Тема: AD7715
Рабочий скетч, протестировано!!!
AD7715-3 === VDD = 3V, UREF = 1.25V
AD7715-5 === VDD = 5V, UREF = 2.5V
На вход IN подавать напряжение только положительной полярности не превышающее Uref.
Данный контент доступен только зарегистрированным пользователям.
Charge-balancing ADC
16-bits no missing codes
0.0015% nonlinearity
Programmable gain front end
Gains of 1, 2, 32 and 128
Differential input capability
Three-wire serial interface
SPI-, QSPI™-, MICROWIRE™-, and DSP-compatible
Ability to buffer the analog input
3 V (AD7715-3) or 5 V (AD7715-5) operation
Low supply current: 450 µA maximum @ 3 V supplies
Low-pass filter with programmable output update
16-lead SOIC/PDIP/TSSOP
GAIN 1
П320 U = 1.000000V
П320 U = 0.500000V
GAIN 32
П320 U = 25.0000mV
#include <SPI.h>
#define SS 10 // CS
#define MOSI 11 // DIN
#define MISO 12 // DOUT
#define SCK 13 // SCLK
#define DRDY 8 // DRDY
#define RESET 7 // Reset
const float ref = 1.2103 ;
long code,code_sum;
int i;
void setup(){
pinMode(DRDY, INPUT);
pinMode(RESET, OUTPUT);
digitalWrite(RESET,LOW);
SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV2, MSBFIRST, SPI_MODE3));
Serial.begin(9600);
SPI.begin();
digitalWrite(RESET,HIGH);delay(300);
}
void loop(){
digitalWrite(RESET,HIGH);
delay(20);
WriteAD7715(0b0010000,0b01100100);
delay(20);
ReadAD7715();
digitalWrite(RESET,LOW);
}
void WriteAD7715(int data0, int data1){
digitalWrite(SS, LOW);
delayMicroseconds(1);
SPI.transfer(data0);
SPI.transfer(data1);
digitalWrite(SS, HIGH);
}
void ReadAD7715(){
while(digitalRead(DRDY)!=LOW);
digitalWrite(SS, LOW);
delayMicroseconds(1);
SPI.transfer(0x38);
code = SPI.transfer16(0);
digitalWrite(SS, HIGH);
code_sum=code_sum+code;i++;
if(i==10){ code_sum=code_sum/10;
Serial.print(code_sum);
Serial.print(" ");Serial.print(ref/65535*code_sum,4);Serial.println(" V");
i=0;code_sum=0;}
while(digitalRead(DRDY)!=HIGH);
}
/* Communications register
0b00010000 gain 1
0b00010001 gain 2
0b00010010 gain 32
0b00010011 gain 128
Setup register
0b01100100 unipolar 50Hz 2.4576 MHz
0b01100000 bipolar 50Hz 2.4576 MHz
*/