Other Parts Discussed in Thread: LMP91000, ADS1115, LM4120
Is there any possibilities to use raspberry pi to read ADC(ADS1115) converted analog output voltage of LMP91000 IC ?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I am using LMP91000 IC, the analog out of the ic given to ADS1115 and to read voltage by using raspberry pi.
LMP91000 IC and ADC address are visible.
The current wiring is as follows:
LMP91000 Raspberry pi
DGND GND
MENB GND
SCL SCL
SDA SDA
NC Not connected
VDD 3.3V from raspberry pi
AGND AGND
CE Out to CE
RE Out to RE
WE Out to WE
VREF External 2.5V
VOUT A0 (Analog Read) to ADC
DAP GND
My problem is the instrument continuously gives false readings that do not change according to the chemical environment.
And I've attached the code.
import Adafruit_ADS1x15
import math
import time
#from kivy.core.window import Window
from time import sleep
import smbus
class Main:
#calculate average
total_sum = 0.0
average_counter = 0
average = 0.0
#led = LED(17)
adc = Adafruit_ADS1x15.ADS1115(address=0x4b)
GAIN = 1
adc.start_adc(0, gain=GAIN)
formaldehyde_error_counter = 0
error_msg = ""
def config_lmp91000(self):
bus = smbus.SMBus(1)
device_addr = 0x48
ready_reg_addr = 0x00
lock_reg_addr = 0x01
tiacn_reg_addr = 0x10
refcn_reg_addr = 0x11
modecn_reg_addr = 0x12
while(not bus.read_byte_data(device_addr,ready_reg_addr)):
pass
bus.write_byte_data(device_addr,lock_reg_addr,0x00)
if not bus.read_byte_data(device_addr,lock_reg_addr):
bus.write_byte_data(device_addr,tiacn_reg_addr,0x0c)
bus.write_byte_data(device_addr,refcn_reg_addr,0xc0)
bus.write_byte_data(device_addr,modecn_reg_addr,0x03)
print("Read Reg vales")
print hex(bus.read_byte_data(device_addr,refcn_reg_addr))
print hex(bus.read_byte_data(device_addr,tiacn_reg_addr))
print hex(bus.read_byte_data(device_addr,modecn_reg_addr))
def formaldehyde_thread(self):
start = time.time()
adc_avg = 0.0
adc_sum = 0
counter = 0
while 1:
try:
adc_value = self.adc.get_last_result()
except IOError as e:
adc_value = None
print 'IO Error in formaldehyde thread'
sleep(1)
except:
print 'Not IO Error'
if adc_value is not None:
counter += 1
adc_sum += adc_value
adc_avg = adc_sum/counter
#print 'start', start
#print 'diff', time.time()-start
if((time.time() - start) >= 2):
voltage = round((adc_avg * (0.000125)), 7) * 1000
print 'voltage :', voltage
#base voltage:1.230
if (voltage <= 1614):
ppm_value = 0
else:
ppm_value =round((((voltage - 1614.0))/6),2)
print 'PPM :',ppm_value
#self.update_formaldehyde(ppm_value)
self.total_sum += ppm_value
self.average_counter += 1
self.average = self.total_sum/self.average_counter
adc_avg = adc_sum = 0.0
counter = 0
start = time.time()
if self.formaldehyde_error_counter > 0:
self.formaldehyde_error_counter = 0
self.error_msg = ""
#sleep(.1)
else:
self.formaldehyde_error_counter += 1
if( self.formaldehyde_error_counter == 3):
if not self.error_msg:
self.error_msg = "Error: "
self.error_msg = self.error_msg + "check adc, formaldehyde sensor "
if __name__ == '__main__':
obj = Main()
obj.config_lmp91000()
obj.formaldehyde_thread()
Please check and give solution for this problem.
Dhanalakshmi,
I don't see anything wrong in the schematic, but I do have a few questions.
Can you measure the output voltage of the LMP91000 with a multimeter? What is the voltage, and is it stable? I'm not an expert with the LMP91000 but the load capacitance of the transimpedance amplifier seems high. If the output of the LMP91000 is not correct, you may want to start lowering that value.
Then what is the output data from the ADS1115 and what do you have written into the configuration register?
If there is any question to the output data of the ADS1115, I'd still like to see the I2C communications with either a scope shot or logic analyzer.
Joseph Wu
Hi joseph,
Yes, i can measure the output votage with a multimeter that vout pin of LMP91000. Output voltage is 1.625 it's not stable. It varies from 1.600 to 1.700.
how to reduce the load capacitance value?
ADS1115 used to read the analog output that vout pin of LMP1000, and then this voltage converted into PPM. (Note: see the code i have attached in the previous message)
In the configuaration register:
LOCK register 00: Registers in write mode.
TIA control registor 0C: Choosed TIA feedback resistance: 7K, RLOAD: 10ohm
REF control registor C0: REF_SOURCE: External, INT_Z: 67%, BIAS_SIGN: Negative, Bias selection: 0%
MODE control registor 03: FET_SHORT: Disabled, OP_MODE: 3-lead amperometric cell
Sorry, I don't have scope or logic analyzer.
Regards,
Dhanalakshmi
Dhanalakshmi,
As I mentioned earlier, I'd like to know if you're having problems with the LMP91000 or if the problems are with the ADS1115. At this point, I'm more focused with the ADS1115 because I know this device well. If the problem is with the LMP91000, then I'll ask someone else to help.
Most of my previous questions, I was asking about the ADS1115. For the ADS1115, what is the configuration register set to? What is the gain, data rate, and the multiplexer setting? If the output of the LMP91000 is 1.6V to 1.7V, what are you getting for the output of the ADS1115? I'd prefer that you change your code to also report the ADC output code and not automatically do the conversion. Have you tried measuring a known voltage to see if the ADS1115? Use a lab supply or even a voltage divider to set known input and see what the ADC reports.
Again, I'm not very familiar with the LMP91000 but I did mention the load capacitance on Vout. In your schematic, you have C2 set to 10uF. I thought this might be high. I don't know if there are limitations on the load capacitance on the LMP91000. I would start by removing this capacitor and measuring the output with a multimeter again.
Joseph Wu
Sorry for the delay.
I don't know about the exact problem and configuaration registor set of ADS1115.
We are using ADS1115 in another project, there is no problem in sensor reading value.
So we will planned to purchase LM4120 for testing of lmp91000.
So that i will raise question if there any problem arised after using that LM4120.