2D Plotter Code

Hey Guys,

So im in a group trying to create a 2D plotter (x,y), and we have the hardware part figured out. But we have a certain issue when it comes to the software of the project, since what we want is kinda different from the usual 2D plotter we found online, they mostly use either inkScape with G-code and Arduino or GRBL and G-Code with Arduino.

Now these methods according to what i know, need to have a ready drawing, that is then imported to create the G-Code that the Arduino will later on use. However, what me and my friends are trying to create is a plotter that receives its input on the spot, with a drawing area of 300mmx300mm, meaning a user will pick his/her coordinates that they want the machine to draw (also i forgot to mention that our project mainly focuses on drawing points, not full drawings yet, hence the coordinates part).

i would like to know if there is any way we can create a code that can generate the G-code for the Arduino after the coordinates are inserted. or if there is any alternative to this method. Please Share your knowledge… anything would help :smiley:

RInmori:
Hey Guys,

So im in a group trying to create a 2D plotter (x,y), and we have the hardware part figured out. But we have a certain issue when it comes to the software of the project, since what we want is kinda different from the usual 2D plotter we found online, they mostly use either inkScape with G-code and Arduino or GRBL and G-Code with Arduino.

Now these methods according to what i know, need to have a ready drawing, that is then imported to create the G-Code that the Arduino will later on use. However, what me and my friends are trying to create is a plotter that receives its input on the spot, with a drawing area of 300mmx300mm, meaning a user will pick his/her coordinates that they want the machine to draw (also i forgot to mention that our project mainly focuses on drawing points, not full drawings yet, hence the coordinates part).

i would like to know if there is any way we can create a code that can generate the G-code for the Arduino after the coordinates are inserted. or if there is any alternative to this method. Please Share your knowledge.. anything would help :smiley:

I am confused a bit by your rambling description. You want a 2D plotter, but yet you want to draw points. How do you do that without 3D?

Do you realize there is the ability to send G-code a line at a time from the IDE to your program?

I suggest you begin to make a list of the necessary G-code instructions you want to be able to process and then learn how to write an interpreter to execute them.

Paul

Tell us all about your plotter hardware.

The usual approach to online 2D plotting is to write functions such as

line(x0,y0,x1,y1);  //draw a line from (x0,y0) to (x1,y1)
point(x0,y0); //put a point at (x0,y0);

Hint: for an integer plotter grid, the Bresenham algorithm is universally used to draw lines.

jremington:
Tell us all about your plotter hardware.

The usual approach to online 2D plotting is to write functions such as

line(x0,y0,x1,y1);  //draw a line from (x0,y0) to (x1,y1)

point(x0,y0); //put a point at (x0,y0);




Hint: for an integer plotter grid, the [Bresenham algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm) is universally used to draw lines.

Hey jremington, thanks for the reply. Our plotter isnt an online plotter, its a real prototype. We have the motors attached, but we dont really know how to integrate g-code and arduino to use them yet.

also our task is very simple, we just want to draw points on a sheet of paper. the user is supposed to enter coordinates of the points.

Confused, are you running a g code compatible motor shield or not?

Why do you insist in using G code, instead of e.g. HPPL?

A point is easy to draw: drive to the requested X and Y position, then lower and raise the pen.

For drawing a line you can use the Bresenham algorithm, similar for circles (see Wikipedia).

online plotter, its a real prototype

I was referring to a real plotter, connected to a computer, and you need to write those functions.

Why have you not described the plotter and its connection to the computer?

“also our task is very simple, we just want to draw points on a sheet of paper. the user is supposed to enter coordinates of the points.”

The rest of the world think “points” are spots or dots at specific locations on the sheet of paper.

What do you think “points” are?

Paul

It is not at all clear if your plotter is receiving Gcode or your plotter is simply the Arduino driving the motors and you just want to type in the coordinates and then have the motors move to that point drop the pen and lift it back again.

If it is the latter then that is simple enough, you just have to have a calibration value that you use to multiply the input coordinations by to get the number of steps you need to reach that point and make the motor move that number of steps. Keep a running total which indicates your current position and subtract this from the position you are at to get the number of steps to move. Note the sign of this number tells you what direction to go in.