DAGU MR. Tidy User manual

Mr. Tidy is a unique and versatile robotic platform ideal for students and hobbyist alike. The 2DOF arm and
array of sensors make this robot capable of so much more than just line followin and object avoidance. An
open framework makes experimentation and expansion quick and easy.

Contents:
Main board features
Assembly
Installin the software
Understandin the sample software
How it works
Trouble shootin
Usin the dia nostic software
Specifications
3
4
9
10
13
15
16
21
2

Main board Features
3

Assembly Instructions
STEP 1: The robot arm comes in two parts that must be joined to ether before the arm is attached to the
base. Start by removin the nuts and sprin washers shown in the photo bellow. Do not completely remove
the screws. This will allow you to use a screwdriver to join the two sections.
STEP 2: Join the two parts as shown below and then replace the washers and nuts removed in STEP 1.
4

STEP 3: Undo the 3 brass spacers and remove the main board.
STEP 4: Insert 6x “AA” (UM3) NiMh batteries. Do not use alkaline batteries as they cannot supply enou h
power for the robot and cannot be rechar ed. Note how the battery cable is run.
5

STEP 5: Re-install the main board bein careful to ensure the encoder PCB for the wheels plu s in correctly.
Make sure the battery cable is behind the mountin post so it cannot jam in the ears.
STEP 6: Mount the arm onto the base with 3x8mm screws as shown. The screwdriver oes between the
ears from above. It may be easier to use pliers to hold the nut while startin the thread. A spanner can then
be used to ti hten the nuts.
6

STEP : Now that the arm is mounted we need to tie the wires to the frame and connect all the wires to the
main board. Pay careful attention to the orientation of the plu s.
7

STEP 8: Attach the IR receiver to the robot. Pay careful attention to how the cable plu s into the processor
board. Incorrect connection may dama e the receiver.
STEP 9: Check your connections carefully before turnin the robot on. When you turn it on it should start by
playin a simple tune. The robot will then open its ripper, lower the arm until the lower limit switch is hit and
then raise it’s ripper. The robot will now search for objects to pick up.
8

STEP 10: optional sensor ali nment rin s can be fitted to help maintain sensor ali nment when the robot
bumps into somethin . These rin s may reduce the sensitivity of the sensors sli htly but can improve
reliability.
Installing the software
This robot can be pro rammed usin a free Inte rated Development Environments (IDE) from the internet.
Dependin on your pro rammin skills there are several choices. Many advanced pro rammers would
choose an IDE such as AVR Studio and use the ISP socket to pro ram this robot.
To make this robot as easy as possible to pro ram we have chosen to make it compatible with the Arduino
IDE and have included a USB interface. This manual assumes that the Arduino IDE (version 18 or later) is
bein used. Althou h the robot comes with the Arduino bootloader and sample software already installed you
will need the Arduino IDE for loadin the dia nostic software and writin your own code.
At the time this manual was written the Arduino IDE was available for Windows, Mac OS X and Linux 32bit. It
can be downloaded from here: http://arduino.cc/en/Main/Software
Once you have the Arduino IDE installed on your computer you can then open the pro ram
“Mr_Tidy_Sample_Code.pde” which is supplied with the robot or can be downloaded from our website at
http://arexx.com.cn/en/DownList.asp
9

Understanding the sample software
The sample software supplied with the robot instructs the robot to locate objects and sort them based on
colour. This is only a simple demonstration pro ram but it contains sample code for all the motors and
sensors. The sample code has been written usin the Arduino pro rammin environment, as this is easier for
be inners.
You will see several tabs at the top, these tabs help or anise the pro ram makin it easier to use. The first
tab shows you the main pro ram. You can edit the pro ram here.
The second tab defines the robots IO pins. The Atme a1280 has 70 IO pins of which more than 40 are used
for sensors and motor control. If you add additional circuitry then you can define the new IO pins here. The
contents of this tab are like a map of the robot.
10

The third tab contains notes on how some of the sensors are used in the software. As you write your own
code you may add more information here. This is basically a scribble pa e.
The fourth tab contains a list of constants. Normally these values do not chan e. They are listed here to
simplify pro ram adjustments such as calibration of the RGB sensor.
It is much easier to chan e a value once here than to search throu h the entire pro ram chan in it where
ever it occurs.
11

