Arduino Line Follower Wallrides Classroom Whiteboard

8,499

89

8

Introduction: Arduino Line Follower Wallrides Classroom Whiteboard

About: klaatu barada nikto

Following the line on the ground is too boring!

We've tried to look at a different angle at line followers and bring them to another plane - to the school whiteboard.

Look what came of it!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What Do You Need?

For one racing robot:

Mechanics:

  • 2 x 6V Micro geared motor with the 1:150 reduction ratio; Geared motors included with the miniQ robot platform have a gear ratio of 1:50 and are too fast. They should be replaced by stronger motors for example with the 1:150 or higher gear ratio. The higher the gear ratio the slower the robot rides on the whiteboard but the less the chance that the wheels slip.
  • 4 x Neodymium magnet; You need small 3mm thickness magnets with the 12mm diameter (for those with a round shape) or with the 12mm side (for those with a square shape). Also, magnets should have a hole for the machine screw with a countersunk head usually for the M3 one. Sometimes manufacturers specify the strength of the magnet coupling. It should be in the range of 2kg to 2.4kg.

Electronics:

  • 1 x Arduino UNO; The on-Board computer. The most popular prototyping platform.
  • 1 x Octoliner module; Eyes and headlights of your racing bot. Octoliner is a cool line sensor consisting of 8 separate infrared sensors controlled via an I2C interface.
  • 1 x Motor shield; Almost any module suits you. I used this analogue one based on L298p chip.
  • 1 x 2-cell 7.4V LiPo battery; It can give a large current that motors need to overcome the attraction of the magnets. The 2-cell battery has a voltage in the range of 7.4V to 8.4V. It is enough for 6V motors and the built-in voltage regulator on the Arduino Board. Any capacity can be selected. The capacious the battery, the longer the robot drives but note that too capacious battery can be heavy. The capacity in the range of 800mAh to 1300mAh is optimal.

Miscellaneous:

  • 4 x Male-Female wire;
  • 4 x M3 spacer or Male-Female standoff with the 10mm length;
  • 3 x M3 spacer or Male-Female standoff with the 25mm length or more;
  • 4 x M3x8 countersunk flat head screw;
  • 1 x M3 Nylon screw;
  • 1 x M3 Nylon hex nut;
  • Any M3 screws and hex nuts.

For a classroom:

  • Magnetic whiteboard hanging on the wall;
  • Thick black magnetic Board markers;
  • Special LiPo battery charger or multiple chargers if you want to make many robots and charge them separately.

Step 2: How to Assemble? ​Assemble Chassis.

At first, you need to assemble miniQ chassis platform pre-replacing motors from the kit with more powerful ones with the 1:150 gear ratio. Do not forget to solder the wires to the motors contacts!

Step 3: How to Assemble? Install Magnets.

Install the magnets on the miniQ platform. Use M3x10 standoffs, M3x8 or M3x6 flat countersunk screws and M3 nuts. Required installation holes are shown in the picture.

That's important!

The length of the standoffs should be exactly 10 mm. After installing the magnets, test the platform on the whiteboard. All four magnets should be adjacent to the magnetic board and the rubber tires on the wheels of the miniQ platform should be preloaded and provide some friction with the board surface.

Manually move robot across the board. During the ride, the magnets should not come off the board. If any magnet comes off it means that the rubber tires on the wheels load maximally. In this case, increase the 10mm distance of all standoffs by 1 or 2 mm by adding a pair of M3 washers and try again.

Step 4: How to Assemble? ​Add Electronics.

Mount the Arduino UNO Board on the platform using M3x25 standoffs, M3 screws and M3 nuts. Do not use short standoffs, leave some space under the Arduino board for wires and battery.

Install the Motor shield on the Arduino UNO Board.

Install the Octoliner module. Press it against the platform using a nylon M3 screw and nut.

That's important!

Do not use metal fasteners to mount the Octoliner. Some mounting holes on the breakout board are soldered and used as IO pins. To prevent short circuits, use plastic fastener, for example, nylon.

Step 5: How to Assemble? Wiring.

Link all electronic components as shown in the diagram. The Octoliner module is connected via 4 wires (GND, 5V, SDA, SCL) to the Arduino UNO. Connect motors to the Motor shield. The LiPo battery is linked to the contact pads of the external power supply on the Motor shield as well as to the VIN pin on the Arduino board. Instead of using the VIN pin, you can use the 5.5 mm x 2.1 mm power plug on the board.

That's important!

When using the Motor shield no wires are needed. Two motor channels are controlled by 4 pins. 2 PWM pins are responsible for the speed of rotation while 2 DIR pins for the direction of rotation. Usually, they are already linked with specific Arduino Board pins and their index numbers may differ depending on the manufacturer of the shield. For example, for my Motor shield, numbers are D4 D5 (DIR and PWM for the first channel) and D7 D6 (DIR and PWM for the second channel). For the original Arduino Motor shield, pins numbers correspond to D12 D3 (DIR and PWM for the first channel) and D13 D11 (DIR and PWM for the second channel).

