24U Phidgets Plug-In 2.0 Syntax

Quickfixes for this minor version:

This file describes syntax of 24U Phidgets Plug-In's functions.

Phidget_Version ( { versionFormat } )

Returns version string of the active 24U Phidgets Plug-In, formatted as requested by the parameter.

Parameters

versionFormatDefines the format of the returned version.

Parameter values for versionFormat

shortTo get just the version number
longTo get the plug-in name followed by its version number
platformTo get the platform of the code currently running
phidgetlibTo get the version of Phidget library.

Examples

Phidget_Version("phidgetlib")
This will return for example: "Phidget21 - Version 2.1.8 - Built Aug 21 2015 10:20:29"

Phidget_Register(selector)

Provides special functionality to operate with plugin serial numbers.

Parameters

selectorDefine the type of operation.

Parameter values for versionFormat

SerialNumber Register given SerialNumber and return an error code.
EmailAddress Tries to activate with given email address and return an error code. Trial version is valid only after you confirm email.
"Registration Window" Show the "Registration window" and return 0.
"About Window" Show the "About window" and return 0.
"Status" Return the actual registration state of the plugin: Demo, Demo expired, Trial, Trial Expired, Registered or Dead.
"Unregister" Unregister all serial numbers related to the product and return an error code. Note: after this trial version days wont come back.

Examples

Phidget_Register( "address@example.com" )
This will send email on address@example.com for confirmation, if you confirm than you will get trial version on this product verified by this email.

Phidget_Register( "PHD20C666-4B7B-37PH-Q2E6-1UKY" )
This will register this product with key: "PHD20C666-4B7B-37PH-Q2E6-1UKY".

Phidget_Register( "Unregister" )
This will remove all registered keys. After this call product is no longer registered.

Result

Returns zero or error code depending on the selector.

Phidget_Read ( phidgetSN ; valueID { ; index ; { extra } } )

Reads data from the Phidget.

Parameters

phidgetSNThe Phidget serial number. Use -1 for the first available device.
valueIDSpecifies which data should be read.
indexDefault to 0. Index of the port of IO Phidget or another index information if needed
extraSpecifies some options for specific Phidget type.

Parameter values for valueID

valueIDPhidget typeDescription
"inputValue" GeneralReturns value of the default input.
"inputState" Interface KitReturns the value of the digital input.
"sensorValue" Interface KitReturns the value of the analog input.
"sensorRawValue"Interface KitReturns the raw value of the analog input.
"outputState" Interface KitReturns the value of the analog output.
"outputState" RFIDReturns the state of the designated digital output.
"tag"RFIDReads the RFID tag value. Note: before reading antenna on device has to be on. See Phidget_Set.
"motorPosition" ServoReads the position of the motor.
"bridgeValue" BridgeReads the value of port (port has to be enabled).
"voltage"AnalogReads voltage level on port of Phidget Analog.

Parameter values for extra

extraPhidget typeDescription
"autoDetect" RFID Use this flag to autodetect the tag protocol from the tag. Without this flag, the first 5 characters of the tag content is converted into 10 character long string to ensure backward compatibility with solutions created for plug-in version 1.x.
Note: all new solutions are recommended to use this flag.

Description

The "General" Phidget Type can be used with all Phidgets. The default input for all Phidgets is the first valueID for each phidget in this list. For example calling Phidget_Read( -1 ; "inputValue" ) is the same as Phidget_Read( -1 ; "motorPosition" ) for PhidgetServo.

Result

Function returns data from Phidget if everything is OK. In case of error the function returns "?". You can use Phidget_Get("lastError") for more detailed error description.

Examples

Phidget_Read(-1 ; "inputValue")
The most basic reading. This command will read an "inputValue" from a connected Phidget. If more than one device is connected the plug-in will choose the first device which was connected.

