#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);
}
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
Mid scale = 0V = (12288 + 53248) / 2 = 32768In datasheet -200mV is 12288 and +200mV 53248. So 0V should be 20480 but values i read are strange.
highByte: 203 lowByte: 44 i_out: 63232
highByte: 178 lowByte: 203 i_out: 32000
highByte: 44 lowByte: 178 i_out: 56832
highByte: 203 lowByte: 44 i_out: 63232
highByte: 178 lowByte: 203 i_out: 32000
highByte: 50 lowByte: 203 i_out: 64768
highByte: 44 lowByte: 178 i_out: 56832
highByte: 203 lowByte: 44 i_out: 63232
highByte: 179 lowByte: 44 i_out: 57088
highByte: 178 lowByte: 203 i_out: 32000
highByte: 44 lowByte: 203 i_out: 63232
highByte: 44 lowByte: 178 i_out: 56832
highByte: 204 lowByte: 178 i_out: 32256
highByte: 203 lowByte: 44 i_out: 63232
highByte: 203 lowByte: 44 i_out: 63232
highByte: 178 lowByte: 204 i_out: 32256
But: ((lowByte + highByte) * 256) is wrong
Do you think its possible to read AD7401 with arduino/mega2560 or its waste of time?
To reconstruct the original information, this output needs to be
digitally filtered and decimated. A Sinc3
filter is recommended
because this is one order higher than that of the AD7401 modu-
lator.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?