mstrens / grbl_controller_esp32

grbl controller for esp32
177 stars 80 forks source link

grbl_controller_esp32

This Grbl controller runs on a ESP32

This project allows to control a CNC running GRBL without having to use a pc.

This is an alternative to Marlin or Repetier for CNC.

Note: GRBL has to run on a separate micro computer (e.g. an Arduino Uno, Mega or a STM32 blue pill).
This project only intends to replace the PC by an ESP32 board, not to replace GRBL.

This application allows to:

This application displays some useful GRBL informations like

Optionnally you can connect a Nunchuk (kind of joystick) in order to move the X, Y, Z, axis.
To move the axis, you have to move the joystick (up/down/left/right) and simultaneously

Hardware

To implement this project you need:

It should also be possible to use a separate SD card support.
Note: this configuration uses the ILI9341 with 4 wires (CLK, MOSI, MISO and CD).
Currently, this project works only with a TFT having a ILI9341 chip, a resolution of 320X240 and XPT2046 chip for the touch screen. If you are using another display, you should change the code yourself.

Software

This project compiles in Arduino IDE but it requires:

Take care that if you do not use my configuration, you can have:

Note: the pins used for the SPI signals (MOSI, MISO, SCLK) are currently hardcoded.
Please note that many ESP32 pins are reserved and can't ne used (reserved for bootup, for internal flash, input only,...). See doc on ESP for more details.

Note: the first time you let ESP32 run this program, the program should execute a calibration of the touch panel.
The screen should first display an arrow in a corner. You have to click on the corner.
When done, an arrow should also be displayed sucessively in the 3 others corners. Click each time on the arrow.
This should normally be done only once. The calibration data are stored automatically in the ESP32.

If you want to recalibrate your screen, you should replace, in the "config.h" file, "#define REPEAT_CAL false" by "#define REPEAT_CAL true".
Change it back to "#define REPEAT_CAL false" afterwards.
Alternatively you can force a recalibration from the SD card. To do so, you have to put a file named "calibrate.txt" in the root of the SD card. The content of the file does not matter (only the file name). Remove the file from SD card once calibration is done in order to avoid to do it at each power on.

Wiring the ESP32

Here the connections being used in my own setup.

Between ESP32 and TFT.

Between ESP32 and touch screen

Between ESP32 and SD card

Between ESP32 and GRBL computer

Between ESP32 and Nunchuk

Control of GRBL from the PC

In order to control GRBL from a PC, you can use the software bCNC on the PC.\ It allows you to connect ESP32 using a com port (USB) or using wifi.\ To install bCNC, follow the instructions from this site: https://github.com/vlachoudis/bCNC/wiki/Installation \ For Windows, do not use the exe file (at march 2019 it did not work) but start intalling python2.7 and then install bCNC using pip.\ At march 2019, this does not install the latest version of pyserial software. \ So, you have to enter also (in the command windows): pip install --upgrade pyserial \ Then, you can launch bCNC with the command: python.exe -m bCNC.\ Note: if you already have a version 3 of python running on your PC, it could be that you have to type: python2.exe -m bCNC.\

In bCNC, select the "File" tab, and in the Serial part, in field Port, enter:\

In bCNC, in the serial part, in field Controller, enter the type of GRBL you are using, so probably it will be GRBL1.\

Then click on the "Open" button in bCNC.\ And finally, on ESP32, select the Print button and then "USB" or "Telnet".\ Once USB or Telnet is activated, you can't anymore use the ESP32 options (Setup, ...).\ The only thing you can do on ESP32 side is to select the button "Stop PC" which will stop the flow of data exchanged with the PC.\

Control of SD card content from the PC

In order to manage the files on the SD card from the PC, you have to:

Informations on the TFT layout and functions

Info screen:

This is the first and main screen of the application. It displays:

Move screen

It allows to move the motors in the X, Y and Z axis.