1

Тема: 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

http://forum.rcl-radio.ru/uploads/images/2020/05/2f3508896cc009d5fc87f12c30cb27c8.png

GAIN 1
П320 U = 1.000000V
http://forum.rcl-radio.ru/uploads/images/2020/05/0d1170447ab8608c1a1522a79a474728.png
П320 U = 0.500000V
http://forum.rcl-radio.ru/uploads/images/2020/05/e35c18dff7c5209f94dd05a530bda01e.png
GAIN 32
П320 U = 25.0000mV
http://forum.rcl-radio.ru/uploads/images/2020/05/34031c2169a7554a6c768ff58489cbfa.png


#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
 */

2

Re: AD7715

Измерение 2-х полярного напряжения

П320 U = -1.00000V

http://forum.rcl-radio.ru/uploads/images/2020/05/5d8aa2fade2a9e225a79a7fe11059e10.png


http://forum.rcl-radio.ru/uploads/images/2020/05/aa8c24bbbea9ceec2369d0d0ebe2c673.png

#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.2010 ;
 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,0b01100000);
  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((2*ref/65535*(code_sum-32767))*1.046,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
 */