This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP430G2: Record data from ADC 16bit (Adafruit) with MSP-EXP430G2ET LaunchPad

Part Number: MSP-EXP430G2

Hi everyone !

I hope you can help me: I'm using MSP-EXP430G2ET LaunchPad to read data from an ADS1115 16-Bit ADC. Thanks to libraries for this component, I have set a sampling frequency of 860SPS (the max possible) and I can plot my data on Energia serial plotter. 

But when I send data from serial to Python or Matlab, I get only 50 samples por second. I tried to send by serial  an int (X) wich increased whenever a data acquired by the ADC was sent; in this way, in Python (on PC), I saw that the int X was ordered (so I wasn't losing samples) and I received only 350 samples in around 7 seconds. 

Tomorrow I'm going to try to acquire data for 5 seconds and store them in an array of 4300 elements (cause the ADC sampling freq is 860SPS x 5 seconds = 4300 samples), to be sure that ADC is sampling correctly.

Could my MCU be the problem ? Maybe the serial write velocity is not enough ? If this should be the problem, i could solve storing data in array and them in a SD.

Thank for your attention !

Best Regards,

Giuseppe Missale

  • What's the speed of your serial link? Also, what format are you using (raw binary vs ASCII)?

    At e.g. 9600bps, you will barely get 860 8-bit binary samples per second. But you can run the UART much faster than that.

  • Thanks for your reply !

    I'm using Serial.wirte func to send an int (that is the value from ADC) and the baudrate is set to 115200..

  • I don't have your setup, so I'm guessing here.

    My first thought was that the host is just slow, but that would result in lost samples, since the MCU doesn't know that.

    The difference in this case would seem to be write(), where (I suppose?) you were using print() for the graphing example. The Energia reference says that write() sends a byte for an int, which isn't what you want anyway.

    Here's a suggestion which is perhaps non-obvious, but it's a quick experiment: Try using print() instead. At 115200 you can afford 115200/10/860=14 bytes per sample, and a 16-bit sample can be sent in (5+1) bytes (digits+newline). 

    If your code isn't too big, it might be useful to post it -- maybe someone here will spot something.

  • Here's my code; is really really simple.

    #include <Adafruit_ADS1015.h>

    #include <Wire.h>

    Adafruit_ADS1115 ads(0x48);  

    void setup(void)

    {

     Wire.setClock(400000);

     Serial.begin(115200);

     ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V      

                                                                  // resolution of  0.03125mV

     ads.begin();  

     }

    int adc0, adc1, adc2, adc3,z=0;      

    void loop(void)

    {

    adc0 = ads.readADC_SingleEnded(0);

     //Serial.print(z++);

     Serial.println(adc0);

     }

    I also tried: Without the serial prinln, using a while loop (where I read the value from ADC) with millis() to take time and increasing a variable (X) for each loop, at the end of while I obtain X = 75 for 1second of loop. So the Reading from ADC is too slow.

  • (Oh, OK -- I wasn't looking at the ADC side since your first post said you were achieving 860sps.)

    I don't see anything here that sets DR in the Config register for 860sps. If that isn't done, you'll get 128sps [Ref data sheet (SBAS444D) Table 8]. Maybe there's a method defined for setting a register and/or DR specifically?

    Also the Config register MODE is defaulted for single-shot(=1), where your code seems to expect continuous (=0) [Also Table 8]. I suspect there's some (time) cost to starting up the ADC for each sample. Similarly, there may be a method for doing this.

**Attention** This is a public forum