Phidget_Read(phidgetSN ; "sensorValue" ; 3)
Reads a value from the fourth sensor of the InterfaceKit. If the field phidgetSN does not contain correct serial number of the the Interface Kit Phidget (which must be connected in the time of reading) than the function will fail and returns "?".

Phidget_Read(phidgetSN ; "bridgeValue" ; 1)
Reads value from port 1 on Phidget Bridge. If the port is disabled or any other error occured than the function will fail and returns "?".

Phidget_Read(335882 ; "tag")
Reads tag value from Phidget RFID.

Phidget_Read(335882 ; "tag")
Assume, that tag contains value "hello world!" using protocol PHIDGET. Because "autoDetect" is not used, output value is converted to "68656c6c6f".

Phidget_Read(335882 ; "tag" ; 0 ; "autoDetect")
Assume, that tag contains value "hello world!" using protocol PHIDGET. This returns "hello world!".

Phidget_Write( phidgetSN ; valueID ; data { ; index { ; tagProtocol } } )

Data to the Phidget are written or set.

Parameters

phidgetSNThe Phidget serial number. Use -1 for the first available device.
valueIDSpecifies which data should be written.
dataData to write or set. Please use FileMaker number type for numbers and text for strings. The plug-in will try to convert them if necessary.
indexDefault to 0. Index of the port of IO Phidget or another index information if needed
tagProtocolDefault to PHIDGETS. See tag protocols for more information.

Parameter values for valueID

valueIDPhidget typeDescription
"outputState" GeneralWrite value to default output.
"outputState" Interface KitWrite data to digital output.
"outputState" RFIDNew value to the output is written.
"tag" RFIDNew tag is written. Note: antenna has to be turned on before reading. See Phidget_Set.
"motorPosition" ServoSets the new motor position.
"displayString"TextLCDNew text to LCD is written on the first row.
"voltage"AnalogAllows to set voltage level of given port. Don't forget to enable port in order to make it work.

Description

The "General" valueIDs can be used with all sensors. The default output for all Phidgets is the first valueID for each Phidget in this list. For example calling Phidget_Write( -1 ; "outputState" ; 20 ) is the same as Phidget_Write( -1 ; "motorPosition" ; 20 ) for PhidgetServo.

Result

Function returns 0 if everything is OK. In case of error the function returns negative error code or Phidget Error code.

Examples

Phidget_Write(-1 ; "outputState" ; 20)
This will write a value "20" to the first connected phidget if it is possible.

Phidget_Write( phidgetSN ; "motorPosition" ; 215)
It rotates the servo in PhidgetServo to 215 degrees. PhidgetSN parameter should contain a valid serial number of connected servo phidget.

Phidget_Write( 69418 ; "outputState" ; 1 ; 5)
Sets the sixth output of the interface kit phidget with serial number 69418 to 1.

Phidget_Write( 335882 ; "tag" ; "Your text." )
New tag is written. Used tag protocol: PHIDGETS (See tag protocols for more information.)

Phidget_Write( phidgetSN ; "tag" ; "999123456789012"; 0 ; "ISO11785_FDX_B" )
New tag is written. Used tag protocol: ISO11785_FDX_B (See tag protocols for more information.)

Phidget_Write( phidgetSN ; "tag" ; "123456789a"; 0 ; "EM4100" )
New tag is written. Used tag protocol: EM4100 (See tag protocols for more information.)

Phidget_Write( phidgetSN ; "displayString" ; "Hello World!"; 0)
New text is written on the first row. Note: Rows are indexed from zero. If text is not visible, please check backlight, brightness and contrast.

Phidget_Write( phidgetSN ; "displayString" ; "special chars: "& char(224) & char(225) & char(226) & char(227) ; 1)
Special characters on the first row are written. More about special characters can be found here.

Phidget_Write( phidgetSN ; "outputState" ; 2,6 ; 1)
Set output voltage to 2,6V on port 1 (assuming this port is enabled).

Phidget_SetScriptEvent( phidgetSN ; event/time ; scriptName { ; index { ; changeAmount { ; threshold } } } )

