Tutorials

CanDo Line Following Robot

Why?

CanDo is a gentle introduction to robotics for anyone who’s just starting out with electronics or programming. It assembles in about 20 minutes and requires no soldering or wire stripping. Kits are $100.

Get a CanDo today!

Step by Step

Some arduino starter kits will teach you to turn on a light or move a motor and then expect you to figure out the rest by yourself. CanDo gives a bit more direction and a greater feeling of accomplishment, because when you will build your own robot. For those who still want to go even further, we offer this challenge: Can you improve on the CanDo to solve a maze?

Details

Each CanDo comes with all the parts you need to build your robot. Just add a 9v battery and you’re ready to go!

Read the assembly instructions and things to try on the Wiki

Tutorials

How to Build a Amazon Warehouse KIVA style robot with Mecanum Wheels

Amazon warehouse KIVA robots can roll forward, sideways, and turn on the spot thanks to special Mecanum wheels. A single wheel has many rollers on the outside edge, turned at a 45 degree angle. Here’s a short video example of what I mean.

What’s really odd about Mecanum wheels is that half turn one way and half turn the other to go in a straight line.

Each wheel is driven by a DC motor. Pairs of motors are connected to 2 channel motor drivers. The two 2-channel drivers are connected to an Arduino that listens for instructions from the pilot (me, in this case).

In 2015 I made an update to this model and put it on a laser cut frame.

ask me and I’ll draw a wiring diagram

Tutorials

How to convert SVG drawings for Makelangelo

So you want to prepare SVG drawings so they can be drawn on a Makelangelo.  Nice! Scaleable Vector Graphics (SVG) are an great way of storing images as lines because they can be made bigger or smaller without losing detail. Since the Makelangelo “thinks” in lines, they are a natural fit together.

Inkscape: create your art

Inkscape is a free vector drawing program that loads a ton of file formats, including Adobe Illustrator.  You can use it to turn a photo into line art or sketch something totally new. I used this picture of Darth Vader for this example. (Please support them to show your thanks.)

Darth Vector
Darth Vector

Inkscape: Ungroup

Select everything and choose Object > Ungroup. In some vector images you might have groups of groups of groups, so keep going until the Inkscape status bar says “N objects selected of type Path in root.” Fortunately this Darth Vader image is pretty simple and only needs one Ungroup command.

Inkscape: File > Save As > Desktop Cutting Plotter (AutoCAD DXF R14) (*.dxf)

This is another format well respected in the machining communities.  It is used by everything from Automatic quilting machines to CNC lasers to robot arms. Makelangelo software added support for DXF files in ~2014

Makelangelo: Convert > Open File

You should now see your picture on the screen. The picture will automatically fill the paper as much as it can.

Here you may discover a catch: SVG files can be made from many overlapping shapes, with junk hidden under the top-most layers. When you ungroup and save as DXF, the DXF file will have all the lines. The Makelangelo has no idea what lines are supposed to be on top, so you might need to clean up the vector file in Inkscape before you send it to the Makelangelo.

Makelangelo v7.2.9
Makelangelo v7.2.9

Makelangelo: Start

And that’s it! Much easier than pre-2014 when DXF files needed a lot of massaging.

So where do I get a Makelangelo?

Final thought

I’d really appreciate your feedback about this tutorial.  Please comment below with your questions and I’ll do everything I can to help.

Tutorials

Drawbot: Overview

The Makelangelo is a great way to start learning about robotics. It has two motors mounted at the top of a wall. The motors have bobbins wound with string. The strings are connected to a plotter, a tool that holds a pen. To draw lines the computer can control the motors, which pulls the strings and moves the pen.

But how does that actually work?

I’ll start with the motors, then the measurements, and then the math. After that you’ll have all the theory and we can start talking about what the Arduino computer does.

Motors

