You are not logged in.
Pages: 1
Topic closed
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
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
Hi,
Yes I have tried it but I am not getting the expected result. How can I see the debug logs?
thanks
Fred
Offline
Hi Fred,
please see the REXLANG documentation, namely the Trace command.
Hope this answers your question.
Jaroslav
Monarco HAT for Raspberry Pi - Lightweight I/O for monitoring, archiving and control.
Raspberry Pi in industrial automation!
Offline
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
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
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
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
Pages: 1
Topic closed