33
PDST Technology CPD 1 Programming the GENIE E18 Motor Control Board to Control a Mini Sumo Robot

Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

1

Programming the GENIE E18

Motor Control Board to Control

a Mini Sumo Robot

Page 2: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

2

Foreword

The PDST Mini Sumo Robot has been developed as a low cost introductory model for educators interested in

Applied Control and Robotics.

Robot Sumo is a sport in which two robots attempt to push each other out of a circular ring in a fashion

similar to the sport of Sumo wrestling. The robots used in these competitions are sometimes called

Sumobots.

Robot Sumo is divided into classes which are fought on progressively smaller arenas. The PDST Mini Sumo

Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g and maximum size of

10cm x 10cm x any height.

The accompanying notes and information included in this module outline the concept and rules behind

Robot Sumo along with how to manufacture the robot as well as giving a history of robotics complete with

notes and video.

This Mini Sumo Robot has the following features:

Three piece simple chassis easily made form acrylic sheet or even cardboard.

Low centre of gravity and moment of inertia allowing quick deceleration.

Two wheeled easily controlled differential drive and steering.

Front mounted LDR edge sensor – students can add a rear mounted LDR sensor as an additional

exercise.

Line illumination LED beside LDR sensor to standardise calibration.

Forward facing one piece infra-red distance sensor 10 – 80cm.

Page 3: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

3

The following should be noted when using this robot:

It is not possible to program the DC motors supplied for a set number of rotations – more expensive

stepper motors would be required for this type of control. It is possible to program the motors to

turn for a set time period e.g. 1.5 seconds etc.

All the settings for the LDR and infra-red sensors indicated in the notes are examples only. Each

robot will require its own settings for the sensors to be found through calibration. They will depend

on the surface it is operating on, the whiteness of the white border/edge, the charge in the batteries

and indeed similar sensors will differ slightly from each other.

It will be necessary to make your own Mini Sumo Robot competition ring to the dimensions shown

below. MDF, laminated board or plywood are all suitable materials and are easily sprayed

black/white with minimal preparation.

The current Irish Mini Sumo Robot Competition Rules are included in the folder Mini Sumo Robots

Introduction.

Ring Name

Ring Diameter

Ring Height

White Border Width

Start Line Width

Start Line Length

Start Line From Center

Mini Sumo

77 cm 2.5 cm 2.5 cm 1 cm 10 cm 5cm

Page 4: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

4

Table of Contents

1. Downloading/Installing GENIE Design Studio Software .............................. 5

2. GENIE Design Studio Interface .................................................................... 6

3. Connecting the E18 Motor Control Board to your PC .................................. 7

4. Testing the E18 Motor Control Board ......................................................... 8

5. Driving the robot forward/reverse ........................................................... 13

6. Turning the robot ..................................................................................... 16

7. Using the LDR readings to create a SURVIVE program ............................... 19

8. Using the infra-red sensor readings to create a Hunt & Attack program…….27

9. Combining SURVIVE, HUNT and ATTACK programs ................................... 30

10. Improving your Mini Sumo Robot Performance ...................................... 31

11. GENIE Design Studio Help ....................................................................... 32

12. Useful links ............................................................................................. 33

Page 5: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

5

1. Downloading/Installing GENIE Design Studio Software Copies of GENIE Design Studio Version 1.1 software and associated USB Driver Installation Wizard is

available in the folder 4.GENIE Design Studio Software Installation.

If you encounter any problems all the required software, drivers and troubleshooting tools etc. can also be

downloaded free via the website www.genieonline.com by clicking on the tab Downloads as shown below.

If you encounter any difficulties click on the Support tab and you will be directed to the GENIE

Troubleshooting Guide and the Troubleshooting Tool. Both of these are also available on the Technology

resource DVD in the 4.GENIE Design Studio Software Installation folder.

Page 6: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

6

2. GENIE Design Studio Interface

To open GENIE Design Studio click the GENIE Design Studio icon on the desktop or use the start

menu to locate the program.

Menu Bar

Work Area

Tool Bar

Programming Commands

Microcontroller button

Page 7: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

7

3. Connecting the E18 Motor Control Board to your PC Connect the GENIE USB Plug & Play cable.

The following should appear:

If the confirmation window does not appear click on the Help button and consult the Troubleshooting

Guide as described in Section 1.

Select OK

Page 8: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

8

