Converting Xy plotter to drawing robot

Hi The other day I came across this instuctable about a drawing robot. From an earlier project I've got a robot which consists of 2 steppers and can move an object (for example a pen) in different directions. I think it would probably be as simple as uploading a different code to turn it into a drawing robot. But what sort of code do I need? Is there anything Online that I could use? I've obviously read the intractable but it seems to be using libraries specific for the design they used.

I have built a Polargraph and it really can't b easier. I would get the polargraph firmware and Processing app to get started. It is not hard to set up. I have the firmware loaded on a stand alone Uno board. My plotter is made with a piece of plywood, 2 stepper motors from, old disk drives, a couple of pieces of 3/4 inch dowel (the spools), a homemade gondola (pen holder), and a servo for pen lift. You can tune the firmware to fit the size of the board and placement of the motors so you can make any size you want (within limits). If you do build one and have questions, I will be happy to help.

The thing is , I haven't got the design with the gondolas I have something like this. Its a great intractable, it just doesn't give me the code for the drawing bit.

It would help if you explain what capability your existing plotter has. What can it do? How do you give it instructions? What Arduino board has it got? What type of stepper motor drivers?

If you are content (at least to start with) with monochrome images you could easily use a Python (for example) program to extract start and stop coordinates and penUp/penDown instructions from a 2-colour photo - I.e. black and white with no grey.

That polargraph device looks very interesting - especially its size capability.

...R

The thing is a blast to play with. The Processing program that can be used to run the plotter does translations to plot bitmap files and SVG vector files. The firmware takes simple serial commands to control it. If you take care to set up the plot area in the firmware it is pretty accurate and repeatable. I have used with a temperature sensor coupled to a Uno to plot temperature vs time like an old circular plotter. Plot the circular chart and then record temps for 12 hours. I am currently working on a pen change mech to plot 4 colors. Using a Tiny85 to intercept the pen up, pen down and pen change commands and control the pen lift servo.

A few questions/comments about the Polargraph …

I notice that the drawings seem to be on circular arcs with one of the motors as the arc centre which means that the lines (but not the complete image) are “upset” relative to the paper.
I presume you could counter that by pinning the paper on at a different angle ?

I presume it could be programmed to move the pen along straight lines?

Have you considered using thicker pens for greater covering capacity?

…R

I presume it could be programmed to move the pen along straight lines?

Yes, very straight (I was surprised how straight) lines by doing a lot of small movements but still pretty fast. Circles are done by plotting a polygon with lots of sides.

Have you considered using thicker pens for greater covering capacity?

You can adjust for the for the pen width in the software for doing shading. Shading is done by drawing lines closer together for dark and with more white between for lighter. So, you can use a wider pen and not draw as many lines.

bestanamnetnogonsin:
I’ve obviously read the intractable but …

intractable
Ha ha the best name for that crap site. :smiley: :smiley: :smiley:

intractable
ɪnˈtraktəb(ə)l/
adjective
adjective: intractable

hard to control or deal with.
“intractable economic problems”
synonyms: unmanageable, uncontrollable, ungovernable, out of control, out of hand, impossible to cope with; difficult, awkward, complex, troublesome, demanding, burdensome
“their problems have become more acute and intractable”

Robin2: 1) It would help if you explain what capability your existing plotter has. What can it do?

2) How do you give it instructions?

3) What Arduino board has it got?

4) What type of stepper motor drivers?

If you are content (at least to start with) with monochrome images you could easily use a Python (for example) program to extract start and stop coordinates and penUp/penDown instructions from a 2-colour photo - I.e. black and white with no grey.

That polargraph device looks very interesting - especially its size capability.

...R

1) Right now its a chess playing robot, which has one stepper moving the x-axis, and one moving the y-axis. It uses a servo to raise and lower a magnet to pull the pieces along, which could easily be replaced with for example a pen.

2) I'm not sure what you mean by this... The chess playing robot gets instructed with serial commands, but this is just for the chess playing robots program. I would naturally use a different program for the drawing robot, so this leaves it open to use whatever type of instructions you want.

3) It uses an Arduino DUE. (and later the due might also be connected to a uno)