Tell the plug-in to launch the script when specified event is triggered by the Phidget or in specified time intervals.

Parameters

phidgetSNThe Phidget serial number. Use -1 for the first available device.
eventThe event when the script should be triggered. Use FileMaker text to describe it. I.e. "onSensorChange".
timeThe time interval on which the script should trigger. Use FileMaker number i.e. 1.8. Time is in [s]. Time must be a positive number. Setting time lower than 1 s is not recommended.
scriptNameThe name of script which should be triggered. The script will receive a parameter which will contain at least phidgetSN on the first row. More values can be added depending on the event.
indexThe index of analog input or output to trigger the script. The script will be triggered only if the value will exceed changeAmount. If omitted the script will be triggered every time when any of inputs/outputs are changed regardless of its number.
changeAmountThe amount of change that should exist between the last reported value and the current value before an event triggers. The default is 1. This cannot be changed for binary inputs or outputs. Use FileMaker number. Param changeAmount can be used only on onSensorChange event, it is ignored on other events.
thresholdThe script will not be triggered until the sensor value exceeds threshold. Use it as a simple noise filter. It has no meaning for binary inputs/outputs. The default value is 0 - no filtering.

Parameter values for event

eventPhidget typeDescriptionScript is given parameters:
"onAttach" GeneralRun the script when some phidget is attached. PhidgetSN must be set to "all". PhidgetSN.
"onDetach" GeneralRun the script when some phidget is detached. PhidgetSN must be set to "all". PhidgetSN.
"onInputChange"GeneralRun the script when default input is changed. PhidgetSN index value
"onInputChange"Interface KitRun the script when digital input is changed. PhidgetSN index value
"onSensorChange"Interface KitRun the script when the value from connected sensor is changed. The amount can be set by the changeAmount. PhidgetSN index value
"onOutputChange"Interface KitRun the script when output is changed. PhidgetSN index value
"onTag" RFIDRun the script when a tag approaches RFID sensor. PhidgetSN index tagBackwardCompatibleString tagValueString
"onTagLost" RFIDRun the script when a the sensor losts the connection with a tag. PhidgetSN index tagBackwardCompatibleString tagValueString
"onOutputChange"RFIDRun the script when output is changed. PhidgetSN index value
"onMotorPosChange"ServoRun the script when the motor position is changed. PhidgetSN index value
"onBridgeData" BridgeRun the script when dataRate time has passed. PhidgetSN index value

Description

Some events are the same for more Phidgets. The "General" event "onInputChange" can be installed to all listed Phidgets and it will behave as their default input event. For example: Phidget_SetScriptEvent( -1 ; "onInputChange" ; "Do Something" ) has the same meaning as Phidget_SetScriptEvent( -1 ; "onMotorPosChange" ; "Do Something" ) for PhidgetServo or Phidget_SetScriptEvent( -1 ; "onTag" ; "Do Something" ) for PhidgetRFID. If "onInputChange" is used, the phidget type is detected automatically and the event is installed to it.
Param changeAmount can be used only on onSensorChange event. On other events it is ignored.

In both cases (event/time) the script will receive a parameter containing the value list with phidgetSN, inputIndex and inputValue. Values for digital input can be "0" or "1" for analog it varies by the type of the event.

To remove event call Phidget_SetScriptEvent( phidgetSN ; event/time ; "" ).
To remove all events from some phidget call Phidget_SetScriptEvent( phidgetSN ; "" ; "" ).
To remove all events from all Phidgets call Phidget_SetScriptEvent( "" ; "" ; "" ) or Phidget_SetScriptEvent( "all" ; "" ; "" ).

Result

Function returns 0 if event is successfully installed or uninstalled. In case of error the function negative error code or Phidget Error code.

Examples

