ADC Testing
This commit is contained in:
@@ -53,7 +53,7 @@ void setup()
|
||||
IPAddress gateway(10, 11, 12, 1);
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
WiFi.softAPConfig(local_IP, gateway, subnet);
|
||||
WiFi.setTxPower(WIFI_POWER_13dBm); // reduce wifi power
|
||||
WiFi.setTxPower(WIFI_POWER_5dBm); // reduce wifi power
|
||||
if (WiFi.softAP(WIFI_SSID, WIFI_PASSWORD))
|
||||
{
|
||||
LOG_INFO("WiFi AP Mode Started");
|
||||
@@ -117,19 +117,42 @@ void loop()
|
||||
#endif
|
||||
// Init ADCs
|
||||
dev->m_adc_a = std::make_unique<ADS1256>(ADC_A_DRDY, ADS1256::PIN_UNUSED, ADS1256::PIN_UNUSED, ADC_A_CS, 2.5, &SPI_A);
|
||||
#ifdef CH_B_ENABLE
|
||||
#ifdef CH_B_ENABLE
|
||||
dev->m_adc_b = std::make_unique<ADS1256>(ADC_B_DRDY, ADS1256::PIN_UNUSED, ADS1256::PIN_UNUSED, ADC_B_CS, 2.5, &SPI_B);
|
||||
#endif
|
||||
#endif
|
||||
// Configure ADCs
|
||||
dev->m_adc_a->InitializeADC();
|
||||
dev->m_adc_a->setPGA(PGA_1);
|
||||
dev->m_adc_a->setDRATE(DRATE_7500SPS);
|
||||
#ifdef CH_B_ENABLE
|
||||
// dev->m_adc_a->setDRATE(DRATE_15000SPS);
|
||||
#ifdef CH_B_ENABLE
|
||||
dev->m_adc_b->InitializeADC();
|
||||
dev->m_adc_b->setPGA(PGA_1);
|
||||
dev->m_adc_b->setDRATE(DRATE_7500SPS);
|
||||
dev->m_adc_b->setDRATE(DRATE_30000SPS);
|
||||
#endif
|
||||
LOG_DEBUG("Init SPI OK");
|
||||
|
||||
uint8_t chs[8] = {
|
||||
SING_0, SING_1, SING_2, SING_3, SING_4, SING_5, SING_6, SING_7
|
||||
};
|
||||
float res[8];
|
||||
|
||||
while (Serial.read() != 's') // The conversion is stopped by a character received from the serial port
|
||||
{
|
||||
clearScreen();
|
||||
auto start = esp_timer_get_time();
|
||||
for (int i = 0; i < 8; i++){
|
||||
// dev->m_adc_a->setMUX(chs[i]);
|
||||
res[i] = dev->m_adc_a->convertToVoltage(dev->m_adc_a->cycleSingle());
|
||||
}
|
||||
auto stop = esp_timer_get_time();
|
||||
for (int j = 0; j < 8; j++){
|
||||
Serial.printf("ADC_A SING_%d: %5.4f\n",j, res[j]);
|
||||
}
|
||||
Serial.printf("ADC Time: %u us\n", stop-start);
|
||||
delay(100);
|
||||
|
||||
}
|
||||
dev->m_adc_a->stopConversion();
|
||||
|
||||
//////// INIT I2C INTERFACES ////////
|
||||
LOG_DEBUG("Init I2C Interfaces");
|
||||
|
||||
Reference in New Issue
Block a user