pero691
Newbie level 4
Hi,
Im use arduino mega to read adc 16 bit AD7401 https://www.analog.com/media/en/technical-documentation/data-sheets/AD7401.pdf
I use it for measure voltage drop on shunt resistor for measuring current.
In datasheet -200mV is 12288 and +200mV 53248. So 0V should be 20480 but values i read are strange.
here is exampe of values i get with 0V on input on adc:
Thanks.
Im use arduino mega to read adc 16 bit AD7401 https://www.analog.com/media/en/technical-documentation/data-sheets/AD7401.pdf
I use it for measure voltage drop on shunt resistor for measuring current.
In datasheet -200mV is 12288 and +200mV 53248. So 0V should be 20480 but values i read are strange.
Code:
#include <SPI.h>
byte highByte;
byte lowByte;
unsigned int i_out;
void setup() {
Serial.begin (115200);
SPI.begin();
SPI.setClockDivider(4);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
}
void loop() {
// read 16bit data ADC
highByte = SPI.transfer(0x0);
lowByte = SPI.transfer(0x0);
i_out = highByte << 8;
i_out = i_out | lowByte;
Serial.print("highByte: ");
Serial.print(highByte);
Serial.print(" lowByte: ");
Serial.print(lowByte);
Serial.print(" i_out: ");
Serial.println(i_out, DEC);
delay(250);
}
here is exampe of values i get with 0V on input on adc:
Code:
highByte: 69 lowByte: 229 i_out: 17893
highByte: 140 lowByte: 128 i_out: 35968
highByte: 50 lowByte: 217 i_out: 13017
highByte: 131 lowByte: 0 i_out: 33536
highByte: 44 lowByte: 179 i_out: 11443
highByte: 44 lowByte: 222 i_out: 11486
highByte: 102 lowByte: 183 i_out: 26295
highByte: 140 lowByte: 128 i_out: 35968
highByte: 67 lowByte: 44 i_out: 17196
highByte: 128 lowByte: 131 i_out: 32899
highByte: 50 lowByte: 217 i_out: 13017
highByte: 128 lowByte: 0 i_out: 32768
highByte: 128 lowByte: 0 i_out: 32768
highByte: 136 lowByte: 8 i_out: 34824
highByte: 128 lowByte: 1 i_out: 32769
highByte: 129 lowByte: 0 i_out: 33024
highByte: 128 lowByte: 130 i_out: 32898
highByte: 38 lowByte: 101 i_out: 9829
highByte: 129 lowByte: 8 i_out: 33032
highByte: 102 lowByte: 67 i_out: 26179
highByte: 44 lowByte: 214 i_out: 11478
highByte: 102 lowByte: 179 i_out: 26291
Thanks.