Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-10-11 17:57:56

farcouet@yahoo.es
Member
Registered: 2016-10-11
Posts: 6

Reading ADS1115

Hi,

I am looking into reading analog values from a ADS1114.

Has anyone made a configuration with rexlang to read a ADS1115?

Thanks!
Fred

Offline

#2 2016-10-12 12:16:12

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Reading ADS1115

Hi Fred,

thank you for your post. Unfortunately, we don't have any example on reading ADS1114/5 available.
However, you can use one of our GitHub examples on integrating other devices via I2C bus using REXLANG as a starting point to speed up your development - https://github.com/rexcontrols/REXexamp … evices/I2C

Hope the above is useful to you.

Best Regards, Tomas

Offline

#3 2016-10-12 17:15:51

farcouet@yahoo.es
Member
Registered: 2016-10-11
Posts: 6

Re: Reading ADS1115

Hi,
Yes I have tried it but I am not getting the expected result. How can I see the debug logs?
thanks
Fred

Offline

#4 2016-10-13 06:33:17

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Reading ADS1115

Hi Fred,
please see the REXLANG documentation, namely the Trace command.

Hope this answers your question.

Jaroslav

Offline

#5 2016-10-30 22:57:09

farcouet@yahoo.es
Member
Registered: 2016-10-11
Posts: 6

Re: Reading ADS1115

Hi,

Yes I have seen the rex documentation. I was looking at a way to see what was sent & received on the I2C bus from Rex. I finally did what I should have done earlier: buy a logic analyzer.
So now withe the logic analyzer I am able to know what to send and what was sending Rex.

My only problem is when I want to send data on the I2C bus but no read anything. From example I use this and set the i2c_read_count to 0. I get no error compiling it but once sent to the Raspi I see an error in the Rexlang block (error 507 numeric argument overflow /urderflow ) . With the logic analyzer I do not see anthing (probably due to this error).
i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);

So how can I send data to I2C bus with this function but do not expect to read anything back?
Thanks,
Fred

So I do this to read:
  i2c_bufTx[0] = 0x01;    // config register is 1
  i2c_bufTx[1] = 0xC3; // bit 15-8 0xD3   11000011
  i2c_bufTx[2] = 0x83; // bit 15-8 0xD3   11000011

  i2c_write_count = 3;
  i2c_read_count = 1;

  i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
   
  i2c_write_count = 1;
  i2c_read_count = 2;
  i2c_bufTx[0] = 0x00;
  i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
 

  adc_value = i2c_bufRx[0] << 8 | i2c_bufRx[1];



But would prefer to do :
  i2c_bufTx[0] = 0x01;    // config register is 1
  i2c_bufTx[1] = 0xC3; // bit 15-8 0xD3   11000011
  i2c_bufTx[2] = 0x83; // bit 15-8 0xD3   11000011

  i2c_write_count = 3;
  i2c_read_count = 0;  <<<<<<--------------- Read count to 0

  i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);
   
  i2c_write_count = 1;
  i2c_read_count = 2;
  i2c_bufTx[0] = 0x00;
  i2c_ret_fun = I2C(i2c_bus_handle, i2c_chip_address, i2c_bufTx, i2c_write_count, i2c_bufRx, i2c_read_count);

  adc_value = i2c_bufRx[0] << 8 | i2c_bufRx[1];

Offline

#6 2016-11-14 12:17:33

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Reading ADS1115

Hi Fred,

thanks to your previous post we found a bug in REXLANG implementation. The read and write counts must be positive - that is the bug.
However, there is a quick-fix for you: set REXLANG parameter "debug" to "1: No check". Afterwards, it won't check the conditions. Please, be aware of potential risks.

Thank you again for your report. Hope it will work for you.

Regards, Tomas

Offline

#7 2016-11-14 18:37:40

farcouet@yahoo.es
Member
Registered: 2016-10-11
Posts: 6

Re: Reading ADS1115

Hi,

Ok I see. I was doing a dummy read and write.

I also see that the code has changed with the new version 2.5. The examples were not refreshed since the new version (nothing complicated to figure out how to fix but might be something worth to mention).

Thanks,
Fred

Offline

#8 2016-11-15 17:29:27

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Reading ADS1115

Hi Fred,

we will check the update of all examples from previous version and update it on our GitHub - thank you for your comment.

Cheers, Tomas

Offline

Board footer

Powered by FluxBB