4. Testing the E18 Motor Control Board Firstly you must tell the software what GENIE chip you are using. Select Microcontroller from the tool bar

followed by Program Settings. Select the GENIE E18 chip.

The Program Settings window provides information about the inputs/outputs available on the E18 chip:

Number of inputs and outputs available

Chip configuration

Page 9: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

9

The E18 chip has the following features:

8 digital outputs labeled Q0 to Q7

We are only using Q3 to Q7 incl. for this robot

These outputs are ‘digital’ in that they are either on (1) or off (0)

3 possible analogue inputs e.g. LDR, Thermistor etc. labeled A0, A1 and A2

5 possible digital inputs e.g. switches labeled D0, D1, D2, D6 and D7

As shown on the chip configuration:

o Input A0 and D0 share Pin 17 – connected to A/D0 on PCB

o Input A1 and D1 share Pin 18 – connected to A/D1 on PCB

o Input A2 and D2 share Pin 1 – connected to A/D2 on PCB

We are using A/D1 and A/D2 for this robot

Power to the chip can be tested across Pin 5 (0v) and Pin 14

NOTE: Battery power must be between 6 V and 12V

It is possible to set the E18 as the default chip to be used by the software each time it is opened. Instructions

for this are available by viewing the AVI file Setting GENIE E18 chip as default located in the folder 5.GENIE

Design Studio Training for Mini Sumo Robot.

NOTE: We are only using LDR and infra-red inputs in this module but it is possible to use many other analogue inputs such as a thermistor, variable resistors etc with the GENIE E18. Similarly it is possible to incorporate digital inputs such as micro switches with the robot for obstacle avoidance etc but they are not covered in this module.

Page 10: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

10

Connect the GENIE USB Plug & Play cable to the line follower robot and turn on power to your robot using

the SPST switch on board.

The green status LED should flash and the software should indicate that the

microcontroller is now connected as shown.

We can now test that both motors and the line illumination LED are

working.

We will use the Control Device command to test these outputs. This command can be activated from the

menu shown above or by clicking the Microcontroller button on the tool bar as shown below.

Page 11: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

11

Activating the Control Device command opens the following window in the Program menu.

2. This indicates that the software recognises that the LDR connected to A/D1 is connected.

1. By clicking on output Q3 and changing it from off (0) to

on (1) we should be able to activate the line illumination

LED beside the LDR.

3. By covering the infra-red sensor connected to A/D2 we

should see its operation indicated on the screen as shown.

Page 12: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

12

Troubleshooting: If the LED does not illuminate, check the following: Is the LED connected into the PCB with correct polarity as shown below?

Is the LED connected to the LED with correct polarity i.e. leg on flat side of LED connected into negative

black?

If the infra-red sensor does not operate, check the following:

Are the black and red cables connected to +V and 0V in Q0?

Is the white cable connected to 0V in A/D2?

Now, by turning on (1) and off (0) outputs Q7, Q6, Q5 and Q4 in turn, we should observe the clockwise and

anticlockwise rotation of each motor M4 and M3.

If the motors do not operate then check the following:

Are the 2 cables from M4 connected into Q6 and Q7 on the PCB?

Are the 2 cables from M3 connected into Q4 and Q5 on the PCB?

In the next section we will now look at how to write a simple program to operate both motors in order to

create forward and reverse motion.

Page 13: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

13

5. Driving the robot forward/reverse We are now ready to write our first program to move the motor forward and reverse.

Construct the following flowchart by left clicking and dragging the programming commands from the

Gallery. Commands will automatically link together when you drop them in place.

The Motor command is located under the Input and Output section of the flowchart

symbols.

The Wait and Stop commands are located under the Program Control section of the

flowchart symbols.

Commands will automatically link together when you drop them in place.

Each command must now be edited in order to complete the program.

NOTE:

The following conventions are used when editing outputs and inputs:

0 Make output low (off).

1 Make output high (on).

T Toggle this output (where high is set to low and low is set to high).

X Leave output alone.

Page 14: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

14

Double click on each of the commands except the Stop and edit as shown below. Remember to set the type

of motor being used to DC:

It is good practice to give every program a name to appear in the Start symbol.

Push up the M3 and M4 sliders in order to set both to forward motion. NOTE: Depending how you have connected each motor polarity you may find that you need to set the sliders in the down position or one slider up and the other down in order to achieve forward motion when you download and Run Live.

Set the Wait time to 3 seconds. This instructs the program to continue running the last command for 3 seconds.

