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.

sampling sensor analog signal with MSP430

Other Parts Discussed in Thread: MSP430G2553

Hello every, 

I'm quite new about MCU. Theoretically, I have learned how to deal with the interrupt of AD converter and timers. Recently, I 'm using MSP430 to acquire the data of moisture sensor. According to the datasheet of MSP430, I got the sampling rate is maximum 200ksps.

What I'm confused is,

1. Can people program to get all of the 200k analog data and convert them to digital data in 1 second? Necessary to get so many data in 1 second? 

2. Or should I just take several data, for example, 1000 in 1 second, and take the average to save or display? And how to realize?

3. How many general ways to sample and save data? Pulse? Time interrupt? AD interrupt?

I'm not sure if you get my point, but I will keep answering and asking. 

Thank you for all your help in advance.

  • Hello Qibin,

    You did not provide your MSP430 derivative so let's suppose you are using a MSP430G2553 device with 10-bit ADC. With a minimum 4 cycle sample-and-hold time, 13 cycle conversion time, and an extra sync cycle, it takes a total of at least 18 cycles to take a full sample. This requires an ADC clock source of ~3.6 MHz (it will need to be even greater to compensate for logic instructions) to achieve 200-ksps , the maximum as limited by the reference buffer drive capability. However you by no means need to store 200k samples per second when 1,000 will suffice for your application. The easiest way to do this reliable is with a timer sample-and-hold source select, determined by the SHSx bits of the ADC10CTL1 register. The rising edge of the selected source will start a sample, which once converted will set the ADC10IFG so that the ADC ISR can be used to read the contents of ADC10MEM. You must be sure that your ADC clock source is fast enough to completely sample and convert a channel, allowing time to read the results before the next timer rising edge requests the next sample to be recorded. TI has several examples provided in the device's software package for you to reference.

    Regards,
    Ryan
  • Hi Ryan,
    very appreciate your answer. What I want is to monitor the soil moisture with the sensor and put several data on the Internet with Raspberry, and I think it might change very slowly. That's why the "rising edge controlled sampling" confused me. Is that ok, if the MCU keeps monitoring the sensor, but just take 100 data every 1 or more second and calculate the average and send it to Raspberry, then put it in the internet.
    One more time, just make it clear:
    Initialize the Timer, ADC and so on. Make a timer isr, in the timer isr, the adc start a converter, and a flag logs the number of data, it can be 1000 or 100 or several but I take the average and send it to Raspberry or to say just save it.
    That is my thought, I hope it makes clear.
    Thank you for your time.
    best regards,
    Qibin
  • Hi Qibin,

    You don't have to use a timer ISR if you initialize the ADC SHSx to start a conversion automatically, and you then use the ADC ISR to read the conversion and log how many samples have been taken. You can halt the timer if you need the ADC to discontinue at any point during your firmware. But your application is very clear and can be easily realized with a MSP430 device.

    Regards,
    Ryan
  • Hi Ryan,
    I just reprogrammed. The function seems like that,
    the MSP4306137 has a Timer ISR(trigged very 0.6 second), in the ISR, the task is to calculate the average of 100 measured values(1min.) and send the average data to another device or save in somewhere.
    Any advice to make it better, or it would be great if my idea is good enough to realize my goal.
    Thank you as alway.

    regards,
    Qibin
  • This is fine, please continue to further develop your solution and post to the forum if the MSP430 device is not working as expected.

    Regards,
    Ryan

**Attention** This is a public forum