24U Phidgets Plug-In 1.0 Syntax

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

Phidget_Register ( registrationCode )

Attempts to unlock (register) your copy of 24U Phidgets Plug-In with the specified code.

Parameters

registrationCodeThe code to unlock the full version of the plug-in.

Description

If the code is valid, 24U Phidgets Plug-In gets unlocked and stays in this state until you quit the FileMaker Pro application, deactivate the plug-in, or the registration code expires. While unlocked, 24U Phidgets Plug-In is fully functional and does not bother the user with a shareware reminder.

Result

Returns a non-zero result when operation is not permitted.

Phidget_Read ( phidgetSN ; valueID { ; index } )

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

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.
"motorPosition"ServoReads the position of the motor.

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_Write( phidgetSN ; valueID ; data { ; index } )

Writes or set data to the Phidget.

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

Parameter values for valueID

valueIDPhidget typeDescription
"outputState"GeneralWrites value to default output.
"outputState"Interface KitWrite data to digital output.
"outputState"RFIDWrites the new value to the output.
"motorPosition"ServoSets the new motor position.

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_SetScriptEvent( phidgetID ; 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 input or output to trigger the script. 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.
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/outpus. The default value is 0 - no filtering.

Parameter values for event

eventPhidget typeDescription
"onAttach"GeneralRun the script when some phidget is attached. PhidgetSN must be set to "all".
"onDetach"GeneralRun the script when some phidget is detached. PhidgetSN must be set to "all".
"onInputChange"GeneralRun the script when default input is changed. The amount can be set by changeAmount.
"onInputChange"Interface KitRun the script when digital input is changed.
"onSensorChange"Interface KitRun the script when the value from connected sensor is changed. The amount can be set by the changeAmount.
"onOutputChange"Interface KitRun the script when output is changed.
"onTag"RFIDRun the script when a tag will approach RFID sensor.
"onTagLost"RFIDRun the script when a the sensor losts the connection with a tag.
"onOutputChange"RFIDRun the script when output is changed.
"onMotorPosChange"ServoThe script when the motor position is changed.

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 instaled to it.

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( phidgetID ; event/time ; "" ).
To remove all events from some phidget call Phidget_SetScriptEvent( phidgetID ; "" ; "" ).
To remove all events from all phidgets call Phidget_SetScriptEvent( "" ; "" ; "" ) or Phidget_SetScriptEvent( "all" ; "" ; "" ).

Result

Function returns 0 if event is sucessfully 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 } )

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

Parameters

whatWhich data shoud be get.
moreAdditional specifier to concretize the request.

Parameter values for what

whatPhidget typeDescription
"lastError"Not usedReturns the error code of the last error. If no error occured 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"PhidgetSN of Interface KitNumber of sensors.
"ratiometric"PhidgetSN of Interface KitReturns phidget ratiometric status.
"antennaOn"PhidgetSN of RFID PhidgetThe status of the antenna of the RFID reading device.
"ledOn"PhidgetSN of RFID PhidgetThe status of the LED.

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")
Returns 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_Set( what ; value { ; phidgetSN } )

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

Parameters

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

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.
"motorOn"ServoTurns a Motor On & Off.

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)
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)
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.