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.

Problems interfacing maxbotix sonar with ADC10 on MSP430G2231

Other Parts Discussed in Thread: MSP430G2231

Hi

I am having trouble reading analog values returned from the Ultrasonic Maxbotix  LV-MaxSonar-EZ3 sensor on to ADC10 of my MSP430G2231 .

Basically when I  use a voltimeter to read the sensor analog output without connect it to msp430 I have consistent results. The sensor scalling factor is VCC/512 thus, for my supply voltage (3.6v), we have ~7mv / inch. For example a value of 0.08v gives me a 11.42inches distance (~29cm).

For the same previous distance, when I plug in the analog pin on to INCH_3 of msp430 I'm getting the value of 186 from ADC10MEM, that converting to volts is equivalent to 0.65V (Volts = Nadc * VCC / 1023) . In fact I'm reading this value on voltimeter. 

The strange thing is that increasing the distance the value remains basically the same. In the end I have only two readings 186  for short and  261 for  long distances.

I am a newbie and don´t know what I'm doing wrong, I've tried to configure the ADC with all possible reference values whitout sucess.

I appreciate if someone can help me....

 

Here´s my code

//------------------------------------------------------------------------------------------------

#include <msp430g2231.h>

 

void ConfigureAdc(void);

void SampleDistance(void);

void main(void)

{

    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

    ConfigureAdc();

  for (;;)

  {

     SampleDistance();

  } 

}

 

void ConfigureAdc(void)

{

    ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE;   

    ADC10CTL1 = INCH_3 + SHS_0 + ADC10SSEL_0;  

    ADC10AE0 |= 0x08 ;                        

}

 

void SampleDistance(void)

{

    ADC10CTL0 |= ENC + ADC10SC;        

    __bis_SR_register(CPUOFF + GIE);   

    adc = ADC10MEM;

}

// ADC10 interrupt service routine

#pragma vector=ADC10_VECTOR

__interrupt void ADC10_ISR (void)

{

  __bic_SR_register_on_exit(CPUOFF);       

}

 

**Attention** This is a public forum