...
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.
...
Running Phidget Handler in Simulated Mode.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<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="PhidgetSensorAction" 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://[%:Event.Argument.SerialNumber.Value:%]" SerialNumber="[%:Event.Argument.SerialNumber.Value:%]" DeviceType="[%:Event.Argument.DeviceType.Value:%]" 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.SerialNumber.Value:%]" SerialNumber="[%:Event.Argument.SerialNumber.Value:%]"
DeviceType="[%:Event.Argument.DeviceType.Value:%]"/>
<!-- Optionally parse the string if desired -->
<Output name="Result" as="ActionResult">
<Value>
<GPSOutput>[%:[%:@Output:%]Invoke.ReadValue.Message.Value:%]</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.SensorURL.Value:%]"
DeviceType="[%:Event.Argument.DeviceType.Value:%]">
<Message Type="text" Value="[%:Event.Argument.DisplayString.Value:%]" />
</Invoke>
<Log Message="Invoked Phidget Text LCD"/>
<Output name="Result" as="ActionResult">
<Value>
<DisplayString>[%:[%:@Output:%]Invoke.WriteToLCD.Message.Value:%]</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
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
sudo apt-get install libusb-1.0-0-dev |
- Download Phidget Libraries from this location
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
http://www.phidgets.com/downloads/libraries/libphidget.tar.gz
|
- Unpack the downloaded libraries using the command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
tar -xzvf libphidget_2.X.X.XXXXXXXX.tar.gz |
- Then run the following commands to install Phidget libraries
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
cd libphidget-2.X.X.XXXXXXXX/
sudo ./configure
sudo make
sudo make install |
- Refer to TQL CLI Protocol Install section for installation of phidget driver.
Note: - For additional information and troubleshooting visit the following website website (http://www.phidgets.com/docs/OS_-_Linux)