Panel Cookies
GRBL CNC - Code
03/04/2022 | Views: 28906 | Arduino | by: ELECTRONOOBS      


This code is using the GRBL platform. But this one is changed a bit so it could work with a servo for the Z axis. Usually, a CNC machine has another stepper motor for the Z axis but this plotter is using a servo to go up and down. For that we connect the servo on pin Z- of the PCB and this code will pull it up when the Z coordinate is above 0 and press it dwon when the Z coordinate is below 0. That's how we go up and down.

How to uplaod the code?

Well, download the grbl.zip file from below. Then open Arduino IDE. Go to sketch, add library adn selecct add .zip library. Then select the grbl.zip file you have just downloaded from below. Now that grbl will be installed as a library. So next go to File, examples and from the grbl examples open the "grblUpload" one. Compile for Arduino NANO and upload it. That's it!

If you open the library directory, you can see the grbl files. If you want to change the pins you must open the cpu_map.h file and change the pins before you uplaod the code. Also, if your servo is rotating backwards or the angle range is different, open the spindle_control.c file and change the #define PEN_SERVO_DOWN and #define PEN_SERVO_UP variables. Mine were 15 and 30. To rotate backwards they would be 30 adn 15. Chaneg these values and adjust the angle rotation of the servo.


Download GRBL Code (03/04/2022)


Arduino code GRBL servo plotter






// these are full travel values. If you want to move less than full travel adjust these values
// If your servo is going the wrong way, swap them.
#define PEN_SERVO_DOWN     15     		//Mine was 15
#define PEN_SERVO_UP       30       		//Mine was 30













Last tutorials

All about Arduino PWM frequencies
Homemade Baby White Noise Generator
Measure AC RMS with Arduino
10 Stage Coilgun - Version 2
Tesla Coil on PCB

ADVERTISERS



Affiliate Disclosure

ADVERTISERS



PCBWAY PCB service





Curso Arduino Online nivel bajo