Alert.png

Notice: This page contains information for the legacy Phidget21 Library.

Phidget21 is out of support. Bugfixes may be considered on a case by case basis.

Phidget21 does not support VINT Phidgets, or new USB Phidgets released after 2020. We maintain a selection of legacy devices for sale that are supported in Phidget21.

We recommend that new projects be developed against the Phidget22 Library.


Click on the 2phidget22.jpg button in the menu bar to go to the Phidget22 version of this page.

Alert.png

Analog Input Primer

From Phidgets Legacy Support


Analogs Inputs are used to interface many different types of sensors, such as temperature, humidity, position, or pressure sensors. Each Analog Input provides power (Nominal +5VDC), ground, and an analog voltage return wire driven by the sensor to some voltage. The PhidgetInterfaceKit continuously measures this return voltage and reports it to the application.

Phidgets offers a wide variety of sensors that can be plugged directly into the board using the cable included with the sensor.

To see a list of currently available analog sensors, click here.

Mechanical Specifications

Each Analog Input uses a 3-pin, 0.100 inch pitch locking connector. Pictured here is a plug with the connections labeled.

A 3-pin analog connector.

The connectors are commonly available - refer to the Table below for manufacturer part numbers.


Cable Connectors
Manufacturer Part Number Description
Molex 50-57-9403 3 Position Cable Connector
Molex 16-02-0102 Wire Crimp Insert for Cable Connector
Molex 70543-0002 3 Position Vertical PCB Connector
Molex 70553-0002 3 Position Right-Angle PCB Connector (Gold)
Molex 70553-0037 3 Position Right-Angle PCB Connector (Tin)
Molex 15-91-2035 3 Position Right-Angle PCB Connector - Surface Mount


Note: Most of the above components can be bought at www.digikey.com.

Electrical Specifications

Schematic for a Phidgets analog input.

The maximum total current consumed by all Analog Inputs should be limited to 400mA. The analog measurement is represented in the software through the SensorValue as a value between 0 and 1000. 5V corresponds to a high sensor value, and 0V corresponds to zero sensor activity. A sensor value of 1 unit represents a voltage of approximately 5 millivolts. The RawSensorValue property brings out a 12-bit value (0-4095) for users who require maximum accuracy. Please note that the sampling is actually done with an oversampled 10-bit ADC, but reported as a 12-bit value to allow future expansion.

The analog inputs on Phidgets interface kits are designed for a maximum of 5V. More than this will cause unpredictable behaviour and could damage the board.

Ratiometric Configuration

The group of Analog Inputs can be collectively set to Ratiometric mode from software using the Ratiometric property. If you are using a sensor whose output changes linearly with variations in the sensor’s supply voltage level, it is said to be ratiometric. Most of the sensors sold by Phidgets are ratiometric (this is specified on the web product page and in the sensor’s product manual).

Setting Ratiometric causes the reference to the internal Analog to Digital Converter to be set to the power supply voltage level. When Ratiometric is enabled, the maximum voltage returned on the Analog Input should be the +5V nominal power provided by the PhidgetInterfaceKit.

If Ratiometric is false, the ADC reference is set to a 5.0V 0.5% stable voltage reference. The maximum voltage returned on the Analog Input should be maximum 5.0V. Note that the Analog Input power supply voltage is not affected by the setting of the Ratiometric property.

When switching ratiometric mode on and off, you need to include a short delay (50ms should be more than enough) before you begin reading values in. This gives the device time to react.

Factors that can affect Accuracy

  • High Output Impedance - Sensors that have a high output impedance will be distorted by the 900K input impedance of the Analog Input.

If your output impedance is high, it is possible to correct for this distortion to some extent in your software application.

  • Power Consumption - Sensor cables have some resistance, and the power consumption of the sensor will cause the sensor to have a slightly different ground from the Analog Input on the PhidgetInterfaceKit. The more power consumed by the sensor, and the longer the sensor cable, the more pronounced this effect will be.
  • Intrinsic Error In Sensors - For many sensors, the error is quite predictable over the life of the sensor, and it can be measured and calibrated out in software.
  • Non-Ratiometric Configuration - Voltage Reference error. The 5.0VDC voltage reference is accurate to 0.5%.

This can be a significant source of error in some applications, but can be easily measured and compensated for.

Some sensors are accurate enough to take advantage of using the raw sensor value. If you want maximum accuracy, you can use the RawSensorValue property. To modify the formula, substitute (SensorValue) with (RawSensorValue / 4.095)


Changing the Data Rate

You can change the data rate for each Analog Input from 1 millisecond to 1 second. By default, the analog input data set is sent to the PC every 8ms. For analog inputs, 8 ms is the maximum transmission rate. This limit is set by the USB processor we use, so there isn't much you can do to get around it.

