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![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
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