The last tab contains a conversion table of musical notes thanks to Brett Ha man. This can be used to
simplify eneration of melodies for your robot and is used for the initial melody played when the robot be ins
operation.
Program structure:
When you break the sample pro ram down the structure is very basic. The pro ram starts by includin the
files that make up the tabs alon with any library files required. Global variables are then defined. These
variables can be accessed from anywhere in the pro ram.
The setup() function as the name su est is used to setup the robot when the pro ram first runs. The
interrupt pins are initialised and output pins are confi ured. By default, all pins start as input pins when the
robot is reset or first powered up. This prevents any accidental short circuits from occurrin . The arm and
ripper limit pins have an internal 20K pullup resistor initialised.
After playin a simple melody to warn that the robot has activated the ripper and arm are reset to their
default positions and the robot is ready to be in operation.
The loop() function is the main core of the pro ram and repeats continuously until the robot is shutdown or
reset. This function can be broken into several steps:
1. Check the timer and chan e the LED chase pattern if required.
2. Monitor the average battery volta e to determine if the char er has been connected.
3. Shutdown the robot if the battery char er is connected (Press reset after char in is finished).
4. Check the side and rear sensors to prevent a collision and operate/chase LEDs.
5. Monitor the front sensors and create a simple binary value of the readin s compared to the avera e.
6. Perform 1 of 16 actions based on binary readin s of the front sensors.
7. Determine if the robot has dropped an object and reset some variables if required.
By performin these seven basic steps repeatedly the robot will locate and pick up objects, attemptin to sort
objects accordin to their colour. As this is a simple demonstration pro ram there is no mappin involved
with the robot simply choosin a random direction to o in after pickin up or settin down an object.
All other functions are called on from the setup() and loop() functions as required. The lan ua e reference
can be found here: http://arduino.cc/en/Reference/HomePa e
12

How it works
Before you can write your own pro rams for Mr. Tidy you need to understand how the sensors work and how
the motors can be controlled.
Front sensors:
Each front sensor consists of 1 infrared LED and two infrared phototransistors. The two phototransistors are
wired in parallel to increase the ran e. These are analo sensors. As ambient infrared li ht will affect their
readin s the software needs to take two readin s.
The first readin is taken with the IR LEDs turned on. This value is a total of both ambient li ht and li ht from
the IR LEDs reflectin off nearby objects. The bri hter the li ht, the hi her the value.
The second readin is taken with the IR LEDs turned off. This value is the ambient li ht only. By subtractin
the ambient li ht value from the total li ht value you are left with a value equivalent to li ht reflected by
nearby objects.
You will see in the sample software that a small time delay (IRdelay) is used after the IR LEDs chan e
states. This is required to et the best results from the phototransistors. This value is set in the constants tab
and can be adjusted if necessary.
Bri ht sunli ht should be avoided as it will result in hi h ambient li ht values and reduce the sensitivity of the
sensors.
Side and rear sensors:
The side and rear sensors are similar to the front sensors but have only one phototransistor so their ran e is
about half that of the front sensors. These are analo sensors but are connected to di ital inputs as we only
need to know if an object is within ran e. Ambient li ht will affect their ran e and may even tri er a false
detection if it is very bri ht.
The side and rear sensors have a visible LED wired in parallel with their IR LED. Unlike the front sensors
these LEDs are individually controlled allowin the visible LEDs to be used to display patterns or the status
of the robot. This does not interfer with object detection which only requires the IR LEDs to be on for very
brief amounts of time.
IR receiver:
The IR receiver is a true di ital sensor. Unlike the other IR sensors this sensor is desi ned to detect IR li ht
modulated at 38KHz. It does not respond to the overall intensity of the li ht so ambient li ht is i nored. As
with the analo sensors, it’s ran e can be reduced by bri ht sunli ht.
The output of this sensor is normally hi h. When the receiver detects IR li ht modulated at 38KHz it’s output
oes low. This sensor is ideal for detectin si nals from a universal TV remote or IR navi ation beacons. If
two or more robots need to communicate with each other then this sensor could receive data from another
robot that was modulatin it’s IR LEDs at 38KHz.
Colour sensing:
This robot uses a Red, Green, Blue (RGB) LED and a Li ht Dependant Resistor (LDR) to detect colour.
Colour sensin is achieved by shinin different colours of li ht onto an object. By measurin how much of
each colour is reflected back the objects colour can be determined. In the sample software the volta e
across the LDR is measured while shinin red, reen and then blue li ht onto the object. The volta e is also
measured with the RGB LED off to et an ambient li ht readin which is subtracted from the red, reen and
blue readin s so that the values represent the reflected li ht only.
The sample software then compares the red, reen and blue values to the avera e value to provide a simple
3 bit result. This is not the most accurate method and should be refined if precise colour matchin is
required. As the red, reen and blue elements of the RGB LED are driven by PWM outputs the sensor can
be easily calibrated.
13