For values less than 8 ms, the data rate sets the sampling rate, not the transmission rate. If, for example, you set the data rate to 1ms, you will receive a packet containing 8 miliseconds worth of 1 ms samples every 8ms. Setting the data rate at 1, 2, or 4ms will not allow you to react to received sensor data any faster than every 8ms; You will simply get more data samples within the 8ms. This feature is useful if you need to log sensor data at less than 8 ms resolution but don't need to react to it in real-time.

Setting the data rate of the analog inputs is an alternative to setting the sensitivity. Setting one of these values will disable the other, since you can either have events trigger on a regular interval, or on a minimum change.

When the Data rate is set at a multiple of 8 ms, the data rate sets both the sampling rate and the transmission rate. There is also a limit as to how many channels can be set at a high sampling rate, since you will, at one point run out of bandwidth. We estimate that you can set up to 4 channels to 1ms or you could set all channels to 2ms. You can't turn channels off entirely to save bandwidth, you can only set them to a slower data rate. You will get an error when you exceed the available bandwidth, warning you of lost data samples.

Note that data rate is limited to at most 16ms when opening over the Phidget Webservice. Actual data rate will depend on network latency.

The method to change data rate is different in each API (See your API for more information). For example, here's how you would change data rate in C#:

// Create a new InterfaceKit object
InterfaceKit IFK = new InterfaceKit();

// Open a local InterfaceKit over the webservice
IFK.open("localhost",5001);

// Change the data rate of analog input zero to 8ms (125 samples/sec)
IFK.sensors[0].DataRate = 8;


Changing the Sensitivity/Change Trigger

You can change the sensitivity of an analog sensor using our API. You can think of sensitivity as a minimum amount needed to register a change (thus triggering a SensorChangeEvent). Whenever your sensor generates a new value, it will be compared to the sensitivity. If the difference between the previous data point and the new data point is less than the sensitivity value, no event will be generated. Sensitivity is measured in sensorvalue, which is a value between 1-1000 that represents the full range of a sensor. Setting the sensitivity of an analog input is an alternative to setting the data rate. Setting one of these values will disable the other, since you can either have events trigger on a regular interval, or on a minimum change.

The method to change sensitivity/change trigger is different in each API (See your API for more information). For example, here's how you would change sensitivity in C#:

// Create a new InterfaceKit object
InterfaceKit IFK = new InterfaceKit();

// Open a local InterfaceKit over the webservice
IFK.open("localhost",5001);

// Change the sensitivity of analog input zero to "10". 
IFK.sensors[0].Sensitivity = 10;


Connecting non-Phidget devices to the Analog Inputs

Here are some circuit diagrams that illustrate how to connect various non Phidgets devices to the analog inputs on your Phidget.

Sensing the Value of a Variable Resistance Sensor

Schematic for connecting to an FSR.

In this diagram, an FSR (Force Sensitive Resistor) is shown.


Sensing the Position of a Potentiometer

Schematic for connecting to a potentiometer

This diagram shows how to monitor the position of a potentiometer.


Interfacing to an Arbitrary Sensor

Schematic for connecting to a sensor.

Note the use of power supply decoupling and the RC Filter on the output. The RC filter also prevents VOUT from oscillating on many sensors.


Non Phidgets Analog Sensors

In addition to Phidgets sensors, any sensor that returns a signal between 0 and 5 volts can be easily interfaced. Here is a list of interesting sensors that can be used with the PhidgetInterfaceKit 8/8/8. Note: these sensors are not “plug & play” like the sensors manufactured by Phidgets.


Analog Sensors
Manufacturer Part Number Description
MSI Sensors FC21/FC22 Load cells - measure up to 100lbs of force
Humirel HTM2500VB Humidity sensors
Measurement Specialties MSP-300 Pressure sensors - ranges up to 10,000 PSI
Freescale Semiconductor MPXA/MPXH Gas Pressure Sensors
Allegro ACS7 series Current Sensors - ranges up to 200 Amps
Allegro A1300 series Linear Hall Effect Sensors - to detect magnetic fields
Analog TMP35 TMP36 TMP37 Temperature Sensor
Panasonic AMN series Motion Sensors
Honeywell FS01, FS03 Small, accurate Piezo-resistive load cells
AllSensors-Europe BARO-A-4V Barometric Pressure Sensor - 600 to 1,100 mbar

Note: Most of the above components can be bought at www.digikey.com

Analog sensors often have their precision measured in mV/Unit. This value represents how many millivolts the sensor will output given a certain measured value. For example, a temperature sensor might output 1 mV per degree Celsius. You can use this value to build a formula so your program can convert it to the measured quantity. Some sensors can have their mV/Unit output changed, which allows you to tweak the sensor's full scale of measurement. Read your sensor's data sheet for conversion formulae and calibration information.