Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What beats Timer 2 in this case?

Status
Not open for further replies.

qtommer

Member
i am doing a self-parking robot car and basically i have the coarse outline of my program all implemented. I am now focusing on scanning the car parking lot to determine whether or not the space is big enough to initiate movement into the lot

in the process of scanning whether the lot is big enough, the car is actually moving forward at the same time whilst polling the space of the lot using a distance sensor. Hence, ADC and PWM are being called up at alternative intervals till the end of the lot is detected.


1)Call PWM_FWD
2)Call ADC
3)Is end of lot reached? if yes proceed to next line, else go back to 1


However, the above routine just determines when the end of the lot is reached.
What I want to ensure is that a minimum length is scanned and once this length is met, the PIC will then be updated.

Doing some simple speed calculations, I have deduced that it takes 22 seconds (yes it's a slow car) for the car to reach the minimum required distance of 40cm for the car to park. Once 22 seconds are up, only then is the car allowed to proceed to park. If however, the end of the lot is detected before 22 seconds are up. the program will make the car stop.

To measure the time lapse of the 22 seconds, I intend to use the Timer2 interrupt as the timer will run in the background independently while im still executing my algorithm. However, I'm just checking here to see if there is a better way to implement this. Expert advice is appreciated;)
 
why not just give the car close range proximity sensors, or whiskers, as bumpers
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top