Phidget_SetScriptEvent(-1 ; 1.2 ; "Default Script")
This will install the script named "Default Script" to the first available connected phidget. The script will run every 1.2 second and it will obtain a parameter which consist of serial number, "0" and input value. Each on new line. The "0" signals that the input on index 0 is beeing read.

Phidget_SetScriptEvent(phidgetSN ; "onTag" ; "Process new tag")
The script "Process new tag" will be triggered every time the new RFID tag is in the vicinity of the RFID phidget. The script will receive a parameter with phidget serial number, "0" and RFID value of the tag. Each on the new line. The zero means, that the first input of RFID phidget is used.

Phidget_SetScriptEvent(69418 ; "onSensorChange" ; "Read sensor" ; 6 ; 10 ; 5)
This will install "onSensorChange" event to the interface kit phidget with serial number 69418. The phidget must be connected. The "Read sensor" script will be triggered when the seventh sensor's value on the interface kit phidget with SN 69418 will change more than 10 points and will be higher than 5. The script will receive the parameter which will contain: "69418", "6" and sensor value. Each on the new line.

Phidget_SetScriptEvent("all" ; "onAttach" ; "New phidget attached")
The script "New phidget attached" will be called every time when user will connect a new phidget to the system. The script will receive a parameter with serial number of the new connected phidget.

Phidget_Get( what { ; more ; index } )

Function to get plug-in or phidget settings and other useful data.

Parameters

whatWhich data should be get.
moreAdditional specifier to concretize the request.
indexAdditional specifier to get data for specific part (see example).

Parameter values for what

whatPhidget typeDescription
"lastError" Not usedReturns the error code of the last error. If no error occurred 0 is returned.
"libraryVersion" Not usedGet version of Phidget Library installed on system.
"attachedDevices" Not usedGet number of attached devices.
"serialNumber" Phidget IndexSerial number of the device with index specified in "more" parameter.
"deviceType" PhidgetSNType of the device specified by PhidgetSN.
"deviceName" PhidgetSNName of the device specified by PhidgetSN.
"deviceVersion" PhidgetSNVersion of the device specified by PhidgetSN.
"deviceLabel" PhidgetSNLabel of the device specified by PhidgetSN.
"numInputs" PhidgetSNThe number of default inputs.
"numOutputs" PhidgetSNThe number of default outputs.
"numSensors" Interface KitNumber of sensors.
"ratiometric" Interface KitReturns phidget ratiometric status.
"antennaOn" RFIDThe status of the antenna of the RFID reading device.
"ledOn" RFIDThe status of the LED.
"tagProtocol" RFIDReturns RFID tag protocol. See tag protocols for more information.
"backlight" TextLCDGets the state of the backlight.
"brightness" TextLCDGets the brightness of the backlight. (Not supported on all TextLCDs)
"contrast" TextLCDGets the last set contrast value.
"numRows" TextLCDGets number of rows on LCD display.
"numColumns" TextLCDGets number of columns on LCD display.
"cursorOn" TextLCDGets '1' if cursor is on..
"cursorBlink" TextLCDGets '1' if cursor should be blinking.
"enabled" Bridge and AnalogGets "1" if port is enabled.
"dataRateMin" BridgeGets minimal possible data rate.
"dataRateMax" BridgeGets maximum possible data rate.
"dataRate" BridgeGets actual data rate for getting values from bridge automatically.
"gain" BridgeGets the value of actual gain (something and precision).
"bridgeMin" BridgeGets bridge minimal possible value on port.
"bridgeMax" BridgeGets bridge maximal possible value on port.
"voltageMin" AnalogGets voltage minimal possible value on port.
"voltageMax" AnalogGets voltage maximal possible value on port.
"servoMin" AdvancedServoGet minimal value for servo position.
"servoMax" AdvancedServoGet maximal value for servo position.
"engaged" AdvancedServoGets '1' if servo on position is on.

Description

The "more" parameter is usually used to specify Phidget Serial Number. Some commands need specific PhidgetSN (of specific type) otherwise they will fail. Some commands are more general. You can use PhigetSN value "-1" to specify the default Phidget.