That's important!

Hobby LiPo batteries do not have a reverse polarity protection Board! Accidental shorting of the positive and negative contacts will result in permanent battery failure or fire.

Step 6: How to Program? XOD.

To make a program for such a racing robot is even easier than to assemble it.

In all my projects I use the XOD visual programming environment which allows me to create Arduino programs graphically without writing code. This environment is ideal for fast device prototyping or learning programming algorithms. Follow the XOD documentation web page to read more.

To program this robot, you need to add just one library amperka/octoliner into your XOD workspace. It is necessary for work with an eight-channel line sensor.

Step 7: How to Program? Patch.

The program is based on the principle of a PID-controller operation. If you want to know what the PID-controller is and how it works you can read another article on this topic.

Take a look at the patch with the robot program. Let's see what nodes are present on it and how it all works.

octoliner-line

It is a quick-start node from the amperka/octoliner XOD library which represents the Octoliner module tracking the line. It outputs the "line tracking value" which lays in the range of -1 to 1. The 0 value shows that the line is at the center position relative to the infrared sensors on the Octoliner board (between CH3 and CH4). The -1 value corresponds to the extreme left position (CH0) while the 1 to the extreme right (CH1). On boot node initializes the optocoupler sensors and sets up their default brightness and sensitivity parameters. The inputs for this node are the I2C address of the device (ADDR for the Octoliner board it is 0x1A) and the line tracking value update rate (UPD), I set it continuous.

The line tracking values are fed directly to the pid-controller node.

pid-controller

This node implementing the work of the PID-controller in XOD. The target (TARG) value for it is 0. It is the state when the line is exactly at the center under the robot. If the line tracking value is 0, the PID-controller resets via RST pin. If the line tracking value is different from 0, the PID-controller converts It using Kp, Ki, Kd coefficients into the motor speed values. The coefficients values were selected experimentally and equal to 1, 0.2 and 0.5, respectively. The update rate (UPD) of the PID-controller is set to continuous.

The processed value of the PID-controller is subtracted from the 1 and added to the 1. It is done to desynchronize motors, to make them rotate in opposite directions when the line is lost. The 1 value in these nodes represents the maximum speed of the motors. You can reduce the speed by entering the lower value.

h-bridge-dc-motor

A couple of these nodes are responsible for controlling left and right robot motors. Here set the PWM and DIR pin values through which your Motor shield operates.

Flash the patch and try your racing bot. If you exactly follow assembly instructions, you do not need to change the patch or adjust the PID-controller. The specified settings are quite optimal.

The finished program can be found in the library gabbapeople/whiteboard-races

Step 8: Showcase and Tips.

  • Use new or fresh black markers to draw a race track on the whiteboard. Try to make a thicker and contrasting line.
  • It is possible to use miniQ platform of different producers, for example, this one. Most analogs are interchangeable.
  • Make more than one robot! When there are a lot of them it's a little more fun!
STEM Contest

Participated in the
STEM Contest

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    8 Discussions

    0
    dulyanaastro02032004
    dulyanaastro02032004

    Question 2 months ago on Step 7

    What is actually the PID controller ? What is it in physical?Or is it just a way of definition to define the inputs from the line following octoliner module or is it the arduino?(In definition.)

    0
    dulyanaastro02032004
    dulyanaastro02032004

    Question 2 months ago on Step 1

    I'm a beginner to arduino and I know only a little about the electronic modules and sort of things such as sensors. Is there any other thing I can use instead of the 'octoliner' module?

    0
    wclapie
    wclapie

    Question 2 months ago on Step 8

    I am admittedly lost with the Arduino things. I have no idea how to program them. I see the boards/pages and go, "uh, nope". Is it easier than I think it is?

    0
    Antzy Carmasaic
    Antzy Carmasaic

    Answer 2 months ago

    Yes it is much easier. It is probably just the apprehension of jumping into something new and once you've tried it, it will seem trivial.
    Steps to program:
    1. Download and Install Arduino software (called Arduino IDE).
    2. Download the code(called a sketch).
    3. Connect Arduino to PC using USB cable.
    4. Select the model of your Arduino and its port. Usually just one option for port will come if a single device is connected.
    5. Click on upload, wait for it to finish, and you are done.

    There are plenty of tutorials online which you can follow for more help. If you try it out, you can message me for help.

    0
    danielgass
    danielgass

    2 months ago

    Superb idea and superb achievement. Well done.

    0
    gravityisweak
    gravityisweak

    Question 2 months ago

    Nice! What happens if one line crosses over another?

    0
    gabbapeople
    gabbapeople

    Answer 2 months ago

    When crossing the line pid-controller does its job.
    The direction of movement depends of the intersection angle.
    If the lines are at the right angles robot continues move forward.
    if they are not then the robot aims at a line with a lower angle to the route.

    By changing the angle you can make intersections or merge different lines in one.

    Some errors can occur due to line quality but It really works. Indeed, the video does not illustrate this moment, my bad.