G-Code-Arduino-Library

https://github.com/tinkersprojects/G-Code-Arduino-Libraryhttps://github.com/tinkersprojects/G-Code-Arduino-Libraryhttps://github.com/tinkersprojects/G-Code-Arduino-Library

This is a library that allows any machine or robot to be controlled by G-Code

What is G-Code?

G-Code is the instructions that 3D Printer and CNC used to create there part. G-Code is a set of instruction commands sent to the controller of the machine to be performed. Position, feed rate, and tool used are some of the items that G-Code can control. The G-Code can either be sent from the computer or saved on an SD card.

Why make this library?

This library allows any machine or robot to be controlled by G-Code. It makes it quick and easy to set up with CNC and machine software and gives much better control over the communications and commands.

Why use this?

If your project requires computer control or a set of instruction, a library like this will help simplify this process of making it your self.

Functions

SETUP

gcode(),
gcode(void (*CallBack)()),
gcode(int numbercommands, commandscallback *commandArray),
gcode(int numbercommands, commandscallback *commandArray, void (*CallBack)());
This Function is used to declare this class so that it can be used in the program. There are 4 different functions, each with variables that can be set. The callback is used to link a call back function used after each command is available. commandArray is an array of callback that interupt the program to execute the command. Numbercommands is the number of items within commandArray.

void begin(),
void begin(int bitrate)
This Function must be called if the serial interface is wanting to be used. Bitrate is the bitrate of the serial port. If this is called, there is no need to Serial.begin();, it is apart of the begin function.

SEND

void comment(String comment)
This Function is to send comments back through the serial. Comment would be the comment that would be sent back.

RECEIVE

bool available(),
bool available(char inChar)
This function reads the incoming data and returns true then the command is ready to for the program to read an control the machine. InChar is the input from a source like an SD card.

double GetValue(char commandLetter)
This function is to return the values for a command letter. CommandLetter is the command letter that is requested to be returned.

Code for Project

GNU General Public License v3.0

#include <gcode.h>

#define LEDpin 13
#define NumberOfCommands 2

void homing();
commandscallback commands[NumberOfCommands] = {{"L1",OnLED},{"L2",OffLED}};
gcode Commands(NumberOfCommands,commands);

void setup()
{
  Commands.begin();
  pinMode(LEDpin, OUTPUT);
}

void loop() 
{
  Commands.available();
}

void OnLED()
{
  digitalWrite(LEDpin, HIGH);
}

void OffLED()
{
  digitalWrite(LEDpin, LOW);
}

Code for Project

GNU General Public License v3.0

#include <gcode.h>

#define LEDpin 13
#define NumberOfCommands 2

void homing();
commandscallback commands[NumberOfCommands] = {{"L1",OnLED},{"L2",OffLED}};
gcode Commands(NumberOfCommands,commands);

void setup()
{
  Commands.begin();
  pinMode(LEDpin, OUTPUT);
}

void loop() 
{
  Commands.available();
}

void OnLED()
{
  digitalWrite(LEDpin, HIGH);
}

void OffLED()
{
  digitalWrite(LEDpin, LOW);
}

Code for Project

GNU General Public License v3.0

#include <gcode.h>

#define LEDpin 13
#define NumberOfCommands 2

void homing();
commandscallback commands[NumberOfCommands] = {{"L1",OnLED},{"L2",OffLED}};
gcode Commands(NumberOfCommands,commands);

void setup()
{
  Commands.begin();
  pinMode(LEDpin, OUTPUT);
}

void loop() 
{
  Commands.available();
}

void OnLED()
{
  digitalWrite(LEDpin, HIGH);
}

void OffLED()
{
  digitalWrite(LEDpin, LOW);
}

Related Projects

Programable Reflow Oven

Programable Reflow Oven

After making the reflow oven, I wanted to make the oven more universal. An oven can e a help tool for heating, curing and drying. The first setup just had one program that could be adjusted within limits. The controller had a temperature profile programmed into it and the user could change the temperature and the duration time at that temperature. Each setting had limits. Once the …
Read more


CNC Plasma Cutter

CNC Plasma Cutter

I have wanted a plasma cutter for a while and instead of buying one I decided to make one. The 2D plotter machine did not take too long to make and has been sitting around for about a year while I was getting all other parts required for cutting. I did not have trouble getting the plasma cutting head/nozzle but have many problems getting the right hoses. After getting the correct parts can …
Read more


Latest Projects

Popular Projects