Motor control:
Each of the 4 motors on the robot are driven by a “H” brid e. This is a circuit commonly used to control DC
motors when direction as well as speed needs to be controlled. Field Effect Transistors (FET) are used on
this robot as they are more efficient than Bi-polar Junction Transistors (BJT) thus allowin more power to be
delivered to the motors. Each “H” brid e includes a current sensin circuit to allow the robot to monitor the
current bein drawn by a motor and each motor has a simple optical encoder to measure rotation.
Each motor has 2 processor pins dedicated to control and another 2 dedicated to feedback. These pins are
defined in the “IOpindefinitions.h” tab. Usin the left motor as an example:
Lmotordirpin controls the direction of the left motor. When this pin is HIGH or “1” then the left wheels will
run forward. Makin this pin LOW or “0” will cause the left wheels of the robot to run in reverse.
Lmotorpwmpin controls the speed of the left motor usin Pulse Width Modulation (PWM). The Arduino IDE
uses the command analo Write() to enerate PWM usin values from 0 to 255. A value of 0 will cause the
motor to stop completely. A value of 255 will run the motor at full power.
At low speeds the motor may stall. A simple method of preventin the motor from stallin at low speed is
alternate it’s speed between the speed you want and a low value that will not stall. For example, if you want
a speed of 23 and you know the motor will not stall at speeds of 60 and hi her then write your pro ram so
that at speeds below 60 the pro ram will alternate the speed between the desired speed and 60.
This will cause the motors power to pulse at a level that can overcome a stall. While the robots movements
will not be as smooth it will allow the robot to achieve much lower speeds.
Lmotorencpin is the di ital si nal from the motors optical encoder. The encoder reads black and white
marks on the motor ear train and outputs a “1” when a black mark is read and a “0” when a white mark is
read. In the sample software, external interrupts are used to monitor these pins and count when they chan e
states.
As this encoder cannot determine direction the sample software uses the direction the motor is travellin in
to determine if it should add or subtract from a value. If the motor needs to chan e direction then it should be
allowed to come to a complete stop first to ensure an accurate count.
Lmotorcurpin is an analo si nal that represents the current bein drawn by the motor. Usin the
analo Read() command in the Arduino IDE will ive a value of approximately 400 when the motor is drawin
1A. This can be useful not only for determinin if the motor has stalled but also if the robot needs
maintenance. If for example dust or dirt ets into the ears then the robot may continue to operate but the
avera e current draw of the motor will increase. If the motor draws less current than expected then perhaps
the robot has fallen so that the left wheels can spin without load.
Amotorlimpin and Gmotorlimpin are the di ital input pins for the Arm and Gripper limit switches. The di ital
inputs are normally held at 1 or HIGH by internal pullup resistors. A low or 0 indicates that a switch is closed.
Using motor feedback:
By monitorin the encoders and current sensors of the robots motors various functions can be achieved. The
wheel encoders allow the robot to measure speed and distance travelled allowin the robot to make a map of
an area to improve navi ation. Current sensin of the wheel motors in conjuction with the encoder
information allows the robot to map inclines such as ramps.
Monitorin the current draw of the arm motor when liftin an object can be used to jud e the wei ht of an
object and determine if the ripper needs to apply more pressure to hold the object.
Usin the arm encoder to determine if the arm is movin or has stalled as the motor current for a heavy
object mi ht be similar to the stall current.
The ripper encoder allows the robot to estimate the size of the object and the ripper motors current draw
can be used to determine how much pressure is bein applied.
14

