Society of Robots - Robot Forum

Software => Software => Topic started by: piravlos on November 01, 2010, 09:01:51 PM

Title: read and save data from sharp ir
Post by: piravlos on November 01, 2010, 09:01:51 PM
hello

i want to read and save the data from a sharp ir which is connected to the microcontroller. how can i do that?

thanks
Title: Re: read and save data from sharp ir
Post by: waltr on November 02, 2010, 07:20:35 AM
Connect the Sharp to an analog input pin. Write code to set-up the ADC for that pin, do an ADC conversion, read the ADC data and save it.

This is all we can tell you with out knowing more.
Which microcontroller?
Where do you want the data saved?

There are also many threads here that discuss using the Sharp sensors. A search will bring up lots of info and even code examples.
Title: Re: read and save data from sharp ir
Post by: piravlos on November 02, 2010, 08:59:25 AM
hello thanks for the reply.

i want to save the data in an array.

my problem is that i do not know how to start. how do i set up the ADC and do the conversion?

thanks
Title: Re: read and save data from sharp ir
Post by: waltr on November 02, 2010, 09:30:56 AM
Learn the C programming language, putting data into arrays is common.
Title: Re: read and save data from sharp ir
Post by: piravlos on November 03, 2010, 08:35:04 AM
void SetChanADC(){ OpenADC(ADC_FOSC_RC & ADC_RIGHT_JUST & ADC_0_TAD,
      ADC_CH7&  ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS, 15 );
}

void configure_ADC() {
      OpenADC(ADC_FOSC_RC & ADC_RIGHT_JUST & ADC_0_TAD,
      ADC_CH7&  ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS, 15);
}
 is something wrong here?

thanks