Using the ADS1256, at a data rate of 500 SPS, and gain of 1, and MSP430
I would like to know more about the proper use of the input multiplexer to obtain data from different/distinct analog sources.
Right now, I have it configured to read data from mux: 05, 15, 25 (using channels 0, 1, and 2, and comparing to channel 5).
Page 21 of SBAS288J -- June 2003 -- Revised August 2008 document describes in part, but I would like to know how long after each command (WREG for mux, SYNC, WAKEUP, RDATA) I should wait before I read the data from DOUT.
Should I issue a calibration between every mux change??, I could not find this mentioned on page 21, but I have read that calibrations should be issued after every MUX change
Also if it is even possible to accurately, almost simultaneously (within the cycling throughput) get distinct data from different channels.
I have included my pseudo code below
Is this basically the right way to go about it? or is there a more efficient/better method? I am not sure if I am giving enough time for the data to settle between MUX changes.
Thank you
Gui
my pseudo code so far is:
main:
set ADS1256sampling rate
set gain exponent
do a gain_offset_calibration
set initial gi_current_mux (the positive and negative inputs to the A/D
then start my loop:
// synchronize to /DRDY
ADS1256_WaitForDataReady(NO_TIMEOUT);
// assert Chip Select to start transfer
ADS1256_AssertCS(TRUE);
// send the read data command byte
ADS1256_SendByte(ADS1256_CMD_RDATA);
//enable the interrupt on the data ready pin
Config_DRDY_Interrupt ();
in my interrupt:
reset interrupt port
ADS1256_QuickWriteMUXRegister(gi_currentMux); //write to MUX register with the value of gi_currentMux (set before loop start, and then goes to next one at end)
ADS1256_Delay_TOSC(24); //wait 24 cycles WAIT_1_US() {asm("nop");} //at 1MHz DCO , 1 cycle per NOP, each
////possibly put a calibration
ADS1256_SYNC_and_Wakeup();
ADS1256_SendByte(ADS1256_CMD_RDATA);
//then I receive each byte and put in a buffer
//gac_sd_AD_buffer size = 512 bytes
gac_sd_AD_buffer[gi_sd_AD_buffer_pointer_in]=ADS1256_ReceiveByte();
gi_sd_AD_buffer_pointer_in++;
gac_sd_AD_buffer[gi_sd_AD_buffer_pointer_in]=ADS1256_ReceiveByte();
gi_sd_AD_buffer_pointer_in++;
gac_sd_AD_buffer[gi_sd_AD_buffer_pointer_in]=ADS1256_ReceiveByte();
gi_sd_AD_buffer_pointer_in++;
//then I state machine the value of gi_currentMux to the next mux
back to main:
In parallel, when not in the interrupt, I empty the gac_sd_AD_buffer into another buffer (also 512 bytes)
when that second buffer is full, i write all 512 bytes to an SD card
I loop until I have filled an N amount of sectors in the SD card
then
//disable the interrupt on the data ready pin
Deconfig_DRDY_Interrupt ();
//now that interrupts on DRDY are disabled, we can poll the pin
// synchronize to /DRDY
ADS1256_WaitForDataReady(NO_TIMEOUT);
// de-assert Chip Select
ADS1256_AssertCS(FALSE);