ADS1115 ADC 16-bit with PGA use in Flowcode
The ADS1115 ADC is perfect for adding high-resolution analog to digital conversion to any microprocessor-based project. An easy to use Breakout broad is available from Adafruit which we also base our explanation of using the Flowcode Component for the ADC. These boards can run with power and logic signals between 2v to 5v, they are compatible with all common 3.3v and 5v microprocessors. As many of 4 boards can be controlled from the same 2-wire I2C bus, giving up to 16 single-ended or 8 differential channels. A programmable gain amplifier provides up to x16 gain for small signals.
Resolution: 16 Bits
Programmable Sample Rate: 8 to 860 Samples/Second
Power Supply/Logic Levels: 2.0V to 5.5V
Low Current Consumption: Continuous Mode: Only 150µA Single-Shot Mode: Auto Shut-Down
Internal Low-Drift Voltage Reference
Internal PGA: up to x16
I2C Interface: 4-Pin-Selectable Addresses
Four Single-Ended or 2 Differential Inputs
The ADS1115 chip have a base 7-bit I2C address of 0x48 (1001000) and a clever addressing scheme that allows four different addresses using just one address pin. To program the address, connect the address pin as follows:
0x48 (1001000) ADR -> GND
0x49 (1001001) ADR -> VDD
0x4A (1001010) ADR -> SDA
0x4B (1001010) ADR -> SDACL
The Flowcode Component support the Single Ended or Differential configuration of the channels as per datasheet the parameters are exactly as in the Datasheet,It also supports all the PGA gain Configurations with the various Sample rates. As shown below.
The Initialize macro initialize the I2C Interface the user needs to to the configuration in the Component Properties.
The WriteConfigurationsampleSglEnded the user write the configuration for a Single ended conversion and needs to add the parameters as required by the Component
The same for the WriteConfigurationsampleDiffMode this macro configure the ADS1115 for a Differential Conversion.
The Read Macro's Read the Conversion result 2 parameters are needed the Device I2C Address and the Gain you configured for or are using.
Example of the parameters need by the Component All is as per Datasheet
The Component Configures the ADS1115 to Trigger the Alert Pin from High State to low State,the user can use this Falling edge of the Alert Pin to trigger an Interrupt and then read the new conversion data ,Note, depending on the Sample Rate you are using there is a certain delay before the New Conversion Data is ready so if you are not using the Alert pin you need to wait the Conversion Time before reading the channels.
In our example we trigger INT0 then set a Flag and in the code we read the Channel when the Flag is set to zero which is the true state of the Alert Pin which is active low in our configuration,
The procedure is
Write the configuration
Wait for the Alert Pin to trigger
Read the Channel
Write the Configuration for the next Channel
Wait for the Alert pin to trigger
Read the channel as so on
The Component does not support Panel Simulation however it Support SCADA Simulation
The user needs to set the Comms Simulation Property to YES and add a I2C Injector with the Component for the intended SCADA device set the properties of both and Run the simulation.
The Component Package include the Source Code for Advanced users which would like to implement the Comparator Trigger with Threshold settings.
The package also contain a simple example for getting started with the Component.