Troubleshooting: If the robot fails to operate correctly then please check the list below. In many cases it
may be necessary to use a 12DC (500mA or better) power supply plu ed into the rechar e socket. You may
also need to install the dia nostic software which is supplied or can be downloaded from our website at:
http://arexx.com.cn/en/DownList.asp
Note: the robot should not be operated in stron sunli ht as this can reduce the sensitivity of the IR sensors.
Problem - the power switch is on but the robot does not appear to work.
Solution - check the battery connection. Connect 12V DC supply (rated for at least 500mA) to the char in
socket on the robot and press the reset button. With the sample software supplied the robot should play a
melody before it starts movin . If you are usin your own pro ram then load the dia nostic pro ram and
retest the PCB with the 12V DC still connected to the char in socket.
Problem - the robot does not move or moves very slowly.
Solution - check that the wheels turn freely when the power is off. Each drive shaft has two couplin s.
These may need adjustin to ensure the shafts are strai ht.
Problem - one or more of the encoders does not work.
Solution - Check the encoder cables are plu ed in correctly and that the screws near the encoder are ti ht.
With the ripper and arm encoders, check that the encoder disk is as close as possible to the encoder PCB.
Load the dia nostic pro ram and connect 12V DC to the rechar in socket. Check the encoder with the
dia nostic software and adjust the position of the encoder disk if necessary.
Problem - the robot has trouble detectin objects or ali nin the ripper.
Solution - the robot requires the front sensors to be re-ali ned. Load the dia nostic pro ram and ently
adjust the position of each photo- transistor so that when there are no objects within ran e all sensors ive
the same readin s (approximately 50).
Problem - one of the collision avoidance sensors does not work.
Solution - the sensor requires re-ali nment. Usin either the sample software or dia nostic pro ram the blue
LED nearest the sensor will stay lit while an object is bein detected. The IR LED and phototransistor should
be parallel to each other but not touchin . Gently adjust their positions until the sensor only detects an object
when you place your hand within approximately 40mm of the sensor.
Problem - the robot attempts to pick up an object but releases it a ain.
Solution - was the object too small? Check the limit switch is connected and workin properly. If the cam
drivin the ripper oes past a certain point then open and close are reversed. Turn off the power and try
turnin the cam by hand 180 de rees. If you are writin your own code then try reversin the motor
directions for open and close.
15

Using the diagnostic program
The dia nostic software allows you to test all of the robots sensors and motors. To use the pro ram you must
have the Arduino Pro rammin Environment loaded on your computer (version 18 or later).
Open the pro ram Mr_Tidy_PCB_dia nostic. Go to the tools menu and select the “Arduino Me a” as your
board type.
Make sure the robot is connected to the computer via the USB cable and turned on so that the computer can
detect it. Select the serial port.
16

Upload the dia nostic pro ram to your robot. You should see the communication LEDs near the USB port
li ht up as the pro ram is uploaded and verified. If this fails then re-check your serial port settin s and check
that your robot is turned on. It may be necessary to connect 12V DC to the char in socket if your battery
volta e is too low.
Now run the serial monitor, this allows you to communicate with the robot. Make sure the baud rate in the
lower ri ht corner of the serial monitor window is set to 9600.
The robot should start by playin a short melody. The blue LEDs at the corners of the PCB should now be in
to chase and the RGB LED will flash. In this default mode the collision avoidance sensors can be tested by
placin your hand in front of the sensors. When a sensor detects your hand the correspondin LED will stay
lit while the others continue to chase.
17

You will see the output of the colour sensor in the serial monitor. If there are no objects within ran e it will say
the colour is none. The colour reco nition code simply looks at which readin s are hi her than the avera e.
To calibrate the colour sensor, place a piece of white paper about 20mm in front of the robot. Adjust the red,
reen and blue PWM values in the constants tab and then upload the pro ram a ain. When the red, reen
and blue readin s on the serial monitor are the same then the sensor is calibrated. Write these values down
so they can be inserted into the main pro ram when it is reloaded back into the robot.
Go to the top of the serial monitor window, type “e” and then press [enter]. This will cause the serial monitor
to display the encoder and limit switch inputs.
By manually movin the wheels, arm and ripper you will be able to check the operation of all the encoders
and limit switches.
18

To calibrate the front sensors, press “f” and then [Enter]. This will display the readin s from the four front
sensors. Place the robot so there is nothin within 1 meter of the sensors. All sensor readin s should have
similar low values. As you move your hand in front of the sensors you should see the readin s chan e.
The value “Object Size” is the decimal value of the sensor readin s used by the sample software to
determine what action to take.
The optional sensor ali nment rin s may affect the sensitivity of the sensors but will help maintain their
ali nment if the robot bumps into an object.
The battery volta e can be monitored by pressin “b” and then [Enter]. The readin is approximately 100x
the actual volta e so in this case the battery readin would be 7.35 Volts. This volta e can fluctuate as
motors and sensors operate so the sample software avera es this over a 20 second period when
determinin if the batteries are bein rechar ed.
19

The last test is for the “H” brid es that control the motors. As this test runs all motors forward and backward
without re ard to limits it is recommended that the arm and ripper motors have their drive ears removed
before testin and the robot be suspended so the wheels are not in contact with the round.
Below you can see a photo of the ripper motor with it’s drive ear removed. Remember the arm and ripper
motors have two ears that need to be removed.
If you only need to test one motor then disconnect the other motors from the main board prior to testin .
Once the robot has been prepared press “m” and [Enter] to be in the motor test. As the motors increase and
decrease their speed you should see their current draw chan e.
20
Table of contents
Other DAGU Robotics manuals