4)It uses the adafruit motor shield v2.3. I'm not sure, but this may or may not cause problems, as it uses its own library. If it's important: The command for moving a stepper looks like this:

myMotor->step(100, FORWARD, DOUBLE);

where 100 is the number of steps, FORWRD the direction, and DOUBLE is the stepping style (which in this case will always be double I guess).

I should look into getting the motor moving processor to accept Gcode. This is simple and you can implement as much or little as you like. Look at the Rep Rap forums for example code using an Arduino.

I have no experience with a DUE and I don’t know to what extent it is compatible with, say, an Uno or Mega.

I had in mind that you would use a PC program to figure out the moves needed to draw a picture and send appropriate serial data to the Arduino which you then use the myMotor->step(100, FORWARD, DOUBLE); instructions to make the pen draw the picture.

Imagine, for example, that the PC sends the command “<D,10,200>” which means put the pen Down and move 10 steps on the X axis and 200 steps on the Y axis. I’m not convinced that GCode adds any value in this situation because you are never likely to write image drawing code by hand - or need to be able to read it.

The examples in serial input basics show how data can be received by the Arduino.

You may find something useful in stepper motor basics but it is not written for motor shields.

…R

What sort of program? something like processing or so? The thing is, I haven't got a lot of experience with programs like python or processing, and I suspect that making the code might just be a bit complicated...

I'm not convinced that GCode adds any value in this situation because you are never likely to write image drawing code by hand - or need to be able to read it.

The point is that many drawing packages support Gcode. For example inkscape has a Gcode output to drawings.

What sort of program? something like processing or so?

Yes you need something to feed the arduino with instructions. I wrote a processing driver here:- http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html

and I suspect that making the code might just be a bit complicated...

It is quite straight forward you just have to read a file and send it out the serial port.

Alternatively you could use the Eggbot language, I saw a drawing robot at the Newcastle Maker Faire two weeks ago that did that. Again drawing packages sometimes have Eggbot extensions.

Ok so I have a Program, I give it an Image and the program turns it to an image consisting only of lines, then converts the lines into xy commands which it sends to the serial port of the arduino. The arduino then reads it and moves the steppers accordingly. Have I understood this correctly?

Have I understood this correctly?

No.

No one has said anything about turning a bit mapped image into a vector image. (an image consisting only of lines). These drawing packages work with you drawing a picture with vector elements.

The rest is right.

So I need to give the program a vector image? Is there a way you can convert a normal image into a vector image? (maybe with a different programm?)

Is there a way you can convert a normal image into a vector image?

There is but it is not always satisfactory. There are two ways:- 1) Using edge detection techniques to pick out lines. 2) Using rasterization where the pen makes a zig zag path and then the pen lifts or deflects according to the value in the grey scale image.

(maybe with a different programm?)

Yes. These are sometimes included in vector drawing packages but not always.

See the software component of this project:- http://makezine.com/projects/trs-drawbot/

I have in mind that you use a program (the Python PIL library is very good) to convert the BMP (or JPG) image into an array. Then you just need to scan the array row by row. If the elements in the array are black tell the Arduino to draw with the pen down. If the elements are white, draw with the pen up. It would be easy for the program to scan forwards along a row when (say) it detects a black element until it finds the last contiguous black element. Then it can instruct the plotter to draw with pen Down for that distance.

It would probaly make life easier if you scale the image so it matches the coordinate size of your plotter. That could also be done with the PIL library, or with an image manipulation program such as GIMP.

With all due respect to the GCode fans, this is very simple stuff without GCode. Even for the GCode devotees it seems to make more sense to "decode" the GCode on the PC to keep the Arduino code as simple as possible.

...R

In what way was that different than the method 2) I described?

this is very simple stuff without GCode.

It is virtually identical to Gcode.

Grumpy_Mike: In what way was that different than the method 2) I described?

It is virtually identical to Gcode.

I'm not quite sure what you mean by "method 2" but I had the impression from Reply #14 "No one has said anything about turning a bit mapped image into a vector image" that you were talking only about drawing from vector images.

It is different from GCode to the extent that GCode has to be interpreted and actual coordinates for stepper moves do not.

...R