Understanding the "Explorer" PCB
The Explorer PCB was designed specifically for the 2 motor / 2 encoder version of the Rover 5 chassis. The Explorer provides all the basic features required to turn your Rover 5 chassis into a working robot.
The first and second videos shows the Explorer mounted on a Rover 5 chassis using the Arduino Mega.
The third video shows the explorer on an RP5 chassis using an Arduino Nano mounted on a breadboard.
- Power supply with +5V @ 1A, +3.3V @ 500mA, Servo power @ 3A trickle charging circuit for NiMh batteries.
- Dual FET motor controller rated at 4A per motor with current monitoring circuitry.
- IR sensors on the corners to assist in object avoidance.
- Large prototype area for adding custom circuitry.
- Mounting holes for Arduino and Arduino Mega development boards.
- Mounts for 2x small breadboards allowing experimental circuits and other MCU's such as Picaxe or Propeller to be added.
- Mounting holes for a pan / tilt kit at the front of the robot.
- Both male and female headers for servos, sensors, encoders, motor control and power.
I have written an instruction manual that can be downloaded from my product support site here:
To help beginners who are still having trouble after reading the manual, I will try to explain in more detail here.
Mounting the board onto the Rover 5:
The PCB is designed to mount on the Rover 5 chassis using 4x self-tapping screws. The motors, encoders and battery pack all need to be connected to the bottom of the PCB before you mount it.
Pay attention to the polarity of the battery connection and power connections for the encoders. Red wires are +V, Black wires are ground. Ignore the colour of the motor wires as the polarity depends on the direction of the motor.
It does not matter if you swap the yellow and white wires of the encoders. This will only reverse the sense of direction and can be easily corrected either in the software or the wiring on the upper side of the board.
Once you have the wires connected and 6x AA NiMh batteries installed you can mount the PCB onto the chassis. Note the chassis has 4 mounting points, 1 in each corner.
Click on the image for higher resolution.
The Explorer is designed to work with 6x AA NiMh batteries (7.2V). This is the best option as NiMh batteries maintain a constant voltage over almost the entire discharge cycle. In comparison, a 7.4V (2S) LiPo or Li-Ion battery will have 8.4V when fully charged and steadily drop down to 6V as it discharges. Alkaline batteries should not be used as the initial voltage of 9V is too high for the motors and they will struggle to supply enough current causing your processor to shut down or reset unexpectedly.
It should be noted that some brands of NiMh battery can deliver higher currents than others. Although I have not tested every brand, the two brands I have found suitable are Sanyo (Eneloop) and Varta. These batteries were capable of delivering higher currents (5A or higher from a single AA cell where as some cheaper brands struggled to deliver 3A under the same test conditions.
To test the batteries, I took a single AA cell (1.2V) that had been freshly charged and shorted it for a few seconds with a multimeter set to 10A. Do not perform this test unless you know what you are doing and never do it with a Lithium Battery!
Some people prefer to use two battery packs, one for the motors and one for the processor. This is not recommended or necessary as the power supply circuitry will filter any electrical noise from the motors and servos.
If you use the 6x AA NiMh batteries as recommended then you can use the built in trickle charger to recharge the robot overnight. This saves having to remove the PCB in order to recharge the batteries.
Do not attempt to charge lithium batteries using the built in charger as Lithium batteries cannot be trickle charged and may catch fire or explode!
The Explorer has both 5V and 3.3V LDO regulators built in. LDO regulators (Low Drop Out) can work with lower input voltages than standard regulators which helps ensure a consistant output even if the battery voltage drops as low as 5.5V due to a stalled motor.
The 5V regulator can deliver up to 1A of current. The 3.3V regulator is rated for 500mA. As the 3.3V regulator gets it's power from the 5V regulator you must allow for this when calculating the total current throught the 5V regulator.
Servo power is supplied from the battery through 3x 3A diodes. Each diode reduces the battery voltage by about 0.6V. This brings your battery voltage down below 6V (assuming a battery voltage of 7.2V or 7.4V) to prevent damage to the servos.
V1 and V2:
All pins marked "Vcc" on the board are +5V. To use the other voltages you can connect them to V1 or V2. These power rails each have 4 pairs of male and female 3-pin headers making them ideal for connecting servos or sensors.
Note that the GND pins are closest to the edge of the PCB, the power rails are the middle pins and the inner most pins are for signal wires. The Signal wires for each pair of headers only connect to each other. This allows the servo control signals to be easily connected to your controller or the breadboards using a jumper wire.
Each power rail has it's own filter capacitors and can be connected to any voltage up to 15V. Each rail can be connected to servo power using a jumper on J18 for V1 or J9 for V2. Battery voltage, +5V, +3.3V or voltage from another battery can be connected to V1 using J22 or V2 using J21.
Please note that all grounds are connected through the PCB. This means that connecting another battery on J21 or J22 will automatically connect it's ground to the ground of the main battery.
Click on the image for higher resolution.
All electric motors will have a "nominal" or "rated" voltage and in most cases the manufacturer will specify a maximum voltage. Exceeding the maximum voltage can drastically reduce the life of the motor and in some cases the motor controller.
Electric motors also have a specification called "Stall current". This is the current drawn by the motor when it is prevented from turning while powered at the rated voltage.
The motor drivers on the exporer PCB are designed for the Rover 5 motors and can handle a maximum stall current of 4A. The Rover 5 motors have a nominal voltage of 6V, a maximum voltage rating of 7.5V and a stall current of 2.5A.
For each motor there are 2 control pins, DIR and PWM. There is also an analog output called CUR plus Vcc and ground connections. The Vcc and ground connections are simply +5V and ground which could be used in cases where each motor is controlled by a separate MCU or experimental circuit that needs power.
The direction control pin, DIR connects to a digital output of your controller. When your controller output is high, the motor will turn in one direction, when the output is low the motor will turn in the other direction. If the digital pin of your controller is in the high impedance state (open circuit or input) then the motor controller will treat this as a low input.
The speed control pin, PWM connects to a digital output of your controller that is capable of generating Pulse Width Modulated control signals. These signals control the amount of power supplied to the motors by controlling the percentage of time that the motor has power.
For example if your PWM output is at 60% then the motor will have power 60% of the time and no power for 40% of the time. This cycle of ON and OFF repeats very quickly (at least 100 times a second) so that the motor's momentum keeps it spinning during the time that the power is OFF.
The current sensing pin, CUR is an analog output. The voltage on this pin is proportional to the current drawn by the motor and is calibrated so that 1V is aproximately equal to 1A of current. This pin should be connected to an analog input of your controller. Your software can monitor this voltage to determine if the robot gets stuck.
The Rover 5 chassis can be supplied with or without encoders. This section assumes your chassis has encoders and they have been connected as previously shown. The encoders are terminated in headers next to the motor headers. Vcc and ground can be used to power external circuitry if required.
Output A is switches between high and low 1000 times for every 6 revolutions of the output shaft. Output B is Identical to output A except that it is 90° out of phase.
If you only want to know speed / distance then you can count the pulses from either output. Counting the pulses from both outputs will double your precision giving you 1000 pulses for 3 revolutions. As the outputs are 90° out of phase you can also tell the direction the wheel is turning by looking at which input rises first.
It is recommended that you connect the encoder outputs to external interrupt pins on your controller. This should ensure that all pulses are counted. If you configure your interrupt to be triggered on the rising edge of a pulse then the direction can be determined by simply looking to see if the other input is high or low.
If then encoder tells you you are going backward when you are actually going forward then you can simply swap the A and B outputs either by swapping the wires or changing the code.
IR corner sensors:
On each corner (numbered 1-4) of the PCB is a clear IR LED and a black photo-transistor. By turning on the LEDs and reading the reflected IR light with the photo-transistors we can detect nearby objects. Because our eyes cannot see the IR light, a small green LED is wired in parallel to the IR LED to indicate that the IR LED is ON.
Align the LED an photo-transistor so that they are roughly parallel to each other as shown in the photos but do not push them too close together otherwise the photo-transistor may detect the LED directly. Adjust their distance and angle so that each corner gives roughly the same readings.
On the left side of the PCB you will see 4 digital inputs for the LEDs. They are numbered 1-4. Connect these to your controllers digital outputs. These pins drive NPN transistors that supply the current needed for the LEDs. Each IR LED draws as much as 50mA so they should be turned off when not used to extend the life of your batteries.
On the right side of the PCB you will see 4 analog outputs also numbered 1-4. Connect these outputs to analog inputs of your controller. As an object gets closer and reflects more IR light, the voltage on these pins will increase.
As sunlight includes a lot of IR light these sensors will be blinded by direct sunlight and work best indoors or at night. To prevent false triggering from ambient IR light your code should work like this:
- Turn on IR LED and wait at least 50uS for the photo-transistor to respond to the change in IR light.
- Read the apropriate analog input and store the value. This value is the Ambient IR + LED IR light reflected from nearby objects.
- Turn off the IR LED and wait again while the photo-transistor adjust to the change in IR light.
- Read the same analog input again. This value is just Ambient IR light.
- Subtract the second value from the first. The result is equivalent to the LED IR light reflected by nearby objects only.
- Repeat these steps for each corner.
Wiring it up:
Below is a typical wiring diagram using an Arduino Mega. If you are using a processor with fewer I/O pins then you may need to leave out some features such as the encoders or replace the eye with a sensor such as an ultrasonic range finder.
In the example below, V1 is connected to servo power and V2 has been connected to 3.3V to power some optional 3.3V sensors. Although the Arduino Mega is a 5V controller it can still accept digital and analog inputs from 3.3V devices.
Click on the image for higher resolution.
I've attached sample code. When you open the folder you will find several files inside. Using Arduino 1.04 or later, open Rover5_Explorer_Mega.ino. This is the main program. All the other files will open into tabs at the top of the screen. I have put various functions into seperate tabs because it makes the program easier to read and edit.
The IO_pins.h tab is your wiring map. In this case it matches the wiring diagram above. If you want to change the wiring of your robot then you must change the pin definitions to match. The reason for defining the wiring like this is to make it easier to change. Changing the one value in this tab changes it throughout the entire program.
The Constants tab includes many values that can be changed to adjust the robot's behavior. For example, changing the value bestdistance will change the distance that the robot tries to mantain between itself and an object detected with the compound eye.
My sample code does not make use of the encoders however I have written an encoder ISR (Interrupt Service Routine) that increments the values lencoder and rencoder when the wheels travel forward and decrements the values when the wheels go backward. Swapping the wires for encoder inputs A and B will reverse the sense of direction if required.