Analog Input Guide: Difference between revisions

From Phidgets Support
No edit summary
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<metadesc>Analog Inputs are used to read signals, that range from 0 to 5 volts DC. You can find analog sensors and interface boards at Phidgets.com.</metadesc>
[[Category:Primer]]
[[Category:Primer]]


Analogs Inputs are used to interface many different types of sensors, such as temperature, humidity, position, or pressure sensors.
==Introduction==
Phidget InterfaceKits such as the [{{SERVER}}/products.php?product_id=1018 1018 - PhidgetInterfaceKit 8/8/8] have multiple analog inputs.
It is common for a sensor to output a voltage in order to relay information about what it is measuring. For example, the 1124 temperature sensor has the following characteristics:
Each Analog Input provides power (Nominal +5VDC), ground, and an analog voltage return wire driven by the sensor to some voltage
[[File:Analoginput_tempsensor.jpg|link=|right|500px|The 1124]]
The Interface Kit continuously measures this return voltage and reports it to the application.
{|class="wikitable" style="text-align: center; margin:auto;"
 
|style="background:#f0f0f0;"|'''Measured Temperature (°C)'''
Phidgets offers a wide variety of sensors that can be plugged directly into the board using the cable included with the sensor.
|style="background:#f0f0f0;"|'''Output Voltage (V)'''
 
==Mechanical Specifications==
Each Analog Input uses a 3-pin, 0.100 inch pitch locking connector. 
Pictured here is a plug with the connections labeled.
 
[[Image:analoginput.jpg|right|thumb|link=|A 3-pin analog connector.]]
The connectors are commonly available - refer to the Table below for manufacturer part numbers.
 
 
 
{| style="border:1px solid darkgray;" cellpadding="7px;"
|+'''Cable Connectors'''
|-style="background: #d1d1d1" align=center
! Manufacturer|| Part Number || Description
|-
|style="background: #f0f0f0" align=center| Molex
|style="background: #f0f0f0" align=center| 50-57-9403
|style="background: #f0f0f0" align=left  | 3 Position Cable Connector
|-
|style="background: #f0f0f0" align=center| Molex
|style="background: #f0f0f0" align=center| 16-02-0102
|style="background: #f0f0f0" align=left  | Wire Crimp Insert for Cable Connector
|-
|-
|style="background: #f0f0f0" align=center| Molex
| -50||0.25
|style="background: #f0f0f0" align=center| 70543-0002
|style="background: #f0f0f0" align=left  | 3 Position Vertical PCB Connector
|-
|-
|style="background: #f0f0f0" align=center| Molex
|0||1.37
|style="background: #f0f0f0" align=center| 70553-0002
|style="background: #f0f0f0" align=left  | 3 Position Right-Angle PCB Connector (Gold)
|-
|-
|style="background: #f0f0f0" align=center| Molex
|150||4.75
|style="background: #f0f0f0" align=center| 70553-0037
|style="background: #f0f0f0" align=left  | 3 Position Right-Angle PCB Connector (Tin)
|-
|-
|style="background: #f0f0f0" align=center| Molex
|style="background: #f0f0f0" align=center| 15-91-2035
|style="background: #f0f0f0" align=left  | 3 Position Right-Angle PCB Connector - Surface Mount
|}
|}
<br clear="all">


This means that if you want to know what the temperature is (or pressure, humidity, position, etc.), you will need to measure the sensor's output voltage. In order to do this, you can use any of our [{{SERVER}}/?view=comparetable&rel=Analog%20Inputs Phidgets with an analog input]. Each Phidget with an analog input interfaces with sensors using three wires (as shown in the image above):
*Power (+5 VDC) - provides the sensor with power.
*Ground
*Data - The sensor manipulates the voltage on this line. The Phidget measures and reports this voltage.


