-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signed bit in ADS1015 #4
Comments
Thanks for the information and digging - I wasn't aware of this. Does this only effect the final voltage conversion? Currently this library doesn't actually return voltage, just the 'val' (although there is an open issue about getting final voltage). |
Hi @tomjoro , thanks for the quick reply! The only thing I've used the library for is final voltage so I'm not sure if anything else is affected. I just learned of i2c's existence yesterday so I'm still gaining context. I see the other issue so perhaps this one should be closed in light of that? Happy to help if that is desired/helpful although, again, I'm still gaining context into what a lot of this means. If the other issue is not implemented, I'm curious on your and @mmmries thoughts on this issue, and I'm wondering what |
It's been a while since I was using this, but I think converting to a final voltage also requires some knowledge about the inputs to the ADC, right? Meaning that the user would have to pass in the reference voltage that they are comparing against? In your example above I would have thought that when we pattern match with a |
Looking at the datasheet here it looks like the 16-bit register reserves the 4 lowest bits as always being "0" and then the remaining bits as a signed 12-bit number. It's been a little while since I've thought about these kinds of binaries, so I'm not sure if it matters whether we do the divide by 16 (ie shift 4 bits) before we treat it as a 2's complement number? Maybe the right pattern match is |
Hi, Do you have the PGA (gain) settings at
If so, that would mean the maximum voltage you can measure is +2.048V. The PGA setting actually controls what the maximum voltage can be read.
As I understand, the way the PGA works is that the PGA zooms in on the voltage range. You need to set the gain to 6144 to read +5V. And also use the same gain, i.e. 6144, in the voltage conversion.
|
Hi @tomjoro , I think I'm going to close this issue because:
|
Hello, thank you for the nice library! I am not sure if I'm correct about this so I thought I'd ask here...
TLDR, I think this line should be updated
ads1115/lib/ads1015.ex
Line 55 in 7181117
Possible Issue (or just me making a mistake)
I'm using an Rpi3 and a Pimoroni Automation Hat mini which uses the ADS1015 chip
The ADS1015 uses scaling,
This point about
ADS1015
scaling is also mentioned here,I have taken a 5 v wire and plugged it into one of the analog inputs oof the hat and then used this
ads11115
library to read the power as a test. For context:iex(77)> ADS1015.config(ref, address)
{:ok,
%ADS1015.Config{
comp_latch: false,
comp_mode: :traditional,
comp_polarity: :active_low,
comp_queue: :disabled,
data_rate: 1600,
gain: 2048,
mode: :single_shot,
mux: {:ain1, :gnd},
performing_conversion: false
}}
So, if I then undo the scaling I'd expect
~5 volts
(essentially taking the same formula from the previous link)So, short story long, I think the line below should ignore the first bit:
ads1115/lib/ads1015.ex
Line 55 in 7181117
and perhaps should be:
So then continuing with that I divide by 16 (shift)
ads1115/lib/ads1015.ex
Line 57 in 7181117
And now when I undo the scaling I get the expected
~5 volts
I also tested this update by connecting another Rpi's ground and 3.3 volt to the Pimoroni Hat, and with the changes I mentioned above it reads
3.297833333333333
as expected, without the changes mentioned it here it reads6.595666666666666
The text was updated successfully, but these errors were encountered: