Mega524
Posts: 9
Joined: Tue May 29, 2018 2:26 pm

Need help with setting up Pressure Sensor with Pi

Thu Sep 13, 2018 5:31 pm

I have a Pressure Sensor: http://www.dwyer-inst.com/PDF_files/E_111.pdf that I need to connect to the Raspberry Pi in order to display a live graph of the data. I bought an Analog-Digital signal converter: https://store.ncd.io/product/2-channel- ... ni-module/, and then an Analog-Digital signal converter: https://store.ncd.io/product/i2c-shield ... hdmi-port/ for the signal converter to plug into. The way I have it set up right now is signal and ground wires from the pressure sensor plug into the signal converter. The signal converter then plugs into the shield on the pi, which is connected to all of the pins on the pi. I found this Python program to read the inputs from the channels on the signal converter:

Code: Select all

# Simple demo of reading each analog input from the ADS1x15 and printing it to
# the screen.
# Author: Tony DiCola
# License: Public Domain
import time

# Import the ADS1x15 module.
import Adafruit_ADS1x15


# Create an ADS1115 ADC (16-bit) instance.
adc = Adafruit_ADS1x15.ADS1115(address=0x49, busnum=1)

# Or create an ADS1015 ADC (12-bit) instance.
#adc = Adafruit_ADS1x15.ADS1015()

# Note you can change the I2C address from its default (0x48), and/or the I2C
# bus by passing in these optional parameters:
#adc = Adafruit_ADS1x15.ADS1015(address=0x49, busnum=1)

# Choose a gain of 1 for reading voltages from 0 to 4.09V.
# Or pick a different gain to change the range of voltages that are read:
#  - 2/3 = +/-6.144V
#  -   1 = +/-4.096V
#  -   2 = +/-2.048V
#  -   4 = +/-1.024V
#  -   8 = +/-0.512V
#  -  16 = +/-0.256V
# See table 3 in the ADS1015/ADS1115 datasheet for more info on gain.
GAIN = 1

print('Reading ADS1x15 values, press Ctrl-C to quit...')
# Print nice channel column headers.
print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} |'.format(*range(4)))
print('-' * 37)
# Main loop.
while True:
    # Read all the ADC channel values in a list.
    values = [0]*4
    for i in range(4):
        # Read the specified ADC channel using the previously set gain value.
        values[i] = adc.read_adc(i, gain=GAIN)
        # Note you can also pass in an optional data_rate parameter that controls
        # the ADC conversion time (in samples/second). Each chip has a different
        # set of allowed data rate values, see datasheet Table 9 config register
        # DR bit values.
        #values[i] = adc.read_adc(i, gain=GAIN, data_rate=128)
        # Each value will be a 12 or 16 bit signed integer value depending on the
        # ADC (ADS1015 = 12-bit, ADS1115 = 16-bit).
    # Print the ADC values.
    print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} |'.format(*values))
    # Pause for half a second.
    time.sleep(0.5)
For output, I get :

Code: Select all

Reading ADS1x15 values, press Ctrl-C to quit...
|      0 |      1 |      2 |      3 |
-------------------------------------
|     33 |     28 |   4403 |   4407 |
|     33 |     28 |   4404 |   4405 |
|     33 |     28 |   4403 |   4405 |
|     33 |     28 |   4404 |   4407 |
|     34 |     28 |   4406 |   4409 |
|     33 |     28 |   4404 |   4406 |
|     33 |     28 |   4402 |   4406 |
|     33 |     28 |   4401 |   4405 |
|     33 |     28 |   4401 |   4405 |
|     33 |     28 |   4405 |   4405 |
and so on...

I have several questions. First, what are the four channels reading, and how do I extract the Pressure reading from this data? Second, I have set the voltage output of the signal from the pressure transmitter to be between 0 and 5 volts. Do I have to specify that anywhere in the code, or change the Gain value to anything? Finally, is there a recommended Python module for this type of project?

KnarfB
Posts: 194
Joined: Wed Dec 14, 2016 10:47 am
Location: Germany

Re: Need help with setting up Pressure Sensor with Pi

Fri Sep 14, 2018 4:31 pm

Hi Mega524,

> First, what are the four channels reading, and how do I extract the Pressure reading from this data?

the ADV1115 is a 4-channel analog digital voltage converter. Its sensitivity is programmable. The code says GAIN=1. according to the data sheet this means that a voltage of 4.096V yields a reading of 0x7FFF (32767). So the reading 4405 in your table should correspond to 4405 /32767*4.096 V which is about 0.55 V.

The board connects only 2 of the 4 ADC channels and you should have connected one of them to the sensor. The channel number may be printed on the PCB, this is not visible in the picture. The code you found reads all four channels, so ignore 3 of them. You find the right one by stimulating some input and watching which column values are changing.

The measurement voltage comes from one of the two current-voltage converters INA196 on the ADC board (the two little 5-pin chips close to the screw terminal). I would ask the vendor for the transfer function mA->V of those and also do own independent measurments of each conversion step using a voltmeter/amperemeter:

1. What is the current I1 for pressure1, what is the current I2 for pressure2?
2. What voltages V1 and V2 does the INA196 generate form currents I1 and I2?
3. What are the digital readings on the Raspi for V1 and V2?

Everthing should be linear, so if you start with some low and some high(er) pressure, you get the feeling.

hth

KnarfB

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: mgrzemow, pcmanbob and 13 guests