Note: Most of the above components can be bought at [http://www.digikey.com www.digikey.com].
 
<br clear=all>
For information about different types of analog inputs, as well as the software objects that are used with analog inputs, visit the [[Phidgets Connectors]] page. Next, we will take a look at the connector that is commonly used for our sensors.
==Connector==
{{AnalogConnector}}


==Electrical Specifications==
==Electrical Specifications==
Line 56: Line 33:
[[Image:analoginputcircuit.jpg|right|thumb|300px|link=|Schematic for a Phidgets analog input.]]
[[Image:analoginputcircuit.jpg|right|thumb|300px|link=|Schematic for a Phidgets analog input.]]


The maximum total current consumed by all Analog Inputs should be limited to 400mA.
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.   
The voltage measurement is represented in the software through the Voltage property as a value between 0 and 5 volts.   
5V corresponds to a high sensor value, and 0V corresponds to zero sensor activity.
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.


One side effect of this oversampling is that very low noise signals will not get full resolution from the ADC without dithering noise injected into the signal. 
The analog inputs on Phidgets InterfaceKits are designed for a maximum of 5V.  More than this will cause unpredictable behaviour and could damage the board.  
 
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.  
<br clear=all>
<br clear=all>
==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.
The ratiometric setting of the interface kit applies to all inputs. Trying to read a sensor with the wrong ratiometric setting will result in incorrect readings. However, it is technically possible to use both ratiometric and non-ratiometric sensors at the same time if you poll for one sensor and then switch the kit's ratiometric setting before polling the other sensor.
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)
<br clear="all">
==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 [[#Changing the Sensitivity/Change Trigger|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 [[Software_Overview#Language_Support|(See your API for more information)]]. For example, here's how you would change data rate in C#:
<div class="source">
<syntaxhighlight lang=csharp>
// 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;
</syntaxhighlight>
</div>
<br>
==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 [[#Changing the Data Rate|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 [[Software_Overview#Language_Support|(See your API for more information)]]. For example, here's how you would change sensitivity in C#:
<div class="source">
<syntaxhighlight lang=csharp>
// 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;
</syntaxhighlight>
</div>
<br>


==Connecting non-Phidget devices to the Analog Inputs==
==Connecting non-Phidget devices to the Analog Inputs==
Line 195: Line 72:
[[File:33vsensor.jpg|thumb|200px|link=|Interfacing a 3.3V Sensor using a 3.3V power supply.<br/>[[Media:33vsensor.jpg|Full-sized Image]]]]
[[File:33vsensor.jpg|thumb|200px|link=|Interfacing a 3.3V Sensor using a 3.3V power supply.<br/>[[Media:33vsensor.jpg|Full-sized Image]]]]


When using a 3.3V sensor with the analog input of a Phidget InterfaceKit, the main challenge is generating the 3.3V supply. You can either buy a 3.3V power supply, or you can buy a voltage regulator to convert the 5V line on the analog input to a 3.3V line, as illustrated in the diagrams. You can also use a second analog input to monitor the output of the 3.3V supply on the regulator. Note that SensorValue will still be equal to the input voltage multiplied by 200, so a 3.3V sensor will saturate at a SensorValue of 667 instead of the usual 1000.
When using a 3.3V sensor with the analog input of a Phidget InterfaceKit, the main challenge is generating the 3.3V supply. You can either buy a 3.3V power supply, or you can buy a voltage regulator to convert the 5V line on the analog input to a 3.3V line, as illustrated in the diagrams. You can also use a second analog input to monitor the output of the 3.3V supply on the regulator.  
 
If the sensor is ratiometric, you can determine the measured value of the sensor expressed as a percentage of the maximum value by dividing the sensor value of analog input 0 by analog input 1. For example, if analog input 1 measures a SensorValue of 667, and analog input 0 measures a SensorValue of 133, then you know that the sensor's measured value is twenty percent of the sensor's maximum value.


<br clear=all>
<br clear=all>
==Factors that can affect Accuracy==


===Interfacing 4-20mA Sensors===
*'''High Output Impedance''' - Sensors that have a high output impedance will be distorted by the 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.


You can use the [{{SERVER}}/products.php?product_id=1132 1132 - 4-20mA Sensor Interface] to read a 4-20mA sensor with an analog input. For more information on 4-20mA sensors, see the [[4-20mA Sensor Interface Primer]].
*'''Voltage Drop''' - Phidget cables have some resistance, which can cause voltage to drop across particularly long lengths of cable. For ratiometric sensors in particular, this can affect accuracy. Long cables also potentially expose the line to a greater amount of interference from surrounding electronics.  


==List of Devices with Analog Input==
*'''Intrinsic Error In Sensors''' - For many sensors, the error is quite predictable by testing it alongside a more accurate sensor, and can be calibrated out in software.


{{:Devices with Analog Inputs}}
*'''Voltage Reference''' - 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.


==Non Phidgets Analog Sensors==
<br clear="all">
 
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.
 
 
 
{| style="border:1px solid darkgray;" cellpadding="7px;"
|-style="background: #d1d1d1" align=center
|+'''Analog Sensors'''
! Manufacturer || Part Number || Description
|-
|style="background: #f0f0f0" align=center| MSI Sensors
|style="background: #f0f0f0" align=center| FC21/FC22
|style="background: #f0f0f0" align=left  | Load cells - measure up to 100lbs of force
|-
|style="background: #f0f0f0" align=center| Humirel
|style="background: #f0f0f0" align=center| HTM2500VB
|style="background: #f0f0f0" align=left  | Humidity sensors
|-
|style="background: #f0f0f0" align=center| Measurement Specialties
|style="background: #f0f0f0" align=center| MSP-300
|style="background: #f0f0f0" align=left  | Pressure sensors - ranges up to 10,000 PSI
|-
|style="background: #f0f0f0" align=center| Freescale Semiconductor
|style="background: #f0f0f0" align=center| MPXA/MPXH
|style="background: #f0f0f0" align=left  | Gas Pressure Sensors
|-
|style="background: #f0f0f0" align=center| Allegro
|style="background: #f0f0f0" align=center| ACS7 series
|style="background: #f0f0f0" align=left  | Current Sensors - ranges up to 200 Amps
|-
|style="background: #f0f0f0" align=center| Allegro
|style="background: #f0f0f0" align=center| A1300 series
|style="background: #f0f0f0" align=left  | Linear Hall Effect Sensors - to detect magnetic fields
|-
|style="background: #f0f0f0" align=center| Analog
|style="background: #f0f0f0" align=center| TMP35 TMP36 TMP37
|style="background: #f0f0f0" align=left  | Temperature Sensor
|-
|style="background: #f0f0f0" align=center| Panasonic
|style="background: #f0f0f0" align=center| AMN series
|style="background: #f0f0f0" align=left  | Motion Sensors
|-
|style="background: #f0f0f0" align=center| Honeywell
|style="background: #f0f0f0" align=center| FS01, FS03
|style="background: #f0f0f0" align=left  | Small, accurate Piezo-resistive load cells
|-
|style="background: #f0f0f0" align=center| AllSensors-Europe
|style="background: #f0f0f0" align=center| BARO-A-4V
|style="background: #f0f0f0" align=left  | Barometric Pressure Sensor - 600 to 1,100 mbar
|}
 
Note: Most of the above components can be bought at [http://www.digikey.com 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.

Revision as of 16:49, 29 November 2017


Introduction

It is common for a sensor to output a voltage in order to relay information about what it is measuring. For example, the 1124 temperature sensor has the following characteristics:

The 1124
Measured Temperature (°C) Output Voltage (V)
-50 0.25
0 1.37
150 4.75



This means that if you want to know what the temperature is (or pressure, humidity, position, etc.), you will need to measure the sensor's output voltage. In order to do this, you can use any of our Phidgets with an analog input. Each Phidget with an analog input interfaces with sensors using three wires (as shown in the image above):

  • Power (+5 VDC) - provides the sensor with power.
  • Ground
  • Data - The sensor manipulates the voltage on this line. The Phidget measures and reports this voltage.


For information about different types of analog inputs, as well as the software objects that are used with analog inputs, visit the Phidgets Connectors page. Next, we will take a look at the connector that is commonly used for our sensors.

Connector

Analoginput.jpg

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


The Phidget cables that are designed to plug into these inputs can be found here.


The connectors and pins they use are also commonly available (usually through digikey) - refer to the table below for manufacturer part numbers.

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


Electrical Specifications

Schematic for a Phidgets analog input.

The maximum total current consumed by all analog inputs should be limited to 400mA. The voltage measurement is represented in the software through the Voltage property as a value between 0 and 5 volts. 5V corresponds to a high sensor value, and 0V corresponds to zero sensor activity.

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

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.

Normally, you can connect a sensor directly to the analog input as long as it has a 0-5V range (or smaller). However, if the sensor is not designed to send its signal across a long cable, you may need to add components as shown in the image.

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.


Interfacing 3.3V Sensors

Interfacing a 3.3V Sensor using a voltage regulator.
Full-sized Image
Interfacing a 3.3V Sensor using a 3.3V power supply.
Full-sized Image

When using a 3.3V sensor with the analog input of a Phidget InterfaceKit, the main challenge is generating the 3.3V supply. You can either buy a 3.3V power supply, or you can buy a voltage regulator to convert the 5V line on the analog input to a 3.3V line, as illustrated in the diagrams. You can also use a second analog input to monitor the output of the 3.3V supply on the regulator.


Factors that can affect Accuracy

  • High Output Impedance - Sensors that have a high output impedance will be distorted by the 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.

  • Voltage Drop - Phidget cables have some resistance, which can cause voltage to drop across particularly long lengths of cable. For ratiometric sensors in particular, this can affect accuracy. Long cables also potentially expose the line to a greater amount of interference from surrounding electronics.
  • Intrinsic Error In Sensors - For many sensors, the error is quite predictable by testing it alongside a more accurate sensor, and can be calibrated out in software.
  • Voltage Reference - 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.