I am using this ADC first time & finding difficult to get desired result.
I wish to use it in basic sequencer mode, 4 differential channel pairs i.e. IN0/IN1 to IN6/IN7, +-20.48V. I am configuring the Configuration Register by the value 0 x F7FF.
D0 is CS, D1 is SCLK & D2 is ADC Data
the code for initialize is :
digitalWrite(CS_ADC , LOW);
digitalWrite(CNV_ADC ,HIGH);
digitalWrite(CNV_ADC ,LOW);
x = SPI.transfer(0xF7);;
y = SPI.transfer(0xFF);;
digitalWrite(CS_ADC , HIGH);
digitalWrite(CS_ADC , LOW);
x = SPI.transfer(0);
y = SPI.transfer(0);
digitalWrite(CS_ADC , HIGH);
digitalWrite(CS_ADC , LOW);
x = SPI.transfer(0);
y = SPI.transfer(0);
digitalWrite(CS_ADC , HIGH);
digitalWrite(CS_ADC , LOW);
x = SPI.transfer(0);
y = SPI.transfer(0);
x = SPI.transfer(0);
y = SPI.transfer(0);
x = SPI.transfer(0);
y = SPI.transfer(0);
x = SPI.transfer(0);
y = SPI.transfer(0);
x = SPI.transfer(0);
y = SPI.transfer(0);
digitalWrite(CS_ADC , HIGH);
I didn't find any example/timing diagram for this mode. however after a bit trial & error I am seeing this value got configured as shown in attached screenshot of initializing ADC.But during periodic data read I do not wish to change the configuration & read only data of 4 channels. So for that reading I am sending only 0x0000 over SPI & seeing the configuration getting changed to 0 x 77FF instead of 0 x F7FF.
D0 is CS, D1 is SCLK & D2 is ADC Data
The code for reading sequentially is :
digitalWrite(CS_ADC,LOW);
digitalWrite(CNV_ADC ,HIGH);
digitalWrite(CNV_ADC ,LOW);
dummy = SPI.transfer(0);
dummy = SPI.transfer(0);
digitalWrite(CS_ADC,HIGH);
digitalWrite(CS_ADC,LOW);
dummy = SPI.transfer(0);
dummy = SPI.transfer(0);
digitalWrite(CS_ADC,HIGH);
digitalWrite(CS_ADC,LOW);
dummy = SPI.transfer(0);
dummy = SPI.transfer(0);
digitalWrite(CS_ADC,HIGH);
digitalWrite(CS_ADC,LOW);
msb[0] = SPI.transfer(0);
lsb[0] = SPI.transfer(0);
msb[1] = SPI.transfer(0);
lsb[1] = SPI.transfer(0);
msb[2] = SPI.transfer(0);
lsb[2] = SPI.transfer(0);
msb[3] = SPI.transfer(0);
lsb[3] = SPI.transfer(0);
dummy = SPI.transfer(0);
dummy = SPI.transfer(0);
digitalWrite(CS_ADC,HIGH);
The problem I am facing is incorrect values, wrong PGA etc. Full count i.e. 7FFF is shown at 7V, & at 3V the count is around 0C22. Since the host is slower reading is at low conversion speeds. If anybody can help let me know.
ADC Count mentioned.
[edited by: NBhange674 at 7:16 AM (GMT 0) on 23 Apr 2019]