Click on the M3 and M4 buttons to turn both motors off.

It is also good practice to include a caption indicating what each command is doing.

Page 15: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

15

In order to download the program to the robot, click on the Microcontroller button and select Run Live. The

Program window will indicate that it is Accessing the PIC chip and then that it is Running Live. The program

will start immediately once it is downloaded. The USB cable can then be removed and the program rerun by

pressing the small reset switch on the PCB.

The following commands and screen will be seen when using Run Live.

As mentioned previously, when you run this program live you may now discover one of the following

scenarios depending on how you have connected the motor polarity either at the motors or on the PCB:

a) The motor is actually going in reverse. In this case you simply set both M3 and M4 sliders to the down

position instead of the up in order to get forward motion.

b) One motor is going forward and the other going in reverse. In this case you will have to move M3 slider

up and M4 down or vice versa.

EXERCISE 1

Edit the program so that your robot moves forward for 2 seconds and then reverse for 2 seconds.

Use Run Live to download and run the program.

Page 16: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

16

6. Turning the robot The procedure for turning the robot while it is moving is based simply on turning off one motor and leaving

the other running.

Construct and edit the following flowchart as shown. Settings for motor control are shown.

You will see these output settings appear in the Multiple Panel View when we simulate this program.

NOTE: Depending how you have connected each motor polarity you may find that you need to set the sliders in the opposite position to that shown in order to achieve right/left turns etc. when you download and Run Live.

Page 17: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

17

Select the Run command on the tool bar.

You will see each flowchart command highlight as the program

simulates.

The Speed Dial can be rotated to adjust the speed at which the

simulation runs.

Now click on the View several monitor panels at once command in

order to open Multiple Panel View.

This allows us see what each flowchart command is doing as shown

below.

Simulation Example: To turn right motor M3 is turned off by turning off both outputs Q4 and Q5 and motor M4 is left running (output Q7) in forward direction. We created this setting earlier while editing this command using Motor Properties.

Page 18: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

18

Click on the Microcontroller button and select Run Live in order to download the program to the robot. The

Program window will indicate that it is Accessing the PIC chip and then that it is Running Live. The program

will start immediately once it is downloaded. The USB cable can then be removed and the program re-run by

pressing the small reset switch on the PCB.

EXERCISE 2

Like all learner drivers you need to learn how to complete a 3 point turn.

Edit the previous Turning Ex program to have your robot execute a 3 point turn.

Points to consider:

There are numerous solutions to this exercise.

Ensure your wheels are tightened on to the motor shaft to ensure proper movement.

It is not possible to control the number of revolutions of a DC motor as it is with a servo or stepper

motor.

Controlling the amount your robot turns using the Wait command is accomplished by trial and error.

It is possible to set the Wait Properties to fractions of seconds by typing the value in rather than

selecting the set values from the drop down menu as shown below.

The turning circle of a robot such as this depends on the diameter of the wheel and the distance

between the wheel centers. This could be the basis for an applied maths question for your students.

Having completed this exercise why not try to program your robot to drive in a square, drive in a figure 8 or

even set up a parking bay that it must park in using parallel parking!

Page 19: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

19

7. Using the LDR readings to create a SURVIVE program.

Before we can successfully use the LDR to detect the white border on the Sumo competition table/ring we

must learn how to understand the digital reading that the LDR creates in the software.

The resistance of the miniature LDR supplied goes from approx. 1KΩ in normal light to approx. 15KΩ in

normal darkness i.e. it’s resistance increases as it gets darker.

Theoretically it goes from 0KΩ in total brightness to 1MΩ in total darkness.

The GENIE software takes whatever analogue resistance value the LDR has at any given moment and

converts it into a digital reading of between 0 and 255.

A digital value of 0 corresponds to an LDR resistance of 1MΩ i.e. total darkness.

Similarly, a digital reading of 255 corresponds to an LDR resistance of 0KΩ i.e. total brightness.

Turn on your robot, connect it to the USB and select Calibrate Sensor from the Microcontroller menu on the

tool bar. You should see the screen shown below.

Shows the LDR connected to A1 and the infra-red sensor connected to A2, and their current reading. Move the robot around and observe the A1 reading change as LDR passes over the white edge. Place something in front of the infra-red sensor A2 to observe the reading change.

Page 20: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

20

The area underneath the LDRs on the robot will, by virtue of its design, be quite dark. This could create