The boolean values are returned in number form. For example Phidget_Get("antennaOn" ; -1) returns 0 if backlight is off and 1 if backlight is on.

Result

Function returns data if everything is OK. In case of error the function returns "?". You can use Phidget_Get("lastError") for more detailed error description.

Examples

Phidget_Get("attachedDevices")
This will return the number of attached devices. If no phidget is attached to the machine it will return 0. It is a good command to start with to check if any phidget is connected.

Phidget_Get("serialNumber" ; 3)
If you have four Phidgets connected to the machine this will return the serial number of the fourth one. Use this command in the loop (along with previous one) to enumerate serial numbers of all Phidgets connected to the machine.

Phidget_Get("deviceType" ; 69418)
This will check the connected phidget with SN 69418 and returns its type. The types are textual in human readable form. For the supported types the result can be: "PhidgetInterfaceKit", "PhidgetRFID" and "PhidgetServo". In general the type names are the same as the official ones.

Phidget_Get("deviceType" ; 120538 ; 1)
This will return device type of given PhidgetSN, however it will try to locate the second type of given PhidgetSN. Example: you have TextLCD combined with InterfaceKit, this allows you to get device type of the second device.

Phidget_Get("enabled" ; 140923 ; 2)
This will check if port 2 on Phidget Bridge is enabled. Port has to be enabled, if we want to read data.

Phidget_Get("dataRateMin" ; 140923)
This will return minimal rate in Phidget Bridge. Value is in ms and if you set data rate, it should be lesser or equal.

Phidget_Get("numColumns" ; 120538)
This will return number of columns of Text LCD with SN 120538.

Phidget_Get("numRows" ; 120538)
This will return number of rows of Text LCD with SN 120538.

Phidget_Get("contrast" ; 120538)
This will return current value of contrast of Text LCD with SN 120538.

Phidget_Get("brightness" ; 120538)
This will return current value of brightness of Text LCD with SN 120538.

Phidget_Get("backlight" ; -1)
This will return backlight status of the first found Text LCD.

Phidget_Set( what ; value { ; phidgetSN ; index } )

Function to set plug-in or phidget settings and other useful data.

Parameters

whatWhich data should be set.
valueThe new value.
phidgetSNThe Phidget serial number. Use -1 for the first available device.
indexIndex of changed value.

Parameter values for what

whatPhidget typeDescription
"ratiometric" Interface KitSets phidget ratiometric. The phidget with ratiometric will measure more precise if ratiometric sensor (marked with R) is attached.
"antennaOn" RFIDSets the status of the antenna of the RFID reading device.
"ledOn" RFIDSets the status of the LED.
"backlight" TextLCDSets the state of the backlight. Possible values are 1 and 0.
"brightness" TextLCDSets the brightness of the backlight. Not supported on all TextLCDs. Possible values of brightness are 0-255.
"contrast" TextLCDSets the contrast value. Possible values of contrast are 0-255.
"cursorOn" TextLCDThis allows to turn on/off cursor.
"cursorBlink" TextLCDIf cursor is on, then you can turn on/off its blinking.
"enabled" Bridge and AnalogThis will enable port on given index.
"gain" BridgeThis will allow you to set gain of data from the bridge;
"dataRate" BridgeThis will allow you to set data rate of incomming data.
"motorOn" ServoTurns a Motor On & Off.
"servoMax" AdvancedServoAllow to set minimal value for servo (prevents servo from being damaged).
"servoMin" AdvancedServoAllow to set maximal value for servo (prevents servo from being damaged).
"engaged" AdvancedServoThis will allow to turn on/off servo.

Result

Function returns set value if everything is OK. In case of error the function returns "?". You can use Phidget_Get("lastError") for more detailed error description.

Examples

