|
|
(176 intermediate revisions by 11 users not shown) |
Line 1: |
Line 1: |
| Preamble about the language and its general strengths and weaknesses.
| | <metadesc>Communicate over USB with sensors, controllers and relays with Phidgets! Our Max/MSP library supports Windows and MacOS.</metadesc> |
| | [[Category:Language]] |
| | __NOTOC__ |
| | We provide support for Max/MSP in '''macOS''' and '''Windows'''. We also provide instructions on how to get your project started. Select your operating system below, and follow the instructions to get your project running with Phidgets. |
|
| |
|
| ==Assessment for use with Phidgets==
| | Once you have set up your development environment to run with Phidgets, we recommend you follow our guide on [[Phidget Programming Basics]]. The guide will showcase the fundamentals of programming with Phidgets. |
| Our honest opinion on how well this language is suited to controlling Phidgets. If it is a poor choice, suggest and link similar (better) languages.
| |
|
| |
|
| ==Support== | | ==Setup Guide== |
| Max/MSP has a complete API and sample code for all Phidgets devices.
| |
|
| |
|
| For a complete list of our supported languages and their support status, [[Levels of Support|click here]].
| | <div class="phd-deck-sequence"> |
| | {{PT3_MAX_CHOOSE}}{{PT3_MAX_WIN}}{{PT3_MAX_MAC}} |
| | </div> |
|
| |
|
| ==Restrictions==
| |
| In this section, list any restrictions or limitations that this particular language may impose. For example, incompatibility with certain operating systems.
| |
|
| |
|
| ==Development Environments and Compilers== | | == Quick Downloads == |
| | If you already know what you're doing and just need the files, you can find them all below. |
|
| |
|
| Describe each major compiler and notable differences or important information. (eg. framework versions) If there are known issues/workarounds mention them and link to the corresponding issue at the bottom of the page.
| | === Documentation === |
|
| |
|
| ==Drivers, Libraries and Resources==
| | *{{Phidget22API}} (Select Max/MSP from drop-down menu) |
| Before you can run your program, you need to set up the proper environment and get the necessary files off the Phidgets website.
| |
| Visit the drivers section at www.phidgets.com and get the latest:
| |
| * [http://www.phidgets.com/drivers.php Phidget Framework] | |
| You will need the Phidget Framework to use and to program with Phidgets. We also recommend that you download the following reference materials:
| |
| * API Manual (Link to API download)
| |
| * API Reference (Link to online API reference (if applicable))
| |
| * Max/MSP Sample Code:
| |
| ** [http://www.phidgets.com/downloads/examples/WinMaxMSP_2.1.8.20110615.zip Windows]
| |
| ** [http://www.phidgets.com/downloads/examples/MaxMSP_2.1.8.20110630.zip Mac OSX]
| |
| * You can find a high level discussion about programming with Phidgets in general on the [[General API]] page.
| |
| * The [[Device Functionality]] page explains the general operational information for your device.
| |
|
| |
|
| You may want to have these pages open while working through these instructions.
| | === Phidgets Max Libraries === |
|
| |
|
| ==Getting Started==
| | * [https://cdn.phidgets.com/downloads/phidget22/libraries/windows/Phidget22MaxMSP.zip Windows Max Libraries for Phidgets] |
| | * [https://cdn.phidgets.com/downloads/phidget22/libraries/macos/Phidget22MaxMSP.zip MacOS Max Libraries for Phidgets] |
|
| |
|
| The Phidget libraries were written to support Max/MSP version 4.5 and greater.
| | === Max Example Code === |
| This tutorial assumes the use of Max 5 but other versions can be set up and used in the same way.
| |
| To install the Phidgets to the Max environment, just add the Phidget Max/MSP examples folder to the Max search path.
| |
| This can be done in Options | File Preferences, by adding the Phidget Max/MSP examples directory to the list.
| |
| The project is now ready to use Phidgets and you can begin by creating a new Patcher (File | New Patcher).
| |
|
| |
|
| ===Coding For Your Phidget===
| | *{{SampleCode|MaxMSP|Max/MSP Example}} |
|
| |
|
| Phidgets can be placed inside the patcher using Max objects, and functions can be called on them using appropriately connected messages. | | ===Phidgets Core Libraries=== |
| The Max/MSP libraries may not implement the full Phidget API - some function calls and Phidget classes may not be supported.
| |
| The help files included with the Phidget externals show all the supported function calls for their type of Phidget.
| |
| Data is accessed either by polling, or at a fixed rate via internal timers.
| |
| The Phidget webservice is supported.
| |
| This tutorial uses a PhidgetInterfaceKit and a new instance will be created.
| |
| It can be done by placing a new “object” object, and naming it PhidgetInterfaceKit.
| |
|
| |
|
| (pic)
| | {{AllQuickDownloads}} |
| | |
| ===Connecting to the Phidget===
| |
| | |
| One important thing to remember is that when working with Phidgets, a local connection will reserve the device until closed.
| |
| This prevents any other instances from retrieving data from the Phidget, including other programs.
| |
| The one connection per device limit does not apply when using the Phidget Webservice.
| |
| Be aware that every Phidget object in Max will automatically try to connect to and reserve the Phidget for itself.
| |
| It will also continuously try to connect to a Phidget, even trying to reconnect if it gets disconnected.
| |
| When the instance is created, normally it will make a connection to the first device of its type it can find.
| |
| The Phidget object can also be declared with a serial number to open a specific Phidget instead:
| |
| | |
| (pic)
| |
| | |
| We can also open remote Phidgets over the Phidget Webservice, for example:
| |
| | |
| Open a remote interface kit using ServerID:
| |
| <font size="3">
| |
| PhidgetInterfaceKit remote “Some remote serverID”
| |
| </font>
| |
| Open a remote interface kit using IP address and port:
| |
| <font size="3">
| |
| PhidgetInterfaceKit remoteip 192.168.2.5 5001
| |
| </font>
| |
| Open a remote interface kit with serial number 35569 on serverID “Patrick’s PC”, with
| |
| password “pass”:
| |
| <font size="3">
| |
| PhidgetInterfaceKit 35569 remote “Patrick’s PC” pass
| |
| </font>
| |
| Open a remote interface kit with serial number 35569, on any remote server
| |
| <font size="3">
| |
| PhidgetInterfaceKit 35569 remote
| |
| </font>
| |
| Open the InterfaceKit on a PhidgetSBC:
| |
| <font size="3">
| |
| PhidgetInterfaceKit remote phidgetsbc
| |
| </font>
| |
| ===Reading and Setting Data===
| |
| | |
| Getting or setting values directly on the Phidget can be done through messages linked to the inlet.
| |
| The object’s inlet can be wired to send commands to the device, and the outlet used to retrieve the results.
| |
| Setting values on the Phidget is achieved by using the set messages, and some properties can be read with get messages.
| |
| | |
| (pic)
| |
| | |
| There are two main approaches for retrieving data when working with Phidgets.
| |
| One is to use the read message, and the other is to setSampleRate and use the start and stop message.
| |
| Read will read the data off the Phidget once, while using start will trigger data to be sent in periodic intervals.
| |
| If the sample rate is set to -1, then data output is only triggered on a change.
| |
| | |
| (pic)
| |
| | |
| Phidget specific data is always given a prefix in Max to allow for their routing.
| |
| For instance, the digital input states are given the prefix “di” and the analog inputs similarly use “ai”.
| |
| The specific prefixes used for each Phidget is listed in their respective help file.
| |
| Data common to all Phidgets, such as the serial number, is not prefixed.
| |
| The following picture would be an example of how to route and split some of the data for the PhidgetInterfaceKit.
| |
| | |
| (pic)
| |
| | |
| ===Working with multiple Phidgets===
| |
| | |
| Multiple Phidgets of the same type can easily be used inside a single program, it only requires another Phidget object placed.
| |
| If two of the same type of Phidget object are placed, the serial number argument should always be specified to ensure that the correct Phidget gets associated with the correct object.
| |
| | |
| ===Other Phidgets===
| |
| | |
| The design given in this document can also be followed for almost all Phidgets.
| |
| For example, if you were using a PhidgetRFID instead of an Interfacekit, you would place a PhidgetRFID object instead of a PhidgetInterfaceKit.
| |
| The messages and data available would change but could be used in a similar manner.
| |
| | |
| ==Building your Project==
| |
| Describe the different ways a project could be built using this language.
| |
| | |
| ==Common Problems and Solutions/Workarounds==
| |
| Here you can put various frequent problems and our recommended solutions.
| |