Hola a todos , alguien a utilizado el ADC 24 bits LTC 2400 , Encontre un codigo de ejemplo
https://www.picuino.com/foro/index.php?PHPSESSID=0g8nv6g0u1rprq6enf2l7quj7o&topic=9.msg12#msg12
donde lo usan como voltimetro en conunto del arduino nano , funciona bien , pero quiciera saber como se podra aumentar la velocidad de muestreo , ya que al cambiarla menor a 180 ms , el codigo no lee valores , alguien me podria ayudar ??
`long count;
static float volt1, volt2;
// ADC Pin definition
const int ADC_SCK = 2; // Serial ClocK
const int ADC_SDO = 3; // Serial Digital Output
const int ADC_CS = 4; // Chip Select
const int sampling_time = 180; // Sampling time in milliseconds
/*
Init LTC2400 signals
*/
void adc_init(void) {
pinMode(ADC_SCK, OUTPUT);
digitalWrite(ADC_SCK, HIGH);
pinMode(ADC_CS, OUTPUT);
digitalWrite(ADC_CS, LOW);
pinMode(ADC_SDO, INPUT);
}
/*
Read 32 raw data bits from LTC2400
*/
unsigned long adc_read32(void) {
unsigned long int count;
digitalWrite(ADC_CS, LOW); // ADC Chip Select
count = 0;
// Read 32 bits from serial ADC
for (char i = 32; i; i--) {
count <<= 1;
digitalWrite(ADC_SCK, LOW); // Send Clock Signal
digitalWrite(ADC_SCK, HIGH);
if (digitalRead(ADC_SDO)) {
count |= 1;
}
}
digitalWrite(ADC_SCK, LOW); // Init next conversion
return count;
}
/*
Read voltage from LTC2400
Return 0x80000000 if not conversion available
Return values from negative 0xFF... to positive 0x1F...
*/
long int adc_read(void) {
signed long count;
char stat;
count = adc_read32();
// Get status
stat = count >> 28;
count &= 0x0FFFFFFF;
// Test end of conversion
if (stat & 8) {
return 0x80000000;
}
// Positive Extended Range
if (stat == 3)
count += 0x0FFFFFFF;
// Negative Extended Range
if (stat == 1)
count += 0xF0000000;
return count;
}
/*
Return 1 if ADC End Of Conversion bit is Enable
*/
int adc_eoc(void) {
digitalWrite(ADC_CS, LOW);
return (!digitalRead(ADC_SDO));
}
/******************************************************
MAIN PROGRAM
*****************************************************/
// Init program
unsigned long sample_time;
void setup() {
// Initialize serial communications
Serial.begin(115200);
// Initialize ADC
adc_init();
sample_time = millis() + 100;
}
// Main Loop
void loop() {
long count;
static float volt1, volt2;
// Wait for next adquisition
if (millis() > sample_time) {
sample_time += sampling_time;
// Read ADC
count = adc_read();
//delay(10);
// Convert ADC to voltage
volt1 = volt2;
volt2 = ((float)count) * (5.000000 / (256.0 * 1024.0 * 1024.0));
count = ((volt2 - volt1) * 1000000.0);
// Print voltage to serial port
if (volt2 >= 0) Serial.print(" ");
Serial.print(volt2, 6);
Serial.print("\t");
if (count >= 0) Serial.print(" ");
Serial.println(count);
char sign;
if (count < 0) {
count = -count;
sign = -1;
} else {
sign = 1;
}
}
}