There are a few more steps involved in dealing with analog inputs than digital inputs. First, the entire Analog to Digital Converter (ADC) portion of the ETH32 device can be enabled or disabled by you at any time. In order for analog values to be read, you must enable the ADC.
You must also ensure that the ETH32 device is configured to use an appropriate analog voltage reference. Whenever an analog conversion is performed by the ADC, this voltage is used as a reference voltage representing the highest possible value. In other words, the readings are scaled so that a 0V signal on an input channel will give the lowest reading (0) and an input voltage equal to the reference voltage will give the highest reading (1023). Please see the eth32_input_analog function or InputAnalog method description for a mathematical representation of how the analog readings are obtained. The analog voltage reference may be supplied by you on one of the pins of the ETH32 (referred to as the external voltage reference) or it may be obtained from one of the internal voltages. The powerup default is the external voltage reference.
The readings from the eight analog pins may be interpreted in different ways, all of which are completely selectable by you. First, you should understand the terms single-ended and differential. A single-ended input yields a reading representing the input voltage with respect to ground. A differential input consists of two input lines and the reading represents the voltage difference between those two lines. The value of the reading is not affected by the voltage of either signal with respect to ground, only the difference between the two voltages. However, please note that the signals are not electrically isolated from ground and must remain within the specified voltage limits of the input signals.
In this documentation, each of the available possibilities for interpreting the analog signals is referred to as a physical channel. For example, a single-ended input from bit 0 is one physical channel, a single-ended input from bit 1 is another physical channel, and the differential between bit 0 and bit 1 is another physical channel. In all, there are 32 physical channels, which are listed later in this document with the function for configuring analog channel assignments.
The ETH32 uses the concept of a logical channel to allow you to specify which of the physical channels should be continuously updated on the device and potentially monitored for event thresholds. There are eight logical channels. Each logical channel can be assigned by you to obtain its reading from any arbitrary physical channel. At powerup, the eight logical channels default to obtaining their readings from the eight single-ended physical channels. If your application requires using a differential channel, you will need to reassign one of the logical channels to obtain its reading from the desired differential channel.
When these settings have been configured appropriately for your application, you are ready to begin reading in analog values.
Task | C / C++ | .NET Languages | Visual Basic 6 |
---|---|---|---|
Enable/disable ADC | AnalogState Property | AnalogState Property | |
Configure voltage reference | AnalogReference Property | AnalogReference Property | |
Configure channel assignments | AnalogAssignment Property | AnalogAssignment Property | |
Obtain analog readings | eth32_input_analog | InputAnalog Method | InputAnalog Method |