With the educator's road test materials I thought the best place to start would be to setup the Parallax robot shield with an Arduino. There are no instructions which come with the package, instead you need to go the the Parallax website and then the Robot Shield with Arduno learning section which can be found via this link:
Robotics with the Board of Education Shield for Arduino | learn.parallax.com
In the past I had seen the Parallax robot shield online but never considered buying it because I thought it would be too "easy" and not fascinating enough to buy a completed robot rather than build one from scratch. However, when I downloaded the PDF file found on the Parallax robot site (at the link above) I was pleasantly surprised to see that the guide was not only for set up instructions but also a full curriculum of exercises and studies you could run in the classroom. The PDF supporting material allows you to learn not only about robotics and sensors but also the basics of Arduino programming. Furthermore, at the end of each chapter there are exercises a learner can undertake with question and answer sections which could be used as a graded/evaluative component in a class. From the Parallax website you can also get a file of all the Arduino code mentioned throughout the PDF support material which means you can save a bunch of time by not having to retype the examples into the Arduino IDE.
Here is a picture me testing out the function of the robot shield (with the Arduino Uno attached) by getting two LEDs (provided in the kit) to light up:
When you setup the robot for the first time you'll need to calibrate the servo motors by centering them. What this means is tightening a screw at the base of the servos so they do not rotate once a pulse width modulation signals (PWM) threshold is reached. The PDF file with the robotics kit outlines what pulse width modulation signals are so no worries if you don't know what this is in the first place. When you program the motors with a PWM value of 1500 you'll want the wheels to be completely still and this is why you have to use a screw driver to adjust the subtleties of movement.
When you want to the Servo motors to run in a forward direction you'd set PWM signals in your code to run at 1300 and then backwards you'd set PWM signals to 1700. Easy pesy! Here is a video of me testing out code to run a wheel backwards and forwards according to PWM signals:
This is the Arduino code provided by Parallax which caused the movement above. It will give a sense of what Arduino code looks like too:
/* * Robotics with the BOE Shield - RightServoTest * Right servo turns clockwise three seconds, stops 1 second, then * counterclockwise three seconds. */ #include <Servo.h> // Include servo library Servo servoRight; // Declare right servo void setup() // Built in initialization block { servoRight.attach(12); // Attach right signal to P12 servoRight.writeMicroseconds(1300); // Right wheel clockwise delay(3000); // ...for 3 seconds servoRight.writeMicroseconds(1500); // Stay still delay(1000); // ...for 3 seconds servoRight.writeMicroseconds(1700); // Right wheel counterclockwise delay(3000); // ...for 3 seconds servoRight.writeMicroseconds(1500); // Right wheel counterclockwise } void loop() // Main loop auto-repeats { // Empty, nothing needs repeating }
After centering the servos to stay still at 1500 PWM you'll mount the motors to the chassis along with a battery pack for when you want to run your robot without tethering it to a computer by a USB cable. Here is what the completed robot looks like:
Another activity you'll undertake early on is set up a Piezo speaker so you'll hear a sound every time the robot is turned on and also when it begins to run out of batteries. Here is a video of me testing out the Piezo on the Parallax robot with the code posted below:
/* * Robotics with the BOE Shield - StartResetIndicator * Test the piezospeaker circuit. */ void setup() // Built in initialization block { Serial.begin(9600); Serial.println("Beep!"); tone(4, 3000, 1000); // Play tone for 1 second delay(1000); // Delay to finish tone } void loop() // Main loop auto-repeats { Serial.println("Waiting for reset..."); delay(1000); }
Let's get into the sensor functions you'll run with the Parallax robot; I'm going to focus on two specifically, which are the bump sensing with the "whiskers" and also the proximity sensing setup which can be used for edge detection. There is an earlier activity you can do with the Parallax robot which involves light sensing so the bot will drive to an area where there is intense lighting but I did not document this in pictures or videos.
All the sensors described are provided with the Parallax robot kit which is a convenient benefit to buying a robotics kit in the first place.
Bump Sensor using "Whiskers":
The "whiskers" are two pieces of flexible metal which protrude from the front of the robot. They are easy to install by using the mini screw driver provided by Parallax. They work by closing a circuit when bumped so a digital pin on the Arduino reads a 0 as opposed to a 1. You can use this in your code by telling the robot to do a series of movements whenever the right, left or both whiskers are hit. In the video posted at the end of this blog you can see the whiskers in action and they are quite fun to play with. Originally I wanted to leave the whiskers on the robot along with all the other sensor attachments but I found that they got in the way. One of the constraints is that the mini bread board at the front of the robot doesn't give you much room for working with multiple sensors.
Infrared Proximity Setup and Edge Detection:
Infrared LEDs are attached to the front of the robot and are paired with an Infrared (IR) receiver behind them. The light from the Infrared LED which when it hits a surface reflects the signal back behind it to be "caught" by the IR receiver; there is one on the left and right side of the robot. This rebounding of light, in turn, influences a programmed 0 or 1 signal output on a digital input pin. Note that the proximity sensor setup will not read actual distance even though the Parallax robot PDF provides an activity for calibrating measurements via trial and error. Element14.com did provide a Sharp Infrared Distance sensor which can output a measure of distance but this sensor did not come with any type of wiring cable so I was not able to use this on my robot yet.The video below shows me testing out the IR receivers in conjunction with the piezo speakers. When an IR signal is sent from my remote it causes the piezo to fire off a sound; this code is helpful too for figuring out if there is any IR interference in the area:
You can turn the proximity sensor setup used for obstacle avoidance into edge detection by angling the IR sensors downwards along with the receivers. Once the robot comes close to an edge the IR signal is not sensed because the IR LED's light has nothing to reflect off of. In code, you can translate the IR signal being their or not into movement to back away from the edge or turn left or right. The angling of the proximity sensors is quite finicky and you'll find that you have to continually adjust them to achieve edge detection. Make sure you are prepared to catch your robot in case it drives over the edge during initial trials!
In a nut shell these are the basics of what you can achieve with the robotics kit and I am very impressed with the generous offering of sensors and support materials by Parallax. I highly recommend this robotics kit to educators in the classroom. If I had more resources as a teacher I'd get a bunch of these for the students in my programming classes as the supporting material would streamline my preparations and students would find the evolution of their robot through each activity engaging.
My next blog will focus on my initial trials with MATLAB and SIMULINK but I can say right now that the software is awesome to work with. Here is a short video I edited of the Parallax robot for your enjoyment:
Top Comments
Nice detailed post.
Thanks
DAB