-
Notifications
You must be signed in to change notification settings - Fork 88
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
mixing analogReference(INTERNAL4V096); and analogReference(DEFAULT); with analogRead and analogDiffRead Not allowed? #27
Comments
Hi @macron0! Please try this: analogReference(INTERNAL4V096);
// your other measurements
analogReference(DEFAULT);
VCAL = 0x1A;
DACON = 0x03;
ADCSRD = 0x00;
ADMUX = 0x00;
output = analogDiffRead(A0, A1, GAIN_1); Also please do the same, but this time use these pins: output = analogDiffRead(A2, A1, GAIN_1); I'll need to check the datasheet to see exactly what these are doing, but if you try this and report back, we'll know where to look :) (reason: |
Hi dbuezas. Thank you very much for your reply and your suggestion. It turned out that adding this was enough to fix my problem:
Uncommenting the others did not change anything. But maybe I should use it anyway to be safe? Here are my results. Funny that the Single/analogRead returns lower values than the analogDiffRead. A7=is connected to the vcc of the board via a voltage divider (2x 10k resistors) Reading 2 volts on A1 (a0 and a2 are 0) ref=default Reading a7 (4.96v) ref=INTERNAL4V096 If I run it without the fix I get these results: You did solve my problem. Thank you again. One little thing. When trying the all_vs_all.ino example it sets serial speed to 230400. Very cool and fast but after this I could no longer upload schetches until I figured out that it worked if I pressed the reset button just after I clicked the upload button in arduino ide. Changing the speed down to 115200 fixed it. |
maybe fix nulllaborg/arduino_nulllab@78371c9#diff-730eea5c79180832efce2d49c3984db0483ccb3b41cf80941cb0cd616488aa6a |
Hi |
This has not yet been corrected. The problem is not with the BGEN bit, it's with the REFS2 bit. The REFS2 bit should be zero in all cases except for the 4.096V selection, I think. #27 (comment) |
Today I finished testing my modification on function About the reason of modification:
moved here
deleted from here
On the other hand in |
Has this fix been committed to a release? If so, please close this issue. |
Yes this fix been committed to the latest release. |
Hi. I am not sure this is an actual issue but I don't know where else to ask.
I tried :
analogReference(DEFAULT);output = analogDiffRead(A0, A1, GAIN_1) ; and this returned results around +- 2500. Well below the 4064 limit.
The thing is the current sensor I try to read (ACS758LCB-050b) is very sensitive to the voltage it gets supplied. When I power every thing via usb only the voltage on the board and also the ACS is 4.60 and it returns +-2330 when there is no current. When I power it from batteries it runs at's 5.06 volts and the ACS returns 2530 So I tried reading the LGT8F328P boards own voltage via A7 but this is always returns 4064 with the default reference. So I added a voltage divider (2 680k resisters) and I changed the analogReference to INTERNAL4V096. This works great. Now I can actually see the difference in my vcc when it is powered from usb or battery.
But now my results from the differential reads are 4064 instead of around 2500. I tried changing analogReference(DEFAULT); and delay(100) and than read and change it back to analogReference(INTERNAL4V096) but this has no effect.
Is what I try to do impossible?
I am trying to do an differential read because I read somewhere that this reduces noise becuase the noise cancels each other out. But this was the documentation if the ads1115 volt sensor. So I sort of asumed this would be true here too. I am using gain_1 so that means no amplification. Am I wrong and does the differential read not affect the noise?
Thank you for your work. This make those littleboards very cool and useable.
The text was updated successfully, but these errors were encountered: