Help with reading i2c output
msiriwardena
Posts: 301
I am using a i2c pressure transducer to read pressures in cm.H20.The transducer I am using is MS4515DO - the Data sheet is attached.
I am using jm_i2c Object - the object and and my code is also attached.
I am able to display the text via PST as in the Demo - but I am unable to display the pressure reading.- the result displayed is "0".
I have tried using the 3 sets of i2c addresses as indicated in the Data sheet,but still unable to display the results.
I have also connected the capacitor accross the power and the pull-ups to the SCL and SDA(4.7k)
I have attached a scope to the SDA and SCL and both show activity ---> the transducer is functioning.
Please help me to solve this issue.This is my first attempt at using i2c bus.
Thank you.
Siri
I am using jm_i2c Object - the object and and my code is also attached.
I am able to display the text via PST as in the Demo - but I am unable to display the pressure reading.- the result displayed is "0".
I have tried using the 3 sets of i2c addresses as indicated in the Data sheet,but still unable to display the results.
I have also connected the capacitor accross the power and the pull-ups to the SCL and SDA(4.7k)
I have attached a scope to the SDA and SCL and both show activity ---> the transducer is functioning.
Please help me to solve this issue.This is my first attempt at using i2c bus.
Thank you.
Siri
Comments
Thanks
Siri
MS4515.putstr(EE, addr,@string3)
where the string3 is
string3 byte "Read_MR"
You only should send a request by means of the address + 1 for a read, or + 0 for a write.
So, instead of sending a string, just send the (address + 1) to read the device. Then read the data.
For Data Fetch commands, the number of data bytes returned by the RBiciLite™ is determined by when the
master sends the NACK and stop condition. For the Read_DF3 data fetch command (Data Fetch 3 Bytes; see
example 3 in Figure 1.6), the sensor returns three bytes in response to the master sending the slave address
and the READ bit (1): two bytes of bridge data with the two status bits as the MSBs and then 1 byte of
temperature data (8-bit accuracy). After receiving the required number of data bytes, the master sends the
NACK and stop condition to terminate the read operation. For the Read_DF4 command, the master delays
sending the NACK and continues reading an additional final byte to acquire the full corrected 11-bit temperature
measurement. In this case, the last 5 bits of the final byte of the packet are undetermined and should be
masked off in the application. The Read_DF2 command is used if corrected temperature is not required. The
Under CON an example of setting up the read or write value ( address + 0 or 1)
Just determine how much data you want to read in before stopping.
Using the minimal i2c driver, you could just just readpage, set the read count to 4 bytes, and read in all the data the comes back, it will auto-ack and stop after the 5th byte. Then you can do what you want with the data that got stored in your array. I would suggest a byte for the incoming data under VAR like this:
VAR Byte datain[3]
You park the 4 data bytes here as the come in from Read Page, then parse as needed. I would start by first just trying to get the device to respond and display any raw data from the 4 bytes. After you are getting some data back, then start to work on parsing the 4 bytes into something usable. Don't try to parse first, just view any data.
I have pull-ups on both SDA and SCL.The minimal i2c driveryou suggested assumes that the SDA and SCL are not pulled-up.
Do I have to disconnect the the pull-ups.
Thaks for the quick reply.
Siri
Try something like the above.
I will give it a try and let you know.
Thanks,
Siri
When using "Minimali2cDrvers" Read Pub - PUB i2cRead(i2cSCL, ackbit) - what is the ackbit? because when I try to complie - error
"Expected an expression" - highligting - "ackbit"
When I replce the "ackbit" with "0" - it reads "255" but does not change with the pressure changes.
Thanks for your help
Siri
For a read, you must first start the driver as shown above with the correct SCL pin, after starting, for the read you send the SCL pin again, followed by the ACK bit. After the read of on or more bytes, you do the stop.
I have attachesd the code I am using.
If i use "1" or "0" for ack - result is "255" and no changes occur during pressure changes.
Thanks for the help.
Siri
Thanks for all your help.
With the last peice of code igot the i2c to work.
Thank you for the patience and great help.
Siri.