I have first added the sonar module (the previously mentioned SRF02). This implied making a small aluminium support to fixate the sonar to the servo, while still being able to slightly adjust the tilt:
After installing it, made a quick check and read the ranging data directly through the MuIn original Windows application:
Every thing was fine. It was time to add more code to the MuIn PIC, implenting useful functions for the robot. A singe command returning both range data and the servo position would be useful, so I implemented it. It essentially consists of the following structure:
'@' | 'F' | 'S' | I2C addr | servo nr | 0 | 0 | '#' |
Each element is 8 bytes long. The PIC responds with the following answer format:
'@' | 'F' | 'S' | I2C addr | servo nr | Range HB | Range LB | Servo HB | Servo LB | '#' | Checksum |
This allows a measurement to be taken, while the servo is sweeping.
A small video of the car in action:
No comments:
Post a Comment