Robotics is the exciting intersection of a number of engineering fields including mechanical engineering, electrical engineering, and computer science. This project was designed as the basis for a two-day workshop for high school age students to introduce them to engineering principles and giving them a jumping off point for exploring their interests further. There is something for everyone here, even if it is just for the art it creates.
What is Turtle Robot? The concept can be traced back to William Walter’s robotics work in the 1940s which investigated complex behaviors in simple systems. Turtle robots are generally slow moving with tight turning radiuses and can trace a design that shows their behavior over time. They make excellent teaching aides in that their programmed output can be seen visually. A number of programming languages have “Turtle Graphics” built in. Turtle graphics can also be used to investigate advanced topics like L-systems or affine geometry
What is Open Source? If you can look past licences and lawyers, Open Source is a philosophy that ideas should be shared, and if you use an idea you attribute the originator, and if you improve on it, you should share your improvement. Every part of this project, from the circuit board to the 3D designs, are available for study, replicating, and improving. Not only that, but it was designed and programmed used Open Source programs like Arduino and KiCad. All you would have to do is use a computer running Linux (an Open Source operating system) and print the parts on a RepRap based 3D printer (an Open Source project), and you would have Open Source Turtles All the Way Down. This project is certified as Open Source Hardware by the OSHWA.
This project is just the latest iteration of my “Low-Cost, Arduino Compatible Robot”, which in turn is based on the work of others (as indicated in the parts section). Improvements include a printed circuit board for ease of construction and robustness, infrared sensors for obstacle detection, and a more compact and stiff chassis for more accurate movement and lower printing cost. Rewiring port assignments and firmware improvements help remove stuttering caused by Arduino’s digialWrite() inefficiencies.
In keeping with the engineering fields we are exploring, this project is broken into three distinct sections:
- Electrical (EE: PCB assembly and testing),
- Mechanical (ME: chassis assembly), and
- Firmware (FW: calibration and programming).
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Electrical Engineering (EE): Parts
The current Bill of Materials is located at: https://github.com/aspro648/OSTR/. A number of components like resistors and capacitors are generic, so substitutions are acceptable. In general, the cost is about $60-80.
A kit for this project is available on Tindie.com. Purchasing the kit will save you the time and expense of ordering from several different vendors and avoid the minimum PCB order premium. You will also be helping me develop and share other projects in my workshops!
Step 2: EE: TLDR;
A well designed circuit should be "build-able" by an experienced hobbiest based on the bill of materials and the PCB silkscreen. For those of you who like to charge ahead, this graphic should be enough to get you past any quirks in the design.
For the rest of us mere mortals, follow along and I'll discuss assembly in detail.
Step 3: EE: Resistance Is Essential.
I like starting with the resistor because:
- They are relatively heat resistant while you are getting into your soldering groove and the iron is coming up to temp,
- They have no polarity, so orientation is not critical, and
- They are the lowest component on the board so sit tight when soldering when the board is flipped on it's back.
Since these are our first components, we'll cover them a little more in depth starting out. There are three pairs of different values:
- 10K ohm for sensors [brown - black - orange - gold]
- 330 ohm for LED current limiting [orange - orange -brown -gold]
- 100 ohm for IR current limiting [brown - black - brown - gold]
Check out www.resistorguide.com/resistor-color-code/ if you want to
learn more about reading resistor color codes.
You can do one at a time, or all six at once.
- Bend the leads to the width of the pads and insert the resistor.
- Flip the board over and heat both the pad and lead for about two seconds.
- Introduce solder, and maintain heat until the solder melts and flows around the pad.
- Remove the solder, and then the heat, in that order.
- If your solder gets stuck, just re-heat the joint.
- Trim the leads with flush cuts.
Step 4: EE: Eyes!
The front end of the robot contains two sets of devices for detecting and indicating obstacles, one for the left side, and one for right. From the outer edge working inward, we have an:
- IR Detector (black),
- IR Emitter (clear), and
- LED (colored).
They each have polarity, so must be put in the correct orientation. The long leg of the LED is the anode (positive), and goes in the pads marked "+". The others go with the lenses facing outward.
- Solder one lead of each component.
- Verify they are oriented and seated correctly.
- Trim the excess lead with flush-cut pliers.
Step 5: EE: Button
We have a single button to use for input. Match the holes with the leads and gently press them in. Solder them in place and clip the leads.
Step 6: EE: Darling Darlington
The single IC on the board is a Darlington array, which is used to control the power going to the motors. From the manufacture, IC pins are splayed slightly outward and need to be bent to 90 degrees to fit in the holes.
- Place the IC on a flat surface and bend each side inward gently.
- Match the divot on the end marking the side with pin one with the silk screen.
- Solder two pins in place and check the alignment. It becomes exponentially harder to fix after more than two pins are soldered.
- If you are ready to commit, solder the remaining pins in place.
Step 7: EE: Headers & Terminals
The two stepper motors are connected using the white JST headers. They have two slot on one side that face outward.
Power from the two battery holders are connected via the two black terminal headers. The openings face outward as well.
Step 8: Servo Header and Power Switch
We need a three pin male header to connect the servo. Insert it with the long legs up (either direction) and solder it in place.
The power switch can installed in either direction.
Step 9: EE: Capacitors
There are three capacitors of various capacities to help smooth power transients that occur while the motor signals switch on and off. The two larger black capacitors (1 uF and 10 uF) are electrolytic and have polarity. Like the LEDs, the long leg is positive, and there is a white strip on the body indicating negative.
The smaller capacitor (0.1 uF) is ceramic and has no polarity.
Step 10: EE: Brains
The Adafruit Trinket connects to the motor board via two 12-pin female headers. Solder them in place with the opening facing upward.
The Trinket comes with pin headers which are longer than needed:
- Cut both of them down to 12 positions.
- Place them in the female headers with the short side facing up.
- Place the Trinket on top of the headers with the USB facing outward, and solder the pin headers into the pads.
Step 11: Mechanical Engineering (ME): Parts
Time to switch gears from Electrical Engineering to Mechanical Engineering.
The required hardware is on the bill of materials (BOM): https://github.com/aspro648/OSTR/blob/master/BOM.md.
A current copy of printable STLs are located on Thingaverse. You will need:
- 1 Chassis
- 2 Wheels
- 1 Caster
- 1 Pen Collar
- 1 Nameplate (optional).
Again, a kit for this project is available on Tindie.com if you don't have access to 3D printing.
Step 12: ME: Chassis Prep
A "chassis" is the fame of a motor vehicle or other wheeled conveyance, and in this case the robot's chassis forms the platform for the electronics, motors, and servos.
Time to get familiar with your hardware. We will be using three different types of Phillips screws you will have to be able to identify:
- Pan Head Screw (M3 x 6 mm) -> Stepper motors to Chassis
- Flat Head Screw (M3 x 6 mm) -> Battery Holders to Chassis
- Round Head Thread-Forming Screw (#2 x 1/4") -> PCB to Chassis
In order to attach parts, we are going to embed M3 nuts into the chassis.
- Use an M3 round-head screw and tighten it to pull the nut into the pocket so it is seated flush.
- Remove the screw.
Step 13: ME: Batteries
Integrating the electrical components like motors and batteries with the chassis will fall into the ME's domain.
- Attach the battery holders using two M3 flat-head screws and thread the wires through the openings under the motor mounts.
- Put on your "EE" hat and attach the positive and negative wires to the terminals marked "+" and "-", one set of batteries for each terminal.
- Attach the circuit board to the chassis using #2x1/4 thread-forming screws.
- If the screws wont start, remove the PCB and use the tip of the screw driver to open them up a bit.
Step 14: ME: Servo
The servo is used to raise and lower the pen for drawing.
- Place the arm on the hub and gently rotate the stepper counter-clockwise looking down on it until it reaches the stop.
- Remove the arm and position it facing left (this will be the down position).
- Insert the small thread-forming screw and tighten.
- Insert the servo in the mount with the hub end upward and attach using two larger thread-forming screws.
Step 15: ME: Stepper Motors
Before we mount the stepper motors, check the fit of the wheels on the shaft. These should slid on fairly tightly if your printer is calibrated correctly.
- If they are too tight, use a jewelers file to open up clearance. You can also heat the hub with a hair drier, but do so sparingly to avoid warping the rim.
- If they are too loose, you can use an M3 round-head screw to hold the wheel to the shaft (after the motor is mounted).
We are going to pass the wires of the stepper (and servo) under the body to help with wire management.
- Start with the left side and thread the wires for the stepper (and servo) through the opening with wires coming from the stepper following down the back side.
- Insert the motor into the mount and attach with two M3 round-head screws and nuts.
- Gently pull the wires through.
Step 16: ME: Caster
The caster allows the robot to pivot with low friction.
- Gently press the bearing into the holder.
- If it is too tight, use a hair dryer to soften the plastic.
- Attach the caster to the chassis using M3 round-head screws.
Step 17: ME: Wheels
- Slip the o-ring into the rim groove and stretch it to snap in place.
- Gently press the wheel on to the stepper shaft as far as it will go.
- If the wheel is too loose on the shaft, thread a M3 round-head screw in the hub and tighten on the hub.
- You will have to ensure the battery wires remain clear of the screw as the wheel rotates.
Step 18: ME: Power
- Attach the stepper connectors to the terminal headers on the PCB.
- Fold and press the wires into the cavities between the headers and the steppers to keep them clear of the servo arm during operation.
- Insert the Adafruit Trinket Pro into the headers with the USB hub facing the edge and press into place.
- Ensure the power switch is set to off.
- Insert the batteries.
Step 19: Firmware (FW): Testing and Blinking
Time to add some code to our robot. We are using an Adafruit Trinket Pro (3V 12Mhz) which has the same microcontroller chip as the Arduino so we can use it's programming environment. In order to have Trinket board support, you need to add it to Arduino, or just download Adafruit's version. Follow the instructions here:
If you are using Windows, you will also need to install drivers from:
Launch your Arduino IDE and set the following:
- [Tools] -> [Programmer] -> "USBtinyISP"
- [Tools] -> [Board] -> "Pro Trinket 3V/12 Mhz (USB)"
Open my favorite test sketch:
- [File] -> [Examples] -> [01.Basic] -> "Blink".
- Change all pin designations "13" to "A4" (the robot's left LED).
- Use the check mark icon to verify the sketch compiles correctly.
- Attach the USB Micro cable to the Trinket USB port.
- Press the reset button on the Trinket board.
- Immediately press the upload icon on Arduino IDE.
Is your robot's LED blinking? Yes = YEAH! No = DONT PANIC!
- Double check the Arduino IDE settings for Programmer and Board above.
- Try the reset and upload sequence again. (The bootloader only looks for new code for several seconds before moving on to what is currently loaded.)
- Try ideas here: https://learn.adafruit.com/adafruit-arduino-ide-setup/troubleshooting
- Ask for help, either in the comments here or on the Adafruit forums.
Step 20: FW: Calibration
Because of variations in assembly and alignment, the robot must be calibrated so that it can move precised distances and angles.
- Measure the wheel diameter from the outer edges of the rubber o-ring.
- Measure the wheelbase from the center of the o-rings on the bottom of the robot (where it will contact the floor).
- Download from https://github.com/aspro648/OSTR/tree/master/firmware
- Enter your measured parameters.
- Upload the sketch as in the previous step.
Prepare the pen:
- Remove the cap and slide the pen collar from the tip side.
- Align collar with “C” in “Crayola”.
- Insert pen in holder with servo arm straight up.
- Ensure pen does not touch paper in this position.
- If the pen binds in the shaft, us a file to remove any roughness and increase the bore diameter.
Draw a square:
- Slide the power switch to "On".
- Wait several seconds for the bootloader to begin.
- After the robot completes it's first square, remove the pen and turn the robot off.
Adjust wheel_dia parameter first. Measure the length of side of the square. It should be 100 mm:
- If the measured distance is too long, increase wheel_dia.
- If the measured distance is too short, decrease wheel_dia.
After you have the distance calibration, adjust the wheel_base parameter which affects the angle of the turn. Place the robot on a fresh sheet of paper, turn it on and let it draw all four squares:
- If the robot is turning too sharply (box is rotating clockwise), decrease wheel_base value.
- If robot is not turning sharply enough (box is rotating counter-clockwise), increase wheel_base value.
- Because of rounding errors in the stepping code and slop in the gears of the inexpensive steppers, you will never get it perfect, so don't spend too much effort on it.
Step 21: Vision Check
Now that you have a calibrated turtle, let's look at how it's eyes work. There are lots ways for robots to detect their environment:
- Bump sensors (limit switches).
- IR emitter/detector pair
- Laser range finding
- Beacon detection
We are using IR because it is easy and inexpensive. The downside is that detection distance is short (several inches), varies by surface reflectance, and is subject to interference from other IR sources like the sun.
- Download and install the OSTR_eyes sketch from Github.
- Verify the left and right LED light when you hold your hand in front of the detector.
If you are not getting the desired response:
- Verify the "blink" sketch works or that the LEDs blink at the beging of the OSTR_eyes sketch.
- Use a phone or camera to observe the IR emitters are working.
If the indicators eyes remain on with no obstacle in front of them:
- It is possible that IR light is bleeding directly over to the detector. Place a piece of light-blocking material like dark plastic between them. If the light goes out, you have solved them problem. Trim the piece and use some hot glue to hold them in place.
Step 22: Trouble Shooting
This is a pretty complex project, and will likely give you fits at some point. I like to tell workshop participants that they need to have:
- Patience - Don't give up at your first failure.
- Persistence - You have to keep trying different things to solve problems.
- A Positive Attitude - You can do it!
If you are having trouble uploading sketches to the Trinket:
- Remove the Trinket from the Robot Driver Board.
- Double check the steps of "Firmware (FW): Testing and Blinking".
- Try ideas at https://learn.adafruit.com/adafruit-arduino-ide-se...
- Ask for help in the comments or Adafruit forums.
No power when on-switch turned on:
- Ensure you have fresh batteries.
- Ensure batteries installed correctly.
- Double-check battery connections to terminal blocks.
- Disconnect servo & steppers.
- Use a volt meter to verify voltage at terminal blocks.
Wheels do not move or stop moving during run for calibration step:
- Ensure you have fresh batteries installed correctly.
- Check white stepper connectors inserted fully.
- Ensure battery wires are not binding the wheels.
- Ensure steppers rotate by hand.
Robot turns the wrong direction:
- You have the left and right steppers plugged in to the opposite headers.
Pen doesn't leave a trace:
- Ensure pen is free in barrel and will drop below the wheel.
- Use a file to remove roughness and open barrel diameter.
- Ensure pen holder is at the proper level hold the pen up.
- Ensure servo points straight up during penup() command. If not, adjust PENUP angle in firmware.
Pen Too Loose:
- Verify your 3D printing parameters.
- Add some tape to the pen to increase the barrel diameter.
Step 23: Now What? Curriculum!
It works and draws nice squares and can detect walls. Now the fun begins.
Here are a couple of resources for learning turtle graphics.
- https://blockly-games.appspot.com/ (block programming)
- Code with Anna and Elsa from Hour of Code
For students, here are a couple of project ideas:
- Program your robot to write your name!
- Design and 3D print a nameplate in TinkerCad from a template. It can be attached below your servo motor.
- Give your robot some personality with some hot glue and bling. (Just keep the wheels and eyes clear of obstructions).
- From the OSTR_eyes sketch, design and test an algorithm to navigate a room. What do you do when one eye detects something. Both eyes? Could you incorporate Arduino's random() function.
- Construct a maze on a large sheet of paper on the floor and program your robot to navigate through it.
- Construct a maze with walls and design an algorithm to navigate it automatically.
- The button in between the LEDs hasn't been put to use yet, and is connected to Arduino pin "A3". What could it be used for? Use it to turn an LED on and off to start with.
- If you didn't do the Investigation section of the "Firmware (FW): Testing and Blinking" step, go back and give it a try.
Step 24: Workshop Ideas
Join the Turtle Robots forum to share your robot and teaching ideas!
Resources are always limited when doing workshops, so I've been breaking students into three groups and rotating them through three areas, each with a knowledgeable volunteer.
- Electrical: Soldering the PCB.
- Soldering irons, one for every two students so they can work in pairs.
- Flush cuts
- Safety glasses
- hot glue
- Laptops/computers, at least one for every two students so they can work in pairs.
- Rulers for calibration
- Pre-built robots for testing code if they haven't assembled their robot yet.
Safety with the electrical portion is important and should be discussed before starting. Safety glasses should be worn. I have a squirt bottle of water at the table for cooling burns (and wetting sponges). Here are a couple of the soldering videos I like to show:
If time allows, give them a challenge to accomplish like a maze (see the "What Now? Curriculum!" step.)
Step 25: Turtles in the Wild
I love seeing these robots out in the wild, especially when they have been modified in ways I would have never have thought. Here are a couple of notable examples, with hopefully more to come:
|Russ Hughes does workshops and has created a custom circuit board, uses Tiny Basic, and has implemented the Hersey Vector Font.|
|Instructable user seancuttlefish added both sonar and line following|
|An in the "where there is a will, there is a way" category, Samarsis created a version with no 3D printing!|
If you make a Turtle bot inspired from my examples, use the "I Made It!" button below, upload a picture, and make my day!
Second Prize in the