Go Down

Topic: how do I control a stepper with g code (Read 9127 times) previous topic - next topic

matelot

I have been looking at various addresses on the internet trying to find a simple piece of code to run a stepper using grbl and g-code.
The nearest I can get is here
It says 'From here, you can simply start sending Grbl some G-code commands, and it'll perform them for you'
I can use the monitor and send a single command  eg  x20,  but I have no idea how to write the information into a program.
Would someone mind just giving me a start? a simple sketch that I could experiment with that allows me to add instructions to move the stepper?
thanks.

Robin2

I have not used GRBL but as far as I know it expects to get a sequence of GCode instructions from somewhere. I think it can read them from a file on an SD Card or receive them via Serial from a file on a PC. The PC would need to have a program to read the file and send the instuctions. AFAIK there is a program called GCodeSender or similar.

You can create a GCode file with any text editor.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

matelot

#2
Apr 25, 2016, 11:21 pm Last Edit: Apr 25, 2016, 11:22 pm by matelot
I have found one called gcode_interpreter here but it is a rar file, I have never been able to open rar files?
Would it then have to be opened on the pc and send information from there?


jremington

Use 7-zip to decompress it, as I did (attached as .zip file)

Robin2

but it is a rar file,
When you come up against that sort of problem Google is your friend.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

matelot

does anyone have any experience with the gcode_interpreterdc found here
I can get it to load and look as if it is working with a h bridge like this but no movement from the motor.
The motor works using similar instructions and the grbl program installed so it is not a controller/motor fault.
The interpreterdc calls for signals from the end stops but I don't have those yet, I have put signals on the pins that read the end stops, both 0v and 5 v but no change.
thanks

nathancamp

Grbl works pretty well.  I've installed v0.9 on an uno for the CNC router I'm building.

To move the X motor you need to send a G01 X20 F100 to move the motor 20 units at a feed rate of 100, Where G01 is a move command, x is the distance to move in mm or inches depending, and F is the federate.

Grbl setup converts the 20 to the number of units to the number of pulses.

You can use the serial window to send the g code commands, or you can download one of the g code senders that are linked to on the grbl site.

Using Grbl, you do not embed the movement into the program, it acts as a interpreter to convert the g code to machine movements.

Generation of the g code can be manual or from CAD/CAM software.  I've even seen a g code generator for ink scape.

If you want a good example of interpreting g code without grbl. take a look at:

https://www.marginallyclever.com/2013/08/how-to-build-an-2-axis-arduino-cnc-gcode-interpreter/

matelot

I have grbl 0.9 in my arduino connected to a servo via a controller like this one
If I put x20 into the monitor the stepper moves. That is perfect.
What I now want is to be able to give it a list of instructions that can be repeated from somewhere?
I have put an interpreter from here into the arduino and the information on the monitor looks good but when I enter x20 into the monitor nothing happens, the monitor says 'ok' but the motor doesn't move. I have moved the control pins to the ones named in the program but it also talks about endstops and execute commands but doesn't say where they should be.

I would be happy to use the grbl 0.9 but I assume I have to send the information (g code) from somewhere but how?

matelot

one of the choices in the grbl website is a program called Easel, if I click on it I get a drawing program that I have played a little with but can't find any way of being able to send the info to the arduino?
Do you use a different program? which one? how do you send info?
thanks.

Henradrie

Try searching for shapoko, those guys run G code to an uno to control a CNC machine. Chances are they have this figured out.

matelot

the only thing I could find on the shapeoko web site was this

"plug the machine into the computer on which you've installed your choice of Communication / Control software (note that even if you're not using the Carbide Motion Machine Control Software you may need to install it so as to provide driver support)"

nothing about  arduinos?

nathancamp

I'm using the Universal G Code Sender.  It is a java based program.  Here is the link:

https://github.com/winder/Universal-G-Code-Sender/releases/tag/v1.0.9

matelot

sorry for the late reply.
That is exactly what I am wanting.
I have been playing with it and writing small programmes in notepad that work.
I only have one stepper connected at the moment but now I know I can run steppers I will look at building something like this .
The next step is to find somewhere that gives a run down of the simple instructions of c gode with examples.
Thank you.

MarkT

The internet knows everything about G-code, and the many many variants.  Its a horrid ancient
thing (1950's I think initially), and is as clunky as it gets.

Unsurprizingly its reasonable to start here: https://en.wikipedia.org/wiki/G-code
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Robin2

That is exactly what I am wanting.
I got very close to it in Reply #1 :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up