LCD on GRBL

Overview


The system shows, on an LCD display, the informations of a GRBL system. It displays the X, Y, and Z axis in working and machine mode, the Run or Idle state and the buffer state.

Optionally you can connect, to the COM port of the system's USB, a DRO.

The system also makes possibility to send commands to the GRBL system. Orders comming from additionnals buttons or joysticks to manage manual movements e.g.

This system fully preserves GRBL’s parameters system.

A short video.

Required
A GRBL machine, Arduino Nano or Uno based, an Arduino Leonardo or better (I use a Maga) (because 2 serials ports). A LCD display 20x4 I2C (for the example program) and, optionally, a PC with Excel for the DRO.

GRBL version must be >= 0.9 default speed 115200. If you are using a GRBL version < 0.9, default speed 9600 you have to change, in program: Serial1.begin(115200);      // GRBL Communication to Serial1.begin(9600);        // GRBL Communication

How does it work
This system is based on an Arduino Leonardo (MP) and an I2C LCD display 20x4. The MP is connected to the GRBL processor (GP) by the TxD and RxD lines. The GRBL must simply be set $10=7

The MP works in 2 modes, Automatic On and Automatic Off.

Automatic Mode On
The GP must be connected, via USB, to a G-Code Manager (gG) as Universal G-Code Sender (UGS) or GRBL Controller. It’s the gP which ensures the polling status request to GRBL. The MP listen the line and receives status parameters.



It formates these for the display on the LCD.

If G-code files sent from gG to GP, it is mandatory to be in this mode! The polling status request in Automatic Off mode may collide with gG’s transmissions.

Automatic Mode Off
The MP requesting the status of GP (polling ?), listen the line and receives status parameters.



It formates these for the display on the LCD.

This mode also allows to send all orders (G-code, configuration etc.) accepted by the GP.

In this mode, it’s possible to work from the MP or from the gG as far as it’s not at the same time.

Other controls can be connected on the MP, such as joystick, control buttons, etc., to transform these values in G-Code commands and send them to the GP.



Remarks
In 2 modes, tables of GRBL system (coordinate axes) are updated and preserved. If updating the GRBL firmware it's essential to disconnect this system!

Schematic
Why the choice of the Arduino Leonardo? Because he has two communication ports (Serial and Serial1). It is always more efficient than adding communications library.



The scheme is not very complicated. The IC CD4066 quad bilateral switch having only a gate used. This electronic switch is, when the MP does not need the TxD line on GRBL RxD, to isolate the line. Without this isolation, another transmitter into the USB port of the GP could no longer transmit. Indeed, if we look at the data transmissions diagram of a Nano (UNO is the same) USB data passes through a 1k. resistor and therefore are lower than ours and will, without insulation, crushed.



The program
The program contains few remarks, I preferred to use relatively speaking variable names.

In Automatic mode On, is mainly used to listen the transmission line of the GP.

The program, in automatic Off mode, sends a status request (polling?) And listen to the transmission line of the GP. In this mode, a monitoring (watchdog grblActivityWatchdog) blocks any issue, from the program if this GRBL activity not controlled by himself.

At the status data reception from GRBL 

Formats values: IDLE,0.000,0.000,0.000,0.000,0.000,0.000,0

And put the parameters in variables: enum grblStatusValuesIndex {grblValStatus, grblValMachX, grblValMachY, grblValMachZ, grblValWorkX, grblValWorkY, grblValWorkZ, grblValBuffer, grblValLasted}; String grblStatusValues[grblValLasted+1]; // GRBL Status] grblStatusValues[grblValStatus]; grblStatusValues[grblValBuffer]; // Machine positions grblStatusValues[grblValMachX]; grblStatusValues[grblValMachY]; grblStatusValues[grblValMachZ]; // Working positions grblStatusValues[grblValWorkX]; grblStatusValues[grblValWorkY]; grblStatusValues[grblValWorkZ];

These variables are displayed on the LCD display 20x4: lcdPrint(grblStatusValues[grblValStatus] + " buff " + grblStatusValues[grblValBuffer] + "  ",0,0); lcdPrint("Xmw " + grblStatusValues[grblValMachX] + "  ", 0,1); lcdPrint(grblStatusValues[grblValWorkX] + "  ", 12,1); lcdPrint("Ymw " + grblStatusValues[grblValMachY] + "  ", 0,2); lcdPrint(grblStatusValues[grblValWorkY] + "  ", 12,2); lcdPrint("Zmw " + grblStatusValues[grblValMachZ] + "  ", 0,3); lcdPrint(grblStatusValues[grblValWorkZ] + "  ", 12,3);

