...
Phidget Input Parameter List
Name | Description | How Used? |
---|---|---|
DeviceType | Specify the type of device that requires interaction. Supported values are: PhidgetRFID, PhidgetTextLCD, PhidgetGPS, PhidgetInterfaceKit, PhidgetAdvancedServo | DeviceType is passed as a modifier to Invoke. <Invoke Method="Get" DeviceType="PhidgetInterfaceKit"/> |
SerialNumber | This represents the interface port number to which the sensor or motor is connected. | SerialNumber is passed as a modifier to Invoke |
ServoAngle | Angle to be applied to a Advanced Servo Motor. | ServoAngle is passed as a payload to Invoke wrapped within Message/Value container. <Invoke Method="Post" DeviceType="PhidgetTextLCD"> <Message><Value><ServoAngle>110.0</ServoAngle></Value></Message> </Invoke> |
Simulated | Simulates Sensor Behavior by sending random integer values between 1 and 100 | |
- | Some time if you need to pass a String value to the handler as input - usually in case of RFID Writer or LCD Text Display, you can pass it as part of <Message><Value>Hello</Value></Message> as payload to Invoke. | Payload of <Invoke>. <Invoke Method="Post" DeviceType="PhidgetTextLCD"> <Message><Value>Hello</Value></Message> </Invoke> |
Phidget Output Format
Output from the Phidget Handler is simply a text value.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Lon:<value>;Lat:<value>;Alt:<Value>;Vel:<Value>;Head:<Value>;Status:<Value> Default Value for Lon, Lat, Alt, Vel, Head is: Unknown Default Value for Status is false |
Examples
Running Phidget Handler in Simulated Mode
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<USBCameraParameters>
<ImageFormat></ImageFormat>
<SaveToDisk></SaveToDisk>
<ImageName></ImageName>
<Size>
<Height></Height>
<Width></Width>
</Size>
<Configuration>
<Standard></Standard>
<Quality></Quality>
<Channel></Channel>
<Brightness></Brightness>
<Contrast></Contrast>
<Gamma></Gamma>
<Gain></Gain>
<Sharpness></Sharpness>
<Saturation></Saturation>
<Hue></Hue>
</Configuration>
</USBCameraParameters> |
USB Camera Parameter Structure
...
<ThingFacet Name="PhidgetSimulatedFacet">
<Integer Name="SimulatedValue" Update="auto" KnownBy="PhidgetSimAction"/>
<String Name="DeviceType"/>
<String Name="SerialNumber"/>
<Action Name="PhidgetSimAction" Documentation="Returns integer values from 1 - 100 in Random order">
<Workflow Limit="1" Live="1" Timeout="-1">
<Task Name="Main" While="True">
<Event Name="Argument" As="ActionArgument"/>
<Invoke Name="ReadValue" waitFor="Argument" Get="phid://" SerialNumber="[%:Event.Argument.SerialNumber.Value:%]" DeviceType="[%:Event.Argument.DeviceType.Value:%]" Simulated="true"/>
<Output Name="Result" As="ActionResult">
<Value>
<SimulatedValue>[%:[%:@Output:%]Invoke.ReadValue.Message.Value:%]</SimulatedValue>
</Value>
</Output>
</Task>
</Workflow>
</Action>
</ThingFacet> |
Reading Data from Sensors Connected to Phidget Interface Kit
There are few important points to be noted here:
- Note that PhidgetInterfaceKit is usually a multi port device (2/2/2 or 8/8/8) i.e it has 8 USB, and 8 GPI and 8 8 GPO pins.
- When there are multiple sensors attached to the InterfaceKit, there will be multiple instances created in ThingModel to which PhidgetSensorFacet is attached.
- Even though there is one single USB connection, the Protocol handler supports multiplexing of data to different Channel.
- Therefore when we do a Invoke with Get="phid://[%:Event.Argument.SerialNumber.Value:%]" we attach the serial number to make the invocation unique.
- Internally there will be multiple listeners attached to the USB serial port each receiving data and saving to SensorValue.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ThingFacet Name="PhidgetSensorFacet"> <Integer Name="SensorValue" Update="auto" KnownBy="PhidgetSensorAction"/> <String Name="DeviceType"/> <String Name="SerialNumber"/> <String Name="SensorName"/> <Action Name="USBCameraImageAction"> ="PhidgetSensorAction" Documentation="Returns integer values from 1 - 100 in Random order"> <Workflow Limit="1" Live="1" Timeout="-1"> <Task nameName="Main" whileWhile="trueTrue"> <Event nameName="Argument" asAs="ActionArgument"/> <Invoke nameName="GetImageReadValue" waitFor="ActionArgumentArgument" postGet="ucamphid://"> <Message> <Value> <USBCameraParameters> <ImageFormat>[%:Event.Argument.USBCameraParametersSerialNumber.ImageFormat.Value:%]</ImageFormat> <SaveToDisk>" SerialNumber="[%:Event.Argument.USBCameraParameters.SaveToDiskSerialNumber.Value:%]</SaveToDisk> <ImageName>" DeviceType="[%:Event.Argument.USBCameraParametersDeviceType.ImageName.Value:%]</ImageName> <Size> <Height>[%:Event.Argument.USBCameraParameters.Size.Height.Value:%]</Height> <Width>[%:Event.Argument.USBCameraParameters.Size.Width.Value:%]</Width> </Size> <Configuration> <Standard>[%:Event.Argument.USBCameraParameters.Configuration.Standard.Value:%]</Standard> <Quality>" Simulated="false"/> <Output Name="Result" As="ActionResult"> <Value> <SensorValue>[%:[%:@Output:%]Invoke.ReadValue.Message.Value:%]</SensorValue> </Value> </Output> </Task> </Workflow> </Action> </ThingFacet> <!-- Combine with Model --> <ThingModel Name="PhidgetSensors" Combines="PhidgetSensorFacet"> <Sid Name="SensorID"/> </ThingModel> <!-- Activate Sensor --> <Query> <Save format="version,current"> <PhidgetSensors> <SensorName>Rotation</SensorName> <DeviceType>PhidgetInterfaceKit</DeviceType> <SerialNumber>0</SerialNumber> <SensorValue value="$Null()"/> </PhidgetSensors> </Save> </Query> |
Reading Data from a GPS Sensor
- Note that GPS sensor is directly attached to the USB of controller i.e (Raspberry Pi or Laptop or VM)
- If there are multiple GPS sensors you plan to attach you can use SerialNumber create a unique protocol string i.e. phid://1 etc
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ThingFacet Name="GPSPhidgetSensorFacet"> <String Name="GPSOutput" update="auto" KnownBy="GPSPhidgetSensorAction" /> <String Name="SerialNumber" /> <String Name="DeviceType" /> <Action Name="GPSPhidgetSensorAction" Documentation="Connect to GPS sensor"> <Workflow Limit="1" Live="1" Timeout="-1"> <Task name="Main" while="true"> <Event name="Argument" as="ActionArgument" /> <Invoke name="ReadValue" waitFor="Argument" Post="phid://[%:Event.Argument.USBCameraParameters.Configuration.QualitySerialNumber.Value:%]</Quality> <Channel>" SerialNumber="[%:Event.Argument.USBCameraParameters.Configuration.ChannelSerialNumber.Value:%]</Channel> <Brightness>" DeviceType="[%:Event.Argument.USBCameraParametersDeviceType.Configuration.Brightness.Value:%]</Brightness> <Contrast>[%:Event.Argument.USBCameraParameters.Configuration.Contrast"/> <!-- Optionally parse the string if desired --> <Output name="Result" as="ActionResult"> <Value> <GPSOutput>[%:[%:@Output:%]Invoke.ReadValue.Message.Value:%]</Contrast> <Gamma>[%:Event.Argument.USBCameraParameters.Configuration.Gamma.Value:%]</Gamma> <Gain>[%:Event.Argument.USBCameraParameters.Configuration.Gain.Value:%]</Gain> <Sharpness></GPSOutput> </Value> </Output> </Task> </Workflow> </Action> </ThingFacet> |
Display Text on LCD Screen.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ThingFacet Name="PhidgetTextLCDFacet"> <String Name="DisplayString" KnownBy="LCDDisplayAction" Documentation="This is a runtime parameter" /> <String Name="DeviceType" /> <Action Name="LCDDisplayAction" Documentation="Display the string to Phidget Text LCD"> <Workflow Limit="1" Live="1" Timeout="-1"> <Task name="Main" while="true"> <Event name="ActionArgument" as="ActionArgument" /> <Log Message="******Invoking Phidget Text LCD"/> <Invoke name="WriteToLCD" waitFor="ActionArgument" Post="[%:Event.Argument.USBCameraParametersSensorURL.Configuration.Sharpness.Value:%]</Sharpness> <Saturation>" DeviceType="[%:Event.Argument.USBCameraParameters.ConfigurationDeviceType.Saturation.Value:%]</Saturation> <Hue>"> <Message Type="text" Value="[%:Event.Argument.USBCameraParameters.Configuration.HueDisplayString.Value:%]</Hue>" </Configuration> </USBCameraParameters> </Value> </Message>> </Invoke> <Log Message="******Invoked USBCamera******Invoked Phidget Text LCD"/> <Output name="Result" as="ActionResult"> <Value> <Image> <DisplayString>[%:[%:@Output:%]Invoke.GetImageWriteToLCD.Message.Value:%]</Image>DisplayString> </Value> </Output> </Task> </Workflow> </Action> </ThingFacet> <!-- Combine with Model --> <ThingModel Name="PhidgetLCDScreenModel" Combines="PhidgetTextLCDFacet"> <Sid Name="LCDScreenID"/> </ThingModel> <!-- Write Text for first time --> <Query> <Save format="version,current"> <PhidgetLCDScreenModel> <SensorName>Rotation</SensorName> <DeviceType>PhidgetTextLCD</DeviceType> <DisplayString>Hello TQL!</DisplayString> </PhidgetLCDScreenModel> </Save> </Query> <!-- Subsequent Writes can happen via Update Query --> <Query> <Find format="version"> <PhidgetLCDScreenModel> <LCDScreenID ne=""/> </PhidgetLCDScreenModel> </Find> <SetResponseData> <key>Message.Value.Find.Result.PhidgetLCDScreenModel.DisplayString.Value</key> <value>Hello Again!!</value> </SetResponseData> <Update> <from>Result</from> <Include>$Response.Message.Value.Find</Include> </Update> </Query> |
Driver Installation Steps
Installing Phidget Driver
Installing V4l4j
...
1.Before installing the v4l4j some packages are needed to be installed. If you are running debian based operating system type the command
...
2. To download the v4l4j you need subversion(svn) tool, download and install it as shown below
sudo apt-get install subversion
3. Now download the library using the following command
svn co http://v4l4j.googlecode.com/svn/v4l4j/trunk v4l4j-trunk
4. Then go to the v4l4j-trunk directory (cd v4l4j-trunk) and start the build process by typing the command shown below
...
5. If you get this error "error: libv4lconvert.h: No such file or directory" , type
sudo apt-get install libv4l-dev
And do the build process again.
6. Once the build process is completed
7. Install by running command
...
8. Finally test the library by running command
...
Linux: - To install Phidget libraries on your Linux system, the following steps must be performed.
- Install libusb-1.0 development libraries (libusb-1.0-0-dev). This libraries can be installed from the source (http://www.libusb.org/) or if you are running a debian based system you can simply run the command shown below
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
sudo apt-get install libusb-1.0-0-dev
|
- Refer to TQL CLI Protocol Install section for installation of phidget driver.
Note: - For additional information and troubleshooting visit the following website (http://www.phidgets.com/docs/OS_-_Linux)