Open Spud-maker opened 4 years ago
Not sure which ADC you are referring to, but just glanced at the MCP3008 data sheet, and it says that lsb size is VRef / 1024, not 1023.
So I think I'm right, but maybe it is different for the other ADCs.
Jayben
On 26/07/2020 21:42, Spud-maker wrote:
Not sure your math for converting the samples to Volts is correct. You seem to be using 4096 as divisor for 10 bit AD. Believe one needs to use 4095 or 2^nbits -1.
Thanks for DMA example!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jbentham/rpi/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNUSEQTP24VBLYKSG52GY3R5SIJ5ANCNFSM4PIE2QCA.
Jayben,There seems to be a lot of confusion about this in the industry. I have seen both ways listed 2^n and 2^n-1 in various places. The actual difference between the two is a pretty small "gain" offset and may not be important in the end. I don't believe the 2^n argument because it depends on hand waving about clipped values at +/- full scale values. It still misses the key point which is that you have 4096 values but 4095 steps. A LSB voltage step * Full scale output of all bits high just doesn't work if you divide by more steps than you have for a single ended ADC. Thanks for responding. I have searched around the web and find both answers. I just can't live with math that tells me with a 3.3V ref, and 3.3V input I've got a reading of 3.299194336V yet with 0V input tells me 0, but that's still a pretty small "gain" offset error. Alan On Sunday, July 26, 2020, 02:43:00 PM PDT, jbentham notifications@github.com wrote:
Not sure which ADC you are referring to, but just glanced at the MCP3008 data sheet, and it says that lsb size is VRef / 1024, not 1023.
So I think I'm right, but maybe it is different for the other ADCs.
Jayben
On 26/07/2020 21:42, Spud-maker wrote:
Not sure your math for converting the samples to Volts is correct. You seem to be using 4096 as divisor for 10 bit AD. Believe one needs to use 4095 or 2^nbits -1.
Thanks for DMA example!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jbentham/rpi/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNUSEQTP24VBLYKSG52GY3R5SIJ5ANCNFSM4PIE2QCA.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Jayben,I have now noticed that in main(), in the single sample If() statement, the return value is a in statement formula instead of the "#define ADC_VOLTAGE(n) ((( int n) 3.3) / 1024.0)" defined by ADC define statements. i.e. "printf("ADC value %u = %4.3fV\n", val, val3.3/1024.0)"; vs printf("%4.3f\n", ADC_VOLTAGE(sample_buff[i]))" in multi-sample. Hope that helps someone else. Took me a bit to understand why a single sample seemed to have different result for math... until I looked at code closely. I am updating your code package to work with a MCP2308 attached to a RPi B. I need multiple ADC reads at a precise time sampling rate. Not really willing to use another external uC to do this but that is my backup plan if needed. Progress:Single DMA read now works fine. Multiple reads still having some issue. Suspect some minor location or Pin value offsets between Pi Zero and my 2012 purchased Pi B (which I believe you would call a Pi 1). Thanks again for posting all this. Truly helpful! Alan On Sunday, July 26, 2020, 02:43:00 PM PDT, jbentham notifications@github.com wrote:
Not sure which ADC you are referring to, but just glanced at the MCP3008 data sheet, and it says that lsb size is VRef / 1024, not 1023.
So I think I'm right, but maybe it is different for the other ADCs.
Jayben
On 26/07/2020 21:42, Spud-maker wrote:
Not sure your math for converting the samples to Volts is correct. You seem to be using 4096 as divisor for 10 bit AD. Believe one needs to use 4095 or 2^nbits -1.
Thanks for DMA example!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jbentham/rpi/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNUSEQTP24VBLYKSG52GY3R5SIJ5ANCNFSM4PIE2QCA.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Not sure your math for converting the samples to Volts is correct. You seem to be using 4096 as divisor for 10 bit AD. Believe one needs to use 4095 or 2^nbits -1.
Thanks for DMA example!