- This topic has 2 replies, 2 voices, and was last updated 12 years, 8 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › Help needed in implementing obstacle detection logic
Hi Folks,
Am working on obstacle detector whose analog output is analog input to Atmega32 micro. I am taking five samples of my analog input to confirm the presence of obstacle. I have kept a cut off value based on the volatage output of the obstacle detector. It is not working consistently, am not getting where is the defect, so can anyone help me plz or suggest any other way of implemening?
Sample of code is lik dis, timer will be loaded with 100ms
#define obs_cut_off 0x10;
#define cut_off_high ;
#define cut_off_low ;
#define cut_off 5;
if (timer_obs.expired == true)
{
init_obs_timer();
timer_obs.enabled = true;
if(analoginput[0] > obs_cut_off )
{
cut_off_high ++;
cut_off_low –;
}
else
{
cut_off_high –;
cut_off_low ++;
}
if(cut_off-high>=cut_off)
{
obstacle_detected = true;
cut_off_high= 0;
cut_off_low=0;
}
else if (cut_off-low>=cut_off)
{
obstacle_detected = false;
cut_off_high= 0;
cut_off_low=0;
}
Looking forward for help.
Rgds,
DD
Fnds plz help me, I have not got any replies till now. If U find any loophole i n pgm plz reply:(. Waiting for replies
Folks,
can any one plz reply:(
Rgds,
Deeps
Try changing your second and third line of your code.
You should define some value before using the macro in your code
Example:
#define cut_off_high 0;
#define cut_off_low 0;