It's been named "The Meerkat". When you see it in action, it's not hard to see how the kids named it.
This is a 4-wheel machine which uses sonar to detect and avoid obstacles. To make life a little more interesting, the ultrasonic modules is steered using a small servo motor. This allows the machine to more effectively find a clear path.
The best place to start is with the chassis. There's a couple of useful things to consider when putting this together.
Motors and Wheels
If your motor have wires attached, it's almost certain that they will not be long enough to reach your driver board and you will need to extend them. My motor driver went on the top deck at the rear, as there were two holes located there already to take it. Solder and heat-shrink the connections.
Bolt your motors into place according to your platform. In same cases you can choose to put the motors above or below the bottom plate. I chose to put mine below because it frees up room for the battery pack(s), but it does make the finished product rather tall.
With a 3V battery, test each motor and determine the polarity which causes the motor to turn in a "forwards" direction. Label the leads as + and - according to the battery. This will make it easier when it comes to hooking up later.
Take some time now to properly align your wheels. Place a straight-edge (such as a metal rule) across the wheels on each side to and align them before finally tightening up the mounting screws. This might take a little time, but eliminating wheel drag improves battery life for free.
Mounting the modules
We have to mount the motor driver and Arduino Mega on the top deck. As noted before, the motor driver I used matched holes in the rear part of the top deck, so I put it there. The Arduino Mega needed new mounting holes, so work out and drill everything you need before you start assembling. While you're there drill a hole for the power switch and battery charging terminals if you're using them.
Mounting the ultrasonics and servo
This requires a little thought. Since only a tiny servo is required it doesn't take up much space, but at the same time this makes it tricky to mount since most commercial spacers won't clear the body of the servo. Because it's got so little mass on it I used industrial double-sided tape (the kind for sticking badges to cars) under the servo. Place it in the centre and running down the long axis of the chassis. (See photos)
Attaching the servo to the ultrasonic module requires a bracket of some kind. I made my own from acrylic. Turned out a bit on the large side but it works well. If you can find a long enough screw of the appropriate size just screw the bracket to the horn wheel on the servo.
Mounting the batteries Make a design decision here. If you are using rechargeable batteries, you will need to add a connector for the charger (I used banana posts as per the photos), and the DPDT switch should isolate the electronics from the battery when charging for added protection. However if you are using non-rechargeable batteries, make sure you have a way of getting at the battery holder(s) to change batteries without having to disassemble the whole machine. It might not look elegant, but a long cable (zip) tie is ideal for the job. At this point, you should have everything mounted, but not wired. It looks pretty good for now, so let's move on to the wiring.
WiringThe source code is the definitive guide to wiring the robot, and it will override any instructions here. All the information you require is in the file "rover_hw.h"
Motors
The motors are arranged as follows (looking from the top) Back Right: Motor A Back Left: Motor B Front Right: Motor C Front Left: Motor D Some L298 driver boards jumper out the "Enable" pin for each motor channel. Refer to the documentation for your board and check if there is a jumper which needs to be removed. The "A" and "B" (or "1" and "2") inputs on the motor driver control the direction.
The "A" and "B" (or "1" and "2") inputs on the motor driver control the direction.
Connections for the motor driver are as follows:
Motor A (1)
A => 22
B => 24
Enable => 2
Motor B (2)
A => 26
B => 28
Enable => 3
Motor C (3)
A => 30
B => 31
Enable => 4
Motor D (4)
A => 32
B => 33
Enable => 5
The motor driver board outputs are normally labelled "+" and "-". Connect the positive and negative leads from the motors to the outputs.
If you compile the code with "BURN_IN" defined, the software will cycle through each motor in turn. This is useful for checkout out the motor and servo wiring.
Servo
The motor driver I used also has a servo driver on-board so I used this to remove the load from the Arduino. However, the servo is small enough that it can be driven directly if required.
The servo needs +5V, Ground and Signal.
The Signal comes from Output 6 on the Arduino. If your driver board supports servo motors, connect Output 6 to the control or signal input on the driver and connect the servo to the driver board instead.
Ultrasonics
The HC-SR04 needs +5V and Ground, as well as a Trigger. The detection result is returned via the Echo pin on the module.
Trigger is connected to pin 7, and Echo to pin 34.
Congratulations. Your robot is now fully assembled. If you wish, use some cable ties to make everything neat and secure.
Like the rest of this project, the software is rather simple but you can still do a lot with it. First of all, grab the latest release from:
https://bitbucket.org/emergenttechnology/4wd-robot/overview
Load up the Arduino IDE and open up "features.h".
For now make sure that the line:
#define OLED
has been commented out. We will come back to that one later.
If you want to test out your motor wiring, add the line:
#define BURN_IN
to "features.h" But in either case, make sure the robot's wheels are clear of the ground before uploading the code.
Once you have confirmed that all the motors turn in the correct direction, removed the BURN_IN from the code and upload again.
Next StepsI don't think any hobby robot is ever really "finished", and Meerkat certainly is proof of this. I have a lot of further plans for this little platform:
- Wireless data transmission so we can tell what it's doing from afar.
- Navigation
- Battery Management
- Additional sensors for "experiments"
Some of this code (The power monitoring) is done already, and is on the "develop" branch on bitbucket.org. If you're feeling adventurous you can pull this branch down and see what we're up to.
Comments