In this program version, these data are formatted to be sent on an Excel sheet based DRO: // GRBL Status droSendValues("GRBLSTATUS",1,grblStatusValues[grblValStatus]); droSendValues("GRBLBUFFER",1,grblStatusValues[grblValBuffer]); // Machine positions droSendValues("GRBLMAXISX",1,grblStatusValues[grblValMachX]); droSendValues("GRBLMAXISY",1,grblStatusValues[grblValMachY]); droSendValues("GRBLMAXISZ",1,grblStatusValues[grblValMachZ]); // Working positions droSendValues("GRBLWAXISX",1,grblStatusValues[grblValWorkX]); droSendValues("GRBLWAXISY",1,grblStatusValues[grblValWorkY]); droSendValues("GRBLWAXISZ",1,grblStatusValues[grblValWorkZ]);

According to a predefined format, details at the end of this wiki.

Program settings
The setting commands are entered through the command line of the Arduino IDE (new line ending) or any other console program connected to the Arduino’s COM port. Orders that are currently recognized: For setting the program: INTERNAL/MODEAUTO/0 //Automatic mode Off/On INTERNAL/MODEAUTO/1 INTERNAL/GRBLPOLLPER/250 //Polling period INTERNAL/DROconnected/0 //If a DRO connected Yes/No INTERNAL/DROconnected/1

Default parameters are: INTERNAL/MODEAUTO/0 INTERNAL/GRBLPOLLPER/250 INTERNAL/DROconnected/1

For sending commands: GRBL/G90 G0 X0 Y0 z0

Changing default settings are not, for the moment, saved in EEPROM. This is for the next version.

The program Basic version
This is a basic version of GRBLuniversalDRO. For Arduino Nano, without display and without DRO section.. GRBL data: X, Y and Z, machine and working state GRBL state Buffer state Are available in grblStatusValues[] array See in the subroutine void grblStatusDisplay

Warning! This MP basic program is for a "small" Arduino with a single communications port, so this program uses a virtual communication port (Library SoftwareSeria). Consequently the speed between the MP and the GP must be set to 9600. If you are using a version of GRBL> 0.8, you must make a downgrade. (GRBL> 0.8 speed default 115200)

The program Mini version
This is a mini version of GRBLuniversalDRO. For Arduino Nano, without display, DRO section and TxD polling. Only listen mode. GRBL data: X, Y and Z, machine and working state GRBL state Buffer state Are available in grblStatusValues[] array See in the subroutine void grblStatusDisplay

Warning! This MP basic program is for a "small" Arduino with a single communications port, so this program uses a virtual communication port (Library SoftwareSeria). Consequently the speed between the MP and the GP must be set to 9600. If you are using a version of GRBL> 0.8, you must make a downgrade. (GRBL> 0.8 speed default 115200)

Downloads
For GRBL until version 0.9j

Full version
Arduino library [LiquidCrystal-I2C] GRBLuniversalDRO Kit LiquidCrystalI2C Folder library GRBLuniversalDRO.ino Arduino source GRBLuniversalDRO.sch Schematic GRBLuniversalDRO.sch.pdf Schematic [GRBLuniversalDRO.ZIP]

Basic version
GRBLuniversalDRObasic Kit SoftwareSerial Folder library GRBLuniversalDRObasic.ino Arduino source GRBLuniversalDRObasic.sch Schematic GRBLuniversalDRObasic.sch.pdf Schematic [GRBLuniversalDRObasic.ZIP]

Mini version
GRBLuniversalDROmini Kit SoftwareSerial Folder library GRBLuniversalDROmini.ino Arduino source GRBLuniversalDROmini.sch Schematic GRBLuniversalDROmini.sch.pdf Schematic [GRBLuniversalDROmini.ZIP]

For GRBL since version 1.1d

Full version GRBL 1.1
Arduino library [LiquidCrystal-I2C] GRBLuniversalDRO Kit LiquidCrystalI2C Folder library GRBLuniversalDRO.ino Arduino source GRBLuniversalDRO.sch Schematic GRBLuniversalDRO.sch.pdf Schematic [GRBL11universalDRO.ZIP]

