Thursday, December 21, 2017

More Phidgets!


Artisan supported hardware from Phidgets since 2013 (see my previous post on Roasting with Phidgets). This year Phidgets fundamentally revised both their hardware and software offerings. With the release of Artisan version 1.2 support for many of the new VINT devices as well as for the new Phidgets v22 driver has been added.

While earlier Phidgets devices came each with a USB connector, the new VINT hardware splits the USB communication interface from the actual device hardware. This has  the advantages of a lower total price for most setups and also reduces the number of USB ports needed to connect multiple Phidgets. One HUB0000 device can connect up to 6 of the new VINT Phidgets. Furthermore, the VINT ports can be used directly for simple input and output tasks.

The new hardware depends on the new Phidgets v22 driver, which also supports all of the previous USB-type Phidgets. This driver completely replaces the previous Phidgets v21 driver, which is not supported anymore by Artisan v1.2. Luckily, both drivers can be installed in parallel without any conflict. One advantage of this new driver is that it reduces the power demand of most Phidgets by more conservative default operation cycles. This is important as USB ports usually have a limit on the maximum power that they can provide to external devices. Thus with the new software you should be able to drive more Phidgets from your USB portswithout having to add a powered USB hub in between which usually adds unacceptable noise to your measurements due to ground loops.


Basic Phidgets Support (all versions)


Initially, Artisan focused on supporting Phidgets that would allow to measure temperatures, the Phidget 1048 reading 4 thermocouples (plus one channel giving the device temperature used internally for temperature compensation) and the Phidget 1046 reading 4 RTDs connected via a Voltage Divider or a Wheatstone Bridge. Later support was added for the Phidget 1051 (supporting just one thermocouple) and the Phidget 1045, featuring a one channel infrared temperature sensor.

To be able to attach also non-temperature sensors to Artisan, support for the Phidget IO family of devices (Phidgets 1010, 1013, 1018, 1019 and the SBC 1073) was added. This allowed to connect for example a Phidgets 1136 pressure sensor to observe the air flow in the roasting machine. However, the support was restricted to the analog inputs ports of those device.

To configure Artisan to read from a Phidget, one has to install the Phidgets driver (v22 for Artisan v1.2 and newer, or v21 for Artisan version before v1.2) and one has to select the corresponding device type (here Phidgets 1048 4xTC 01) from the meter popup in the Device Assignment dialog (menu Config >> Device, first tab ET/BT). Note that in v1.2 of Artisan the Phidgets device names have been slightly renamed to better indicate their features and be better aligned with the naming and channel/port numbering used by Phidgets.



With this configuration Artisan reads the first two channels, channel 0 and 1 as Phidgets channels are counted from 0, of the device as bean temperature (BT) and environmental temperature (ET). These two channels are considered the main devices. To access further channels (for example the 1048 offers 2 more channels), one has to add an extra device (menu Config >> Device, second tab Extra Devices). Each extra device adds two more channels. So to read in the channels 2 and 3 from the connected 1048, one would add an extra device of type Phidgets 1048 4xTC 23.




Note that Artisan before v1.2 did not allow to combine several Phidgets of one type (say several Phidgets 1048 to read more than 4 thermocouples).

For most Phidgets there are some configuration options that are available in the Phidgets tab (menu Config >> Device, 4th tab). This dialog is split into 5 sections. The first one in the top left is used to specify the thermocouple type per channel for the thermocouple input Phidgets like the 1048. The second section allows to specify the RTD type (PT100 vs PT1000) for the TMP1200 VINT Phidget as well as the wiring (2, 3 or 4-wire) used. Similarly, the third section allows to specify the amplifier gain and the wiring (Div: Voltage Divider, WS: Wheatstone Bridge, or raw values). In Section 4, within the second row on the left, one can specify the emissivity for the infrared sensor of the 1048. Moreover, for all device types it is possible to specify the sampling rate and to activate the asynchronous sampling mode. Note that higher sampling rates result in higher power demands. By default the Phidgets continuously read the connected sensor with the given rate and Artisan requests a reading once per its sampling interval. The value returned by the Phidgets is based on some internal averaging of several readings that were taken at its faster internal sampling rate. In asynchronous mode, the Phidget is delivering readings to Artisan once they are higher or lower than the specified change level. Artisan will take the average of all those asynchronously received samples within a sampling interval as reading. See the post on Data Interval/Change Trigger by Phidgets.com.


Finally, the Phidgets tab allows to access Phidgets connected either to a Phidget SBC or a different computer via the network connection (remote sharing enabled via the Phidgets control panel). If the flag in the network section is ticked, Artisan will also attach to Phidgets available under the given IP host and port. If additionally the Remote only flag is ticked, locally connected devices will ignored. This mode allows to force a connection to locally connected Phidgets via the network interface localhost. The advantage of such a setup is that it allows several applications to attach to the Phidgets in parallel, while locally connected Phidgets can otherwise be accessed only by one application (eg. you cannot use the Phidgets control panel and Artisan at the same time).


Revised Phidgets Support (Artisan v1.2 and newer)


