ads1x15-chip command not work
I'm update from b220 to b330.
ads1x15-chip command not work.
After firing this command, I don't receive any response from the shell.
Omega Pin ads1015 Pin --------- ----------- GND GND 5V PWR 20 SCL 21 SDA
As you are, I am running release b330 on my Omega
I have installed ads1x15-chip from opkg
Using the ads1x15-chip command runs OK and using the -x option shows in general the kind of communications I would expect from the chip documentation.
However, the results returned are NOT what I would expect. The output values do not correspond to the voltages applied to the input. Additionally, it is totally unclear as to how the *max voltage is to be specified for the ads1x15-chip command to set the gain to be used. I suspect some flaws in the code for ads1x15-chip
This is born out by separate C++ code I have produced to access the chip (see: code in https://github.com/KitBishop/Omega-Arduino-Expansion as also referenced from https://community.onion.io/topic/899/omega-arduino-expansion-board - you will need to read the documentation in section 4 of https://github.com/KitBishop/Omega-Arduino-Expansion/blob/master/omega_arduino_expansion.pdf for details of how to use my code).
Suffice it to say that my code always reliably returns the input voltage from the ads1015.
We would appreciate your help in fixing up the ads1x15 chip code!
Can you please take a look at the GitHub repo https://github.com/OnionIoT/onion-ads1x15-driver and submit a pull request with your fixes??
@Lazar-Demin Will do. Will contact you when done.
I will try to restore and reinstall.
I removed ads1x15-chip and reinstalled.
It's work !
But I think the output value is wrong as @Kit-Bishop says.
@Lazar-Demin I have found two faults with the ads1x15-chip code.
As a quick summary:
- The order of the bytes in the command sent over I2C was wrong - needs swapping
- Despite the documentation that indicates that the default max voltage range (used to set the gain) is 6.144 volts, if no max voltage is specified, then the gain value does not get explicitly set.
I have fixes for both these problems and have tested them and they work OK.
However, I would like to make some additional minor changes that would make the code easier, more user friendly, and more flexible to use.
If this is OK with you I will complete these additional changes before making my changes available.
@Kit-Bishop Good work!
I think it would be better for the community overall if the fixes to the current code were released as soon as possible, so people can get to tinkering with the ADS chips.
Would you mind creating a Pull Request with the fixes now and then another Pull Request later on with your additional changes?
@Lazar-Demin No problem, but .....
When I tried to create a pull request using GitHub in a branch with my changes, it was rejected for lack of permission on the repository. I assume I need to be authorised to do this.
Luciano S. last edited by
@Kit-Bishop , i guess you just need a actual fork from onion.io to put your changes from your repo in it (and pull request from this new fork). If both of you made changes on the repository, you not have the same versions anymore and a pull request is not possible.
@Luciano-S. Thanks for the hint, I am more used to creating branches in Git and working on that.
Have now successfully created a fork and committed my changes there and created a pull request on it.
@Lazar-Demin Have forked to https://github.com/KitBishop/onion-ads1x15-driver, committed my changes to it and created pull request:https://github.com/OnionIoT/onion-ads1x15-driver/pull/1
This covers just the basic bug fix changes. Hope it is what you want.
Will later do a change with the improvements I would like to see
Thanks @Kit-Bishop!! It looks great!
Looking forward to your improvements!
@Lazar-Demin Thanks for incorporating my changes - glad it's useful.
I have now created a new pull request (https://github.com/OnionIoT/onion-ads1x15-driver/pull/2) with some general improvements to the program. The changes are 100% backward compatible with the original and the new usage is described in the README file.
For reference, the new usage is:
Usage: ./ads1x15-chip [options] <channel> [max-voltage] <channel> Analog input channel, can be 0 to 3 [max-voltage] Optional: Set maximum expected input voltage If used over-rides -g option setting. Enter as a real number for maximum voltage. maximum usable is:6.144 minimum usable is:0.256 [options] - any number of: -q Quiet: no output -v Verbose: debug output -x Extra Verbose: all debug output -g<gain> Gain: gain to use. Affects maximum voltage measurable 0 - max voltage 6.144V - the default 1 - max voltage 4.096V 2 - max voltage 2.048V 3 - max voltage 1.024V 4 - max voltage 0.512V 5 - max voltage 0.256V -t<type> Type: the device type 1015 - 12 bit A/D - the default. Maximum raw data value 2047 1115 - 16 bit A/D. Maximum raw data value 32767 -o<output> Output: form of result output s - standard output giving channel number and raw data - the default r - raw data read m - data read in millivolts v - data read in volts -d Debug: do not carry out any I2C transactions
Luciano S. last edited by Luciano S.
Here you can see the Document with the changes, red the old version green what is new and white it is as it was.
In the end it is that was Kit-Bishop posted.
@Scott-Smith Don't understand how the README got linked in my post, I didn't link it to anything.
Anyway, ifyou want to see it, it is accessible at https://github.com/KitBishop/onion-ads1x15-driver/blob/master/README.md - though it doesn't say anything that isn't in my original post
2Luciano-s, thanks, that explains my confusion. @Kit-Bishop, this is timely and much appreciated, thanks for all your work!