The Generic-ADC driver on the IoT Gateway is used to read the voltage value on each of the gateway's 4 analog channels.
These channels can be located on the "power side" of the gateway at the end labelled "ANALOG INPUT".
Each channel can read between 0-24 volts with an effective resolution of 9 bits, which means it can read voltage changes every 0.002 Volts.
Each channel references its measurement to the the return channel ( - ) on the input. This means that all analog voltage measurements will share the same analog common.
Setting up the Generic-ADV Driver
To use these values in Tulip, you will have to make sure that the "GENERIC-ADC-VOLTAGE" driver is turned on in the Gateway Portal on the Driver Configuration page.
Using Analog Inputs in Triggers
To use the data in your app, there are two ways can use triggers to capture this analog data.
- Capturing data when the voltage changes
- Requesting the current value of a channel
Here's an example of how to capture data when voltage changes:
- When "device" "Analog Voltage Input" outputs at "this station"
- If "Device Output" "channel" "=" "Static Value" "Integer" "1"
- Then: "Data Manipulation" "Store" data: "Device Output" "voltage" location: (variable)
- Then: "Data Manipulation" "Store" data: "Device Output" "rawValue" location: (variable)
- Then: "Data Manipulation" "Store" data: "Device Output" "channel" location: (variable)
This method will capture the following data every time the gateway detects that the voltage has changed:
- Raw reading from ADC chip
It will not send repeat values. The GENERIC-ADC-VOLTAGE driver will emit data if it detects too much noise on the the single causing the voltage to fluctuate more than 0.002V.
Here's an example of how to request the current value of a channel.
- "When" "button is pressed"
- "Run Device Function" "Analog Voltage Input" "Get current reading" at "this station" channel: "static value" "integer" "1" "Channel 1 reading"
This method will request the current voltage on a specific channel and will return the value even if the reading hasn't changed.
This is necessary for signals from devices such as pressure sensors which, when held at a steady voltage, would not otherwise send an update to Tulip.