You are here

Analog Inputs (ADC Module) Overview

Analog Reference Voltage

GPIO-24 analog to digital converter can measure input voltage levels from VRefLow up to VRefHi.

There are 4 modes to setup VRef source of GPIO-24 analog to digital converter:

  • VRefHi is positive supply voltage (VDD), VRefLow is negative supply voltage (VSS);
  • VRefHi is the voltage level on the C.6 (VDD), VRefLow is negative supply voltage (VSS);
  • VRefHi is positive supply voltage (VDD), VRefLow is the voltage level on the C.5;
  • VRefHi is the voltage level on the C.6, VRefLow is the voltage level on the C.5.

Following requirements are reasonable for each mode:

  • Reference Voltage Range (VRefHi – VRefLow) >= 3V;
  • Reference Voltage High VSS<VRefHi<VDD;
  • Reference Voltage Low VSS – 0.3V<VRefLow<VDD – 3.0V;
  • Recommended Impedance of Analog Voltage Source – 2.5k.

With external reference voltage you can achieve better accuracy of measurement than with USB-IO adapter supply voltage. USB-IO adapter supply voltage depends on the voltage level of USB port. When using the external reference voltage, keep in mind that any analog input voltage must not exceed VRefHi.

An inexpensive way to generate VRef is by employing a zener diode (mode 1 VRefHi is the voltage level on the C.6, VRefLow is negative supply voltage (VSS)):

Most common zener diodes offer 5% accuracy. Reverse bias current may be as low as 10 μA. However, larger currents (1 mA - 20 mA) are recommended for stability, as well as lower impedance of the VRef source.

Finally, various reference voltage generator chips (typically using on-chip band-gap reference) are available. They are more accurate.

 

You can measure larger range of voltage levels if you connect the analog input to the output of a voltage divider. It theory, you can measure an indefinitely large DC and AC voltage levels with the help of resistive dividers. But keep in mind that GPIO-24 adapter does not have galvanic isolation from the PC. The improper connection to the source of high voltage (or current) can damage both the USB-IO adapter and the PC. We don’t recommend to measure voltage above 40V with this USB-IO adapter.

Association Between Analog Input Voltage & ADC Digital Code

USB-IO Interface Adapter ADC module allows conversion of an analog input signal to a corresponding 10-bit digital number. The output of the sample and hold is the input into the converter, which generates the result via successive approximation. The analog to digital conversion can be represented mathematically as:

ADC Code = floor(1024*(VIn-VRefLow)/(VRefHi-VRefLow))

where: ADC Code - ADC digital output code; VIn - analog input voltage; VRefHi - high reference voltage; VRefLow - low reference voltage.

We get much simpler expression when VRefLow is equal to zero:

ADC Code = floor(1024*VIn/VRefHi)

If VRefHi = 5V and VRefLow = 0, analog to digital conversion can be illustrated by the following diagram:

 

Digital output code to analog voltage equivalence diagram

ADC Module SW Interface

GPIO-24 analog to digital converter is easy to setup and use. The PC software can request the analog input value at any time. You can also configure the analog to digital converter to send the analog input values each n millisecond. If you want to be notified only when the input voltage reaches the preset value, simply specify the low and high threshold values.

ADC Module Configuration

Use GPIO_SET_ADC_MODULE_CFG command to configure the ADC module of USB-IO adapter. With this command you can enable/disable the ADC module and select the analog reference voltage.

When you enable the ADC module, all 5 pins (C.1, C.2, C.5, C.6 and B.3) are switched to analog input mode. If you have previously configured these pins to send events (with the GPIO_SET_ADC_CHANNEL_CFG command), they begin to send events immediately. To reset pins configurations, set the byte 4 to 1.

When you disable the ADC module, the same 5 pins are switched to digital input mode.

You can specify the analog reference voltage in byte 3 of the GPIO_SET_ADC_MODULE_CFG command. If you set this byte to 0, ADC module will use the USB-IO adapter supply voltage (VDD and VSS). If you set this byte to 1, ADC module will use the voltage level on the C.6 (VRefHi) and C.5 (VRefLow) pins.

ADC Channels (Analog Input Pins) Configuration

By default, USB-IO adapter doesn’t send events for analog inputs. With GPIO_GET_ADC_VAL command you can get the current analog input values.

Use GPIO_SET_ADC_CHANNEL_CFG command to instruct USB-IO adapter to send events for particular analog input pin. You can specify different event sending conditions for each pin. By sending conditions we mean low and high thresholds.

Low and high threshold values are specified in bytes 4-7. USB-IO adapter sends events when the analog input value is greater than low threshold and less then high threshold.

REPEAT value is specified in byte 3. If the REPEAT value is equal to zero, USB-IO adapter will send single event when the analog input value reaches the specified interval. The next event is sent after the analog input value exits from the specified interval and enters it again.

If the REPEAT value is non-zero, USB-IO adapter sends events repeatedly each REPEAT milliseconds, while the condition is valid. You can set low threshold to 0 and high threshold to 0x3FF, specifying the whole range of possible values. Thus you can monitor the changes at analog input continuously.

ADC Module Applications

Analog to digital conversion has many applications. You can acquire data from wide range of analog sensors and save it at PC for further processing. You can also implement a real time analog data processing in your software. In conjunction with other USB-IO adapter modules you can implement feedback control over your hardware.

Analog to digital conversion is well utilized for external analog signal reading such as current, voltage, temperature, distance, pressure, or even color information.

Below, we list some of the ADC module applications with detailed instructions on how to implement them:

- DC & AC Voltage Measurement;

- DC & AC Current Measurement;

- Resistance Measurement.

Rating: 
Average: 2 (1 vote)

User login