difficulties when trying to detect a white surface on a dark surface. In order to solve this problem a LED has

been installed beside the LDR to illuminate the surface underneath.

In order to calibrate the LDR while this LED is on we will use the Debug Live rather than the Calibrate Sensor

command. Debug Live allows you watch your program animate and monitor the state of inputs, outputs,

variables etc. as it runs on the actual GENIE E18 chip.

Construct and edit the following flowchart as shown below.

To create the loop, firstly left click and hold the mouse over the right connection point on the Outputs

symbol. Drag the connecting line to the right and then upwards to create the first 90˚bend. To create the

second 90˚bend, release the left mouse button and then click again at a point approximately in line with the

Start command. Continue dragging the line to complete loop.

The Outputs command is

used to turn on the LED

connected to output Q3.

The loop back to the Start keeps the LED tuned on.

Release and click again here

Page 21: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

21

Now click the Microcontroller button and select the Debug Live command. Click Start to begin live debugging.

By clicking on View several monitor panels at once as shown below we can now observe what the LDR is

reading while the LED is lighting.

Page 22: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

22

In order to get a calibration reading for the LDR on the black surface a reading should be taken in each of the

four quadrants of the ring as shown below.

A1 reading 106 A1 reading 110

A1 reading 111 A1 reading 125 This gives a maximum reading for A1 LDR on the black surface of 125. Notice that this reading occurs at the

edge of the board that light from the window is shining on. Ambient light levels can affect the operation of

the robot but the use of the LED should minimize this.

Therefore if A1 reads anything above 125 then the robot is either on the white edge or very close to it. We will now start creating a basic ‘survival’ program for the robot using this data. To ‘survive’ the robot must stay on the ring i.e. it must detect the white edge whenever on it and then

reverse away from it.

NOTE: You must use your own readings in the following programs.

Page 23: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

23

Construct and edit the following flowchart as shown.

It is good practice to name all programs.

The illumination LED must be turned on at the start of the program.

Start your robot in the centre of the competition ring. It then drives forward.

The Compare command checks whether the reading from A1 is greater than 125. If not N the robot continues forward. If it is greater Y the program moves on to the next command.

If the Compare command detects that the reading from A1 is greater than 125 this means that the robot is on the white edge. The robot then stops for 0.5 seconds.

At this point the robot needs to reverse back from the white edge toward the centre of the board.

You can decide how long to reverse for in order to return to the centre of the ring. The loop back to the start of the program starts the program again.

NOTE: You can swap the Y and N program paths by right clicking

Page 24: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

24

We can now test our program using Debug Live. Firstly, place your robot in the center of the competition

ring and connect your USB.

As before, select Debug Live, click Start and then select View several monitor panels at once.

Turn the Speed Dial fully clockwise to its maximum.

Your robot should start moving toward the white edge of the competition ring and the program will

highlight red showing its progress.

We can see above that output Q3 is activated keeping the illumination LED lit.

We can also see outputs Q4 and Q5 activated – these are the settings for forward motion in this robot. You

may have different outputs activated for forward motion depending on how you have connected your

motors.

Depending on the speed of your motors you may now find that your robot drives over the white edge

without stopping – as if the sensor A1 was not working. It should be remembered that during Debug Live the

microcontroller communicates with the program continually and that this slows the speed that it can react

to changing conditions.

To check if this is happening slow down the speed of movement of your robot manually by holding it back so

that it has more time for A1 to react to the white edge. NOTE: Watch the video ‘Troubleshooting SURVIVE

program during Debug Live’ included in this folder.

Speed Dial

A1 is shown reading 110 which means that it is not greater than 125. The program therefore follows the N path keeping the robot driving continuously forward.

Page 25: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

25

When A1 is on the white edge and its reading is greater than 125 the program should continue past the

Compare command following the Y path.

We can see below that outputs Q7 and Q5 are now activated to reverse the robot for 1.5 seconds.

Having checked the program using Debug Live we can now download the program using Run Live, and run it

at full speed with the USB cable disconnected.

Any previous problems caused by A1 not recognizing the white edge quickly enough due to the program

running slower during Debug Live should not reoccur as the program will now run at full speed on the

microcontroller only without the need to communicate with the PC/laptop.

NOTE: Watch the video ‘SURVIVE program Run Live’ included in this folder.

However, you will discover while building robots that problems do occur, frequently, and that achieving

consistency in operation is one of the most difficult tasks. It is not possible to troubleshoot all the possible

