• 0
Joao Paulo

Protocol custom I2C Reading Problem

Question

Hello,

I think I need a bit of help. Then, here goes my case

What do I need to accomplish?

  • Read the TSL2561 sensor; ( Here is the help I need now )
  • Convert the values from the sensor using an exponential equation.  (please, point me out some reading on doing so)
  • Export the values to a CSV file; (please, point me out some reading on doing so)

What is going on?

  • I'm trying to use the instrument protocol in the custom tab, but I'm having a hard time to figure out why I'm having the output attached for that code.
  • I see that 
    if(!Write(adr, 0x80, 0x03)) return "Communication error.";

    Works just fine and outputs correctly

           image.png.f8af8e1069a7f6e0ecdae5fbb6873831.png

 

  • But the lines 
    Read(adr, [0xAC], 2);
    Read(adr, [0xAE], 2);

    Are giving me incorrect output as in the picture.

What have I tried?

If I run only one reading, I get it correctly:

Read(adr, [0xAC], 2);

image.png.e32bb3cebd8a9bf3211a45cd96a80c5b.png

Please, see in the picture that Forum_case_I2C_read_outpu.png that it tried to perform 4 readings while I passed only 2 as the parameter. 

Further question?

  • Is that a way enable line number in the editor?

What is my environment?

  • Instrument: Analog Discovery 2
  • IDE: Waveforms 3.10.9

 

Thanks,

 

Forum_case_I2C_read_output.png

image.png

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @Joao Paulo

The WF beta v3.11.10 adds support for multiple I2C transfers in sensor loop function:
https://forum.digilentinc.com/topic/8908-waveforms-beta-download/
In earlier version only one I2C read or write was supported in the loop.

Thank you for the observation.

function loop(){
    var tm = Read(adr, 0x2D, 1);
    var rg = Read(adr, 0xF2, 6);

image.thumb.png.e5406aac6aff45c55a778ddff409900e.png

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now