Phidget_Set("ratiometric" ; 1 ; 69418)
This will set the ratiometric value to 1 (turns on) in the phidget with SN 69418. This phidget must be interface kit phidget otherwise "?" is returned.

Phidget_Set("ratiometric" ; 1 ; -1)
This will set the ratiometric value to 1 (turns on) in the first phidget it founds. This phidget must be interface kit phidget otherwise "?" is returned. Use this form if you have only one phidget connected to the computer and you are sure that you will never connect any other phidget otherwise the result can be unpredictable.

Phidget_Set( "backlight" ; 1 ; 120538)
This will set the state of the backlight. Possible values 0 (off) or 1 (on).

Phidget_Set( "contrast" ; 155 ; 120538)
This will set the contrast value. Possible values 0-255.

Phidget_Set( "motorOn" ; 1 ; 170192 ; 3)
This will turn on the fourth motor.

Phidget_Set( "motorOn" ; 0 ; 170192 ; 0)
This will turn off the first motor.

Phidget_Set( "enabled" ; 1 ; 140912 ; 3)
This will enable port 3 on Bridge.

Phidget_Set( "dataRate" ; 200 ; 140923)
This will set data rate of Phidget Bridge on 200 ms. Be careful - data rate should be between data rate min and data rate max.

Phidget_Set( "enabled" ; 1 ; 131907 ; 3)
This will enable port 3 on Analog (assuming proper phidgetSN was given).

Phidget_Connect( address ; password {; port } )

Function to connect to SBC via network.

Parameters

addressAddress of SBC in network.
passwordPassword for security.
portPort of service. In case you wont use, port 5001 is used.

Result

Function return 0, if everything OK, if function returns "?". You can use Phidget_Get("lastError") for more detailed error description. However, even if function returns 0, it doesn't mean that SBC is already connected. If you have slow network, then it can take some time. Connected SBC will trigger "onAttach" script (if set).

Examples

Phidget_Connect("10.0.3.51" ; "111111")
Try to establish connection to address 10.0.3.51 with password "111111" on port 5001.

FileMaker example of using this feature can be found here.

Phidget_Disconnect( address )

Function to disconnect from SBC.

Parameters

addressAddress of SBC in network.

Result

Function return 0, if everything OK, if function fails - it returns "?". You can use Phidget_Get("lastError") for more detailed error description.

Examples

Phidget_Disconnect("10.0.3.51")
Disconnects from address 10.0.3.51.

Tag protocols of RFID

This section explain tag protocols used for writing on RFID tag.
Tag protocol specifies, which format of input data is accepted. Table below shows supported protocols.

Tag protocol Accepted value
PHIDGETS Strings or numbers (integer).
ISO11785_FDX_B Strings with 15 numbers (3 state code, 12 animal code).
EM4100 Strings of 10 hexadecimal numbers (0-f).

24U Phidget Plug-In status codes

-50Means paramErr, Phidget_ has wrong parameters.
-36Returned when RFID Reader / Writer has not RFID tag to read / write.
24001 Demo mode expired. If you want to keep using the plug-in, you must register it or buy it for particular environment.
24002 Product expired. Trial period is over. If you want to keep using the product, you must buy it for particular environment.
24003 SN limit was met. The serial number is already registered on too many computers.
24004 Product is dead. The product expired and cannot be used any more. Please download the new version from 24U Software.
24005 Invalid serial number. Serial number you entered is not valid.
24006 Activation failed. Activation failed probably due to some network error. Please, check your connection to the internet and try again later.
24007 Deactivation failed. Deactivation failed probably due to some network error. Please, check your connection to the internet and try again later.
24008 Unknown serial number. The given serial number cannot be used for the current product. It has been stored so that other product can try to use it.
24009 Blacklisted serial number. The given serial number has been blacklisted and cannot be used anymore. Please, contact 24U Support if you need more information.
24010 eSellerate engine not installed. This product uses eSellerate to validate user registration and purchases, but its installation failed. Please, reboot the computer or try again later.