problems here but we will now look at one that may have occurred while you were running this program

live.

Page 26: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

26

Firstly you should watch the video ‘SURVIVE program Run live problem’ included in this folder.

You will notice the robot perform the following:

1. Drive forward to white edge. Stop.

2. Reverse back. Stop.

3. Drive forward to the edge. Stop.

4. Reverse back. Stop.

5. The front of the robot jumps slightly.

6. Robot continues in reverse rather than driving forward.

Question: Why do you think the robot continued in reverse rather than driving forward again as expected?

Answer: When the robot jumped slightly after stopping in step four, the A1 LDR did not get a proper reading

of the table surface i.e. the reading was greater than 125 rather than less as would be expected on the black

area.

Question: Why did the robot jump slightly?

Answer: I was using 6 x 1.5V batteries. These supply approx. 6V to each motor which is the maximum they

should be run at. Rapid stopping/starting can cause sudden jolts which due to the weight distribution in the

robot can cause the front to lift slightly.

Question: How can this problem be solved?

Answer: Extra weight could be added to the front of the robot or else the

program could be modified as shown.

An extra Robot Stop for 0.5 seconds has been included after the Robot Reverse

Watch the video ‘SURVIVE program Run live solution’ included in this folder to

see the result of this change.

Page 27: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

27

8. Using the infra-red sensor readings to create a HUNT and ATTACK program. The Sharp GP2Y0A21YK0F Analog Distance Sensor 10-80cm mounted on the front of this Mini Sumo Robot

has a transmitter and receiver built into a single unit. It creates an analogue signal that is converted to a

digital reading by GENIE Design Studio and can successfully detect something in its path up to 80cm away.

In order to use it to detect another robot on the competition ring we will first have to calibrate it to establish

what readings to use in our programs.

1. Connect your robot via the USB cable and turn it

on.

2. Click on the Microcontroller button and select

Calibrate Sensor.

3. Position your robot as shown with

nothing in front of it up to 80 cm away.

NOTE: When competing against each

other in a competition the robots are

programmed with a 5 second wait at the

start in order to allow operators and

spectators time to move back from the

competition ring.

4. The infra-red sensor is shown connected to input A2 and

reading 5. The software converts the analogue reading

into a digital reading between 0 and 255. NOTE: The

reading from A1 is also shown but is lower than normal as

the LED (output Q3) has not been activated.

Page 28: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

28

NOTE: The infra-red reading will increase to approx. 158 when something is at a distance of between 7 and

10cm from the sensor. The reading will then decrease as the detected object gets closer, falling to a reading

of between approx. 0 and 80 when the object is directly in front of the sensor depending on the surface of the

object. In our case this will not affect the use of a reading of 60 for A2 in the program but you must calibrate

your own robot in order to establish suitable readings for your own programs.

We will now look at how to create a basic HUNT-ATTACK program using the A2 reading above.

Construct and edit the following flowchart as shown.

5. Place an object in front of the robot at

the far side of the competition ring as

shown. In this example the reading on

A2 has now increased to 27.

6. Move the object to approx. the centre

of the competition ring as shown. The

reading on A2 has now increased to 60

in this example. We will use this

reading in our next program. You may

decide later to use a reading that

detects another robot either closer or

farther away.

Page 29: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

29

As the robot rotates during this program it is difficult to test it using Debug Live because of the attached

USB. One method of getting over this problem is shown in the video ‘HUNT-ATTACK program Debug Live’.

The video ‘HUNT- ATTACK program Run Live’ shows the program being tested at full speed.

It is good practice to name all programs.

The robot hunts for its opponent by rotating through 360 degrees. In this case the motors are set to rotate in opposite directions. Alternatively one could be stopped while the other rotates.

While the robot rotates/hunts infra-red sensor A2 checks its reading. If less than 60, the program follows the Y path and robot continues rotating as there is no opponent in front of it. If the reading is not less than 60 the program follows the N path and drives forward/attacks as it has now detected an opponent in front of it.

It is good practice to name all programs.

In this example the robot is set to drive forward/push for 2 seconds and then stop. In an actual battle it would push its opponent until it detected the white edge.

Page 30: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

30

9. Combining SURVIVE, HUNT and ATTACK programs.

Construct and edit the following flowchart as shown. It is a combination of the previous two programs.

The program operates as follows:

1. The illumination LED attached to output Q3 is turned on immediately

when the program starts.

