1
$\begingroup$

In cnc machine, programs change G-code to commands to stepper motors using parallel port.

I want to know what is the G-code and how can it be converted to stepper motor commands?

The programs doing this are not open-source, So can I find open source project doing the same?

$\endgroup$
4
$\begingroup$

LinuxCNC is an open source project dedicated to "converting" G-code into motor commands. It is not at all a simple task.

The basic steps are:

  1. Read the G-Code file into memory
  2. Interpret the G code (mostly motion commands and way points, but also branches and loops)
  3. Plan a continoupous path between the waypoints
  4. Add the time dimention to your path (velocities and accelerations)
  5. Project values to your motor axis
  6. Make your motor controller follow the reference trajectory (this is the part which is heavily dependent on your motors and motor driver, in your ase the stepper motor with parallel port)

On driving a setpper motor with your paralel port (once you know what is the desired trajectory of your motor) information can be found here and here

$\endgroup$
2
$\begingroup$

LinuxCNC is a good example. A simpler example would be GRBL, which runs on Arduinos:

https://github.com/grbl/grbl/wiki

$\endgroup$
1
$\begingroup$

I suggest you look at the Marlin firmware for reprap 3d printers. Essentially it parses out lines of CNC code and identifies each of them as a command. The trickiest of these are the mutli-axis coordinated movements where multiple steppers are involved such as g3/g4 circle interpolate. The magic is in the timers and trig.

$\endgroup$
  • $\begingroup$ Awesome , I will see it $\endgroup$ – Ammar Atef Nov 11 '16 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.