Can I generate several different Gcode from Arduino Uno To Arduino Uno with CNC Shileld?

So I have already made a Cartesian robot that can move in 3 Axis X, Y, and Z.
To move the robot I use Gcode sender from my Laptop.
The question is can I generate the Gcode from Another Arduino to the Arduino with CNC Shield?
So I don't use my laptop anymore to send the Gcode

try a web search for arduino Gcode
you may need more memory and power than a UNO - a mega or ESP32?
if you need more power search for raspberry pi Gcode

Are you using grbl on the CNC Arduino? If so interfacing with grbl may be of interest to write a gcode sender for the sending Arduino.

If not using grbl, how are you translating gcode to stepper motions?

Is the gcode on the second Arduino coming from an SD card or something or is the gcode actually generated by the second Arduino on the fly?

1 Like

Yes I do use GRBL. Usually I use Gcode sender with my laptop to send my Gcode to GRBL. I want to send Gcode from another Arduino so I dont use my laptop anymore. There are only 4 different Gcode(based on input given A,B,C, or D) that I want to sent to the GRBL. Can I use another Arduino instead of my laptop to send the Gcode?

You will need to use a hardware serial port on both the sender and receiver as grbl uses 115200 baud rate.

The Interfacing grbl link tells you how to send the gcode.

1 Like

So I try to communicate the 2 Arduinos. 1 as sender and the other 1 as receiver(connected with CNC shield)

For the sender I try simple code like this

char mystr[5] = "abcde"; 

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.write(mystr,5); //
  delay(1000);
}

and it can be uploaded easily.

While for the receiver I alter the grblupload

/***********************************************************************
This sketch compiles and uploads Grbl to your 328p-based Arduino! 

To use:
- First make sure you have imported Grbl source code into your Arduino
  IDE. There are details on our Github website on how to do this.

- Select your Arduino Board and Serial Port in the Tools drop-down menu.
  NOTE: Grbl only officially supports 328p-based Arduinos, like the Uno.
  Using other boards will likely not work!

- Then just click 'Upload'. That's it!

For advanced users:
  If you'd like to see what else Grbl can do, there are some additional
  options for customization and features you can enable or disable. 
  Navigate your file system to where the Arduino IDE has stored the Grbl 
  source code files, open the 'config.h' file in your favorite text 
  editor. Inside are dozens of feature descriptions and #defines. Simply
  comment or uncomment the #defines or alter their assigned values, save
  your changes, and then click 'Upload' here. 

Copyright (c) 2015 Sungeun K. Jeon
Released under the MIT-license. See license.txt for details.
***********************************************************************/

#include <grbl.h>
char mystr[10]; //Initialized variable to store recieved data

void setup() {
 
  Serial.begin(115200);
}

void loop() {
  Serial.readBytes(mystr,5); //Read the serial data and store in var
  Serial.println(mystr); //Print data on Serial Monitor
  delay(1000);
}

// Do not alter this file!

and it can't be uploaded. I know the original grblupload 'do not alter this file'.

What should I do so the 2 Arduinos can communicate each other while I can't alter the grblupload? Or there is a way to alter the grblupload?

I have no idea why you would want to modify grblupload. That will do you no good. Put grbl on the controller Uno (the one with the CNC shield) in the normal manner and send the gcode from the second Uno via the hardware serial port. Use the methods from the interfacing grbl page that I linked to send the gcode from the second Uno to the controller Uno.

In an informatic project you have to be very precise in your descriptions.
You are using the word "upload" in a way where I assume (=not beeing sure) you mean

sending data over a serial interface where the data is received by a arduino-C++-sketch.

Usually the word "upload" is used for transferring the compiled code into the flash-memory of the microcontroller.

Of course this transferring the compiled code into the flash-memory of the microcontroller is done by the same serial interface but is a very different category of data-transfer.

The usual word for

sending data over a serial interface where the data is received by a arduino-C++-sketch.

is sending serial data.

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.