To begin with, Our model car has a fixed breadth and length. As such the microcontroller is fed with two values which are used as the threshold enabling the car to park.
One of the values is slightly larger than the width of the car (W) and the other is approximately one and half times the length of the car (L).
Initially the car moves forward under the control of the H-Bridge and simultaneously searches for parking space. The moment it gets sufficient parking space, the control transfers to the Parking subroutine. Otherwise if sufficient parking space is not available the car keeps searching for parking space while moving forward.
Below the algorithm used for this whole process is provided—
Set thresholdDist = ***
Set lengthCount = ***
Set H-Bridge Control to move car forward
If ( getDistance() > thresholdDist ) Then
Set I = 0
While ( I < lengthCount ) Do
Delay ( 1 sec )
If ( getDistance() <= thresholdDist ) Then
GoTo Label 1
Set I = I + 1
getDistance Subroutine :
Select ADC chip by sending low voltage at CS pin
Give +ve edge trigger i.e. low to high transition at WR pin
Wait until INTR = 1
Give –ve edge trigger i.e. high to low transition at RD pin
Get 8 bit digital output from D7-D0
Return the digital output
startParking Subroutine :
Calculate y1, angle A, x1, Arc Length
Set H-Bridge Control to
move car forward until car reach position x1
stop car & turn front wheel towards the right
move car backward for the distance equal to the Arc Length ( 1st )
stop car & turn front wheel towards the left
move car backward for the distance equal to the Arc Length ( 2nd )
stop car & turn front wheel straight
move car forward until any obstacle is detected in front of the car.
Calculation of Turning Radius
tan (theta) = wheelbase/turning radius