[Digi-Key Follow me Issue 2] + Off-mission Sensor ADS7950
[Copy link]
In total I bought two extra chips, so I made two boards.
The actual device is as above. Currently there is no good driver for Arduino, so I wrote a simple one via SPI.
as follows:
#include<SPI.h>
#defineVSPI_MISO MISO
#defineVSPI_MOSI MOSI
#defineVSPI_SCLK SCK
#defineVSPI_SS SS
#ifCONFIG_IDF_TARGET_ESP32S2|| CONFIG_IDF_TARGET_ESP32S3
#defineVSPIFSPI
#endif
staticconstintspiClk = 1000000;// 1 MHz
//uninitalised pointers to SPI objects
SPIClass * vspi = NULL;
uint16_tManual_Mode = 1840;
voidsetup(){
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(F("Hello! Feather AD7950 Test"));
vspi = new SPIClass(VSPI);
vspi->begin();
pinMode(9, OUTPUT);//VSPI SS
}
voidloop(){
// put your main code here, to run repeatedly:
uint16_tadc_data;
uint8_tadc_channel;
floatadc_Data;
spi_data_16(vspi, Manual_Mode);
spi_data_16(vspi, Manual_Mode);
adc_data = spi_data_16(vspi, Manual_Mode);
Serial.println(adc_data);
Serial.print("adc_channel:");
adc_channel = adc_data >> 12;
Serial.println(adc_channel);
Serial.print("adc_data:");
adc_Data = ((adc_data&0x0fff)/4095.0)*2.5;
Serial.println(adc_Data);
delay(1000);
}
uint8_tspi_data(SPIClass *spi, uint8_tdata)
{
uint8_treceive_data;
spi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE1));
receive_data = spi->transfer(data);
spi->endTransaction();
returnreceive_data;
}
uint16_tspi_data_16(SPIClass *spi, uint16_tdata)
{
uint16_treceive_data;
spi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE1));
digitalWrite(9, LOW);//pull SS slow to prep other end for transfer
receive_data = spi->transfer16(data);
digitalWrite(9, HIGH);//pull ss high to signify end of data transfer
spi->endTransaction();
returnreceive_data;
}
This chip has three modes, so I configured one. Also, its input and acquisition have a two-fold relationship, but I didn't see where to configure it in the manual.
The test results are as follows:
Problems will occur if the input exceeds the range. Within 0-1.25V, the input is twice as much, which is quite stable.
|