In contrast to  previous versions, the Phidgets support has be fully reimplemented to allow to attach Artisan to multiple devices of a given type. To ensure that on start the devices are assigned to Artisan channels always in the same order, Phidgets get ordered internally by their device serial number.

Additional Device Support


List of supported Phidgets was extended by a number of devices, mostly of the new VINT kind.

  • VINT HUB
    • HUB0000: 6 ports can be used to connect either VINT devices, as voltage inputs (in mV), as voltage ratio input, as digital input, or digital PWM outputs
  • Temperature Input
  • Analog Input
    • HUB0000: 6x, analog voltage input in mV
    • 1011: 2x analog voltage input in mV
  • Analog Output
  • Digital Output
  • Digital Input

Digital Input


Digital input channels are assigned the same way as temperature channels, meaning they return only 0 or 1, depending on the binary state of the channel. The device types contain the tag digital in their names, like Phidget 1011 IO Digital 01 which addresses the digital inputs of the channels 0 and 1 of a Phidgets 1011.

Output


Artisan can trigger signal outputs via external device using  slider, or custom button actions. Note that alarms can trigger custom buttons and custom buttons can be hidden. Thus outputs can also be triggered via alarms via some extra button configurations.


There are three types outputs.

  • digital outputs: emitting a binary state, on or off
  • PWM output: emitting a pulse width modulated binary signal from 0-100%
  • analog output: emitting a voltage in a given range


The following actions have been defined to generate those output types.

  • IO Command: to trigger digital outputs
  • PWM Command: to trigger PWM outputs
  • VOUT Command: to trigger analog outputs


For each of the above actions there are corresponding commands defined that are to be specified in the Documentation field of the button or slider definition.


  • IO Command, addressing channel n
    • set(<n>,0) : switches channel n off
    • set(<n>,1) : switches channel n on
    • toggle(<n>) : toggles channel n
    • pulse(<n>,<t>) : sets the output of channel n to on for time t in milliseconds
  • PWM Command, addressing HUB port n with value v in [0-100]
    • outhub(<n>,<v>) : outputs PWM v on channel n
    • togglehub(<n>) : toggles channel n between OFF and last PWM
    • pulsehub(<n>,<t>) : sets the output of channel n to 100% for time t in milliseconds
  • PWM Command, addressing channel n with value v in [0-100]
    • out(<n>,<v>) : outputs PWM v on channel n
    • toggle(<n>) : toggles channel n between OFF and last PWM
    • pulse(<n>,<t>) : sets the output of channel n to 100% for time t in milliseconds
  • VOUT Command, addressing channel n with voltage v:float a voltage in V
    • out(<n>,<v>) : outputs voltage v on channel n
Artisan v2.4. UPDATE:
VINT modules do not have a serial number but can be identified via the HUBs serial number and the hub port they are connected to. In Artisan v2.4 all Phidgets output command actions now support an additional argument to specify the hubs serial number or a combination of the serial number and the port the module to be addressed is connected to. The format of this extra parameter is <hub_serial>[:<port>] like in out(1,21,560282) and out(1,21,560282:2).

Phidget HUB ports are assigned in order of their VINT HUBs serial numbers (lowest first), if the hubs serial number to be addressed is not explicitly given.

Note that in slider commands the placeholder {} gets substituted on slider release by the current slider value. So the slider action PWM Command with the command out(0,{}) will send the slider position (0-100) to reconfigure the output on channel 0 of the connected PWM output Phidget on each slider release.

Further note that output devices are attached on first use and detached on application exit. Therefore it might take a moment to send the first output command to the device. Output channels are attached in order, based on the serial number of the attached devices of the corresponding type to keep the order stable between restarts.

The slider Offset and Factor can be used to map the slider values 0-100 to the required voltage range of an analog output Phidget. If for example an output of 0-10V is required by an application, a factor of 0.1 and offset of 0 will ensure that the output stays in that range over the full range of the slider. A factor of 0.05 and offset of 0 will put the output range to 0-5V.

If one port of a HUB0000 is connected to another one, one can simulate a one bit memory by setting the one port via a digital output command and reading it via a digital input channel. Funny!


Example

The following testbed plays with some of the new functionality possible with the extended Phidget support in Artisan v1.2.



In this setup, Artisan is connected via WiFi to the SBC shown on the right. Connected to this SBC is a SSD on digital output port 1 that drives the battery powered motor shown on the top. Further, an IR distance sensor is connected to the SBC analog input channel 0 and an LED on its digital output port 0. Connected to one of the USB ports of the SBC is a VINT HUB0000 to which a VINT 1 channel isolated TC input TMP1100 and a VINT 4 channel TC input TMP1101 with one TC is connected. A PWM VINT OUT1100 is also connected to the same HUB0000 driving one LED on its channel 0. 



There are 4 custom buttons defined. One to toggle the right most LED, one to turn that one ON and another one to turn it OFF. The last button toggles the motor on and off.


Finally, a slider is defined that dims the LED in the middle via PWM commands.

Here is some footage that shows this setup in action.