When you give power to a normal electric motor it spins as fast as it can. A lot of robotics involves stepper motors. They have a special design so that they only move one step each time they are told to, and only in the direction they are told to. I use NEMA17 stepper motors that have 400 steps per turn, or about 0.9 degrees per step. NEMA17 is a particular size. I have seen NEMA sizes from 8 all the way up to 34.

Measurements

Inverse Kinematics

I know how much string is reeled in or out at each step because I know the number of steps per turn and I know the circumference of the bobbin.

STEPS = 200;
DIAMETER = 0.9;  // cm
CIRCUMFERENCE = DIAMETER * PI;
TPS = CIRCUMFERENCE / STEPS;

I can use Pythagorus’ theorem to find the lengths of the strings because I have The distance between the motors (M1M2) and I know the position of the plotter (P) . If all of this was on a grid then I could say

function IK(P) {
  A = Px - M1x;  // same as V-M1 in the picture
  B = Py - M1y;  // same as P-V in the picture
  M1P = square_root(A*A+B*B);
  A = Px - M2x;  // same as V-M2 in the picture
  // B is the same
  M2P = square_root(A*A+B*B);

  return M1P,M2P;
}

In robotics this is known as Inverse Kinematics – when you know where you want to be and you calculate how to move the motors/muscles/etc in order to get there.

Forward Kinematics

There’s also Forward Kinematics, when you know how far the robot moved and you need to find out where the thing has gone to. For that I use the law of cosines.

function FK() {
  A = length( P-M1 );
  B = length( M1-M2 );
  C = length( P-M2 );
  Theta = arccos( ( A*A + B*B - C*C ) / ( 2*A*B ) );
  Px = cos( Theta ) * A*A + M1;
  Py = sin( Theta ) * A*A + M1;
}

So: If you can calculate the length of string at any point then you can find the difference – we can find the moment the string length needs to change while it is moving.

Linear Interpolation

Let’s pretend I’m moving M (me) from point H (here) to point T (there) in one second. At any moment I can describe my position as

M = ( T - H ) * S + H

At the start of the second S=0 and M=T. at the middle S=0.5 and M is halfway between here and there. At S=1 M=T (I have arrived there).

Putting it all together

If we combine this we get something like

function DrawLineTo(T) {
  start = IK( H );
  tstart = millis();
  loop {
    S = ( millis() - tstart ) * 0.001;
    now = IK( ( T - H ) * S + H );

    ChangeStringLengths(now,start);
  } while( S < 1 ); } function ChangeStringLengths( now, &start ) { if( now.MIP > start.MIP + TPS ) {  M1.Unwind();  start.M1P+=TPS;  }
  if( now.MIP < start.MIP - TPS ) { M1.WindUp(); start.M1P-=TPS; } if( now.M2P > start.M2P + TPS ) {  M2.Unwind();  start.M2P+=TPS;  }
  if( now.M2P < start.M2P - TPS ) {  M2.WindUp();  start.M2P-=TPS;  }
}

The rest, as they say, is details. Stepper motors can only turn so fast; the type of plotter used might change things; sometimes the now IK is more than two TPS from the current TPS; and so on.

I use a very similar technique for drawing arcs, or parts of circles. The only difference is that now I’m moving on a curve instead of a straight line.

Arduino code

Download the arduino code here. Almost all of the code has one job: to prevent user error. The rest is comments to explain my specific implementation.

Wait! What about the halftones?

Halftone() uses the line drawing code to fill in a square with a zigzag pattern. I tell halftone how big the square is, how thick the zigzag line is, and how much to fill in. It does the rest!

Can you put all these parts in a kit for me?

I’ve used timing belt and pulleys instead for greater precision, and written software to make it super easy to run.

Thanks for reading!

If you have any comments or questions about the robot, please feel free to post them below and I’ll be happy to answer.

Tutorials

How to Control a Linear Actuator with an H Bridge

Here’s an example:

Canakit h bridges are twice the price of Solarbotics. Lesson learned.

I find using Arduino analogWrite() on the output pins works much better than Servo::write().

Send me a message and I’ll update this post with more specifics.