2. Upon pressing the reset switch the program initially waits 5 seconds

to allow everyone move back at least 2 metres from the table so as not to

affect the A2 infra-red sensor readings.

3. In HUNT mode the motors turn in opposite directions to rotate the

robot 360deg so that it can hunt for opponents using its IR sensor A2.

4. If another robot is detected, A2 will read more than 60. While A2 is

less than 60 it will keep rotating and hunting until the opponent is detected.

5. If an opponent is detected the robot moves forward into ATTACK

mode - trying to push it off the board.

6. While attacking and pushing the opponent the robot continuously

checks for the white border using LDR sensor A1 - this is SURVIVE mode. If

the line is not detected it continues pushing the opponent.

7. If the white border is detected i.e. A1 reads more than 125 the robot

stops, waits briefly, reverses and returns to the original 360deg hunting

mode once again.

The video ‘SURVIVE-HUNT-ATTACK program Run Live’ shows the program

being tested at full speed.

NOTE: The values used for A1, A2 were changed to 128 and 70 respectively

due new batteries being installed. The values you use for A1, A2 and the

motor wait times etc. will also require recalibration depending on the

components installed and the conditions they are used under.

Page 31: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

31

10. Improving you Mini Sumo Robot performance. Example strategies for relatively simple improvements in your Mini Sumo Robot’s performance:

1. Include another LDR A0 on the rear of the robot that could be used to detect the white edge if it

were being pushed backwards.

a. This would allow further SURVIVE strategies to be incorporated.

b. Include a sub routine in your program that will return the robot to HUNT mode if it loses

sight of its opponent i.e. if the A2 reading goes above 60 while attacking. This may happen if

the robot was pushing an opponent at an angle and lost contact with it.

c. A sample of this type of program called ‘Sample Mini Sumo Advanced Program’ is included

in the folder Mini Sumo Robot Sample Programs. Explanatory notes are included with the

flow chart.

2. Include micro switches on the sides that could be connected to D6/D7. These could be used as

detectors to indicate that your opponent has made contact and is pushing you – allowing the

possibility of evasive action.

3. Increase the size and or traction of your robot wheels. The robot shown in the videos has larger

wheels with rubber bands around them to increase traction.

4. Install more powerful/stepper motors etc.

5. Consider how your robot is positioned at the start of a bout? The new Irish rules (in folder 2. Mini

Sumo Robots Introduction) indicate that robots must be placed facing in opposite directions in

opposing quadrants of the circular ring (Rule 4.1). However, the rule indicates that the robots can be

placed anywhere within each quadrant.

6. Decide how and where it will initially move in order to efficiently hunt attack and survive?

7. Decide how far away a detected opponent must be before you attack but remember that you can

change this decision at different points in the program.

8. Consider methods of avoiding being targeted such as altering the materials used in order to affect

the infra-red readings etc.

Page 32: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

32

11. GENIE Design Studio Help These notes are only an introduction to GENIE Design Studio. It contains many more commands that have not been

mentioned at all.

Explanations of these other commands can be found in the Help section of the software by clicking on GENIE Design

Studio Help as shown below:

Then select Flowchart commands as shown: This will open a window displaying all current GENIE commands. By clicking on any command the user will be given a

simple explanation of what the command does along with a sample flowchart showing how the command may be

used.

Page 33: Programming the GENIE E18 Motor Control Board to Control a ... Robot/PDST Mi… · The PDST Mini Sumo Robot can compete in the Mini Sumo class which allows a robot mass of up to 500g

PDST Technology CPD

33

12. Useful Links The following is a sample of websites that may be useful for further study in the area of microcontrollers and Mini

Sumo Robots:

http://www.genieonline.com/

http://en.wikipedia.org/wiki/Robot-sumo

http://www.robotroom.com/Robots.html

http://www.technologystudent.com/pics/picdex1.htm

http://www.ridgesoft.com/articles/minisumo/Building%20and%20Programming%20a%20Mini-Sumo.pdf

http://www.youtube.com/watch?v=hCg9p-bZw4o

http://www.huv.com/miniSumo/

http://www.societyofrobots.com/robotforum/index.php?topic=98.0

http://www.wa4dsy.net/robot/robor/index.html

http://www.fingertechrobotics.com/proddetail.php?prod=ft-kit-cobra-4wd-chassis

http://www.junun.org/MarkIII/Store.jsp

http://www.hobbyengineering.com/sumovore.html