Let's Make Robots!

Understanding the "Explorer" PCB

Provides Rover 5 chassis with motor drivers, power supply and IR sensors
AttachmentSize
Rover5_Explorer_Mega.zip7.9 KB

Introduction:
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.

 

 

 

 

 

 

 

Features:

  • 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:
https://docs.google.com/file/d/0B__O096vyVYqOWUzZGM5MGUtNTgyNC00NmU1LWFjYWUtZWZlNjVlYmIzM2E3/edit

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.

 


 

Batteries:
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!

 


 

Power:
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.

 


 

Motor drivers:

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.

 


 

Encoders:

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:

  1. Turn on IR LED and wait at least 50uS for the photo-transistor to respond to the change in IR light.
  2. Read the apropriate analog input and store the value. This value is the Ambient IR + LED IR light reflected from nearby objects.
  3. Turn off the IR LED and wait again while the photo-transistor adjust to the change in IR light.
  4. Read the same analog input again. This value is just Ambient IR light.
  5. Subtract the second value from the first. The result is equivalent to the LED IR light reflected by nearby objects only.
  6. 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.

 


 

Sample Code:

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.

 

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hello.

I have a question about the mA draw of the Explorer PCB - how much Power does all the Stuff on it need?

 Is there a way to disable something to save power?

And does anyone have example Code for Pathfinding or even creating a grid Map? ;)

 

Is there a Shop where to get another 2 Motors+Encoders as Addon? Because i ordered only a 2 RW Version but my Robot seems to be too heavy for only 2 Motors :(

 

Thanx and btw very nice Work! :-)

Regards

Unless your robot weighs quite a few kilos and your trying to climb steep inclines then I doubt that having only 2 motors is your problem. Most likely your batteries are not suitable. If your using Alkaline batteries then that's your problem. Use good quality NiMh or Lithium batteries and you will be surprised how much more speed and power your Rover 5 has.

What batteries are you using? How much does your bot weigh?

 

The explorer board doesn't really use much power at all, maybe 50mA. The IR LEDs on the corner sensors draw as much as 50mA each but if your code is written properly then they only need to be on for about 100uS when you read the sensor.

Can you explain why you think it draws a lot of power and how much you hoped to save?

Once the robot is moving about and tracking an object then it is really up to you to add your own code to make the robot do what you want. My sample code was only intended to test all the functions and let customers check that everything is working. It is a base to build upon, nothing more.

I'm not sure the "Explore" code is finished. I wrote this program a long time ago and never got it finished to my satisfaction. You can remove the "/*" and "*/" to re-enable that bit of code if you wish but you may need to modify it or finish it yourself. The intention of the "explore function" was to have the robot use the eye as a simple range finder to avoid collisions while searching for a new moving object to track.

 

Hi, I have finished building the Explorer 5, Everything has been checked , When I load the main program, (Rover5_Explorer_Mega.ino), it comes up with "LeftEncoderA'was not declared in this scope" also this line is highlited "attachInterrupt(0,LeftEncoderA,RISING);" and thats as far as I have got. is there a special way to load up this program?, I am using Arduino 1.0.5-r2, Any help would be great.

 

Peter

Double post :(

Did you extract all the files in the folder? There are 11 files in the folder. Each file will appear as a separate tab at the top of the screen. If you cannot see the tabs then you did not unzip the folder correctly.

One of the files is "IO_pins.h". This is where the IO pins are defined. Think of this file as your wiring diagram. If you want to change your wiring for any reason then you must make sure you update the IO_pins.h file to reflect the changes.

Hi, Thanks for your reply, Ok, Yes I do have 11 files, 4 of which are in folders

OK, I took the 4 files in the there folders out, and the program loaded up ,

all 4 leds pulsate counter clock wise in turn While they are connected to the pc via the usb cable, The switch on the explorer board is in the off postition, when I disconect the usb cable and power on the switch, only the left one pulsates the others are just on

 

another update, I spaced the leds out a little , now I have all 4 leds pulsing CCW , when i place my hand near one of the corners that array goes steady, I assume they are now working correctly, The 2 servo's (pan & tilt) will center, But I dont get anything else happening.

It sounds like your wiring might be wrong then, check the wire that enables the IR LEDs in the eye (white wire in the diagram). Use the IO_pins tab to confirm it's connected to the correct pin. I recently built another Rover 5 using the software attached to this post and the wiring diagram. It worked fine.

Thanks for your reply.

I have checked the IO tab...its says D53, which is where i have the white wire connected,

I have a pic of the chassis and a link to a short Youtube http://letsmakerobots.com/arduino-mega-2560-r3-qusetion

If you get a chance to have a look, I would appreciate it.

Regards Peter