Basic version GRBL 1.1
GRBL11universalDRObasic Kit SoftwareSerial Folder library GRBL11universalDRObasic.ino Arduino source GRBL11universalDRObasic.sch Schematic GRBL11universalDRObasic.sch.pdf Schematic [GRBL11universalDRObasic.ZIP]

Mini version GRBL 1.1
GRBL11universalDROmini Kit SoftwareSerial Folder library GRBL11universalDROmini.ino Arduino source GRBL11universalDROmini.sch Schematic GRBL11universalDROmini.sch.pdf Schematic [GRBL11universalDROmini.ZIP]

Overview:
A DRO (Digital Read Out) for GRBL based on an Excel workbook: Essential of the assembly, MP side, is described in the above wiki,. The example values of this explanation, too. The connections of these elements is showed on the top of the above Block diagram.

A short video.

Required:
A PC, or better, a touch screen tablet & Excel. An Arduino microcontroller (MP), if possible, with two communication ports (Leonardo, Mega...) A system running GRBL (GP).

How MP works:
The DRO connect via the COM port of the MP’s USB. The MP receives data from the GP, it formats and sends it to the DRO as follows: DRO name, value name, value index, the value value. (Index of the source, though several sources with the same name, eg. POT 1, POT 2, not used in the program above example, always 1) Example for source GRBL machine axis position X = 123 to DRO named DROX Int droValue = 123; Int droIndex = 1; String droCommand = "DROX" + "," + "GRBLMAXISX" + "," + String(droIndex) + "," + String(droValue) + "\n"; Serial.print(droCommand);

DRO side, on receipt: DROX, GRBLMAXISX,1,123 The name of the recipient cell for this value should be GRBLMAXISX_1 consisting of the name of the value + underscore + index of value. Once a cell is so named, value is displayed in cell otherwise it will be reported as error.

Operation Excel DRO:
First, this Excel sheet is not entirely my creation but an adaptation of a work of [Roberto Valgolio], thanks to him.

This DRO Excel based works with VBA macros, but for general use, as described below, it's necessary to use that spreadsheet functions quite normal cell treatments.

It consists of 3 sheets Display, Data & Connect.

Display: That contains the values you want to display and control buttons.

Data: Receiving the received values of MP in the zone received values, settings of commands in Commands definition area. The name of the DRO in DRO Identity. The trace of the received orders, if a value is an unknown name, it is preceded by ???.

Connect: Which contains the serial connection setting. The connection button. The checkbox Display full screen, when checked, the Display sheet is displayed full screen, without menus and icons. This mode is also used to update CB modified in Data sheet. If not checked, you can edit, more easely, the Display sheet.

Sheets details:
Data: Received values: The first column contains information of the name of the value received. The second column contains the received value. This is the most important as it is to be named as mentioned above.

The DRO receives from the MP, DRO,GRBLMAXISX,1,123

The cell who must receives this value should be named GRBLMAXISX_1.

In case of error or not receiving expected values, they will be displayed in the list, at bottom left, preceded by ???.

The third column contains additional information on the displayed value.

Commands definition area : Index column: Contains the index of the control buttons (CB). By default there are 20 buttons.

Button column name: the Object button's name.

Column Button text: The text displayed in the CB, if empty, CB is off and the text of CB will be Button_nn.

Locked column: if = L this command has a safety lock.

Column Command: The command sent to MP when CB is clicked.

Column Section: Information usefull for layout in Display.

Column Command parameter: Additional parameter for to make the command.

Column Remark: Note.

To add additional CB, it must be done in a logical continuation of definition Commands area and create additional CB in the Display sheet by copy and past an existing button.

Display: Values display: For the layout of values, only the standard functions of Excel are required.

Command buttons : By default there are 20. To add one, create the definition in Data / Commands definition area. Add new buttons by copying and pasting an existing, according to rename the column Data / Commands definition area / Button name. To name a button, select it by a right click and put the name in the name box at the top left. Unused CB can be hidden at the bottom outside the display area.

Connect:

Comm port = MP’s communication port, on PC. Speed = Arduino Serial.begin(115200);

Option Display full screen: If selected: Viewing Display sheet is full screen, icons, and menus are hidden. The buttons definition changed in the Data Sheet are updated.

If not selected: Viewing sheet Display is normal, to allow its publishing more easily.

Download
GRBL universal DROxls Excel workbook

Why this?
You can see why I've made this system, on the excellent forum usinages.com Transforming my lathe Proxxon PD 230E (in French).