Quick guide

[Control a Servo] [Hardware]

To get your Arduino to control a plotter, following steps are needed:

Windows USB driver

Connect your Arduino with your PC, on windows 10 the needed USB driver will be installed automatically, if not: the cheap Arduino clones often uses a CH340 chip. Check here for more information https://www.google.de/search?q=arduino+ch340.

 

Grbl firmware

Download and unzip GRBL-Plotter. Start the program XLoader.exe. Select the desired firmware, correct device and the correct com port, then upload the firmware. With the shown settings, the upload took 18 seconds.

After successful upload, close XLoader and reset the controller.

1st connection

Install GRBL-Plotter by starting 'setup.exe' from the unzipped folder. Start GRBL-Plotter and select the correct COM-port for the controller. After successful connection, grbl sends a start-up message "Grbl 1.1h ['$' for help]".

Now the buttons inside the GUI are enabled and the stepper motors can be controlled.

 

 

 

Configuration of grbl

After pressing "$$", grbl lists the stepper motor settings, which must be adapted for each machine. Check the grbl-Wiki for more information. The screenshoot shows the initial settings after the installation of grbl.

The main settings are $3, $10x, $11x (x=0,1 or 2 depending on axis) to get the stepper motors running in the correct direction. The correct direction means:

  • +X = to the right
  • +Y = to the back
  • +Z = upwards

 

Note: a too large number for $10x (steps/mm) and $11x (max. speed) will cause problems.
The product of $10x and $11x must stay below 1800000 to avoid pin frequencies above 30 kHz.
E.g. $100=250, $110 = 7200 is at the edge.

More information here: quick-guide-to-setting-up-your-machine-for-the-first-time

 

Spindle-PWM and use of a servo:

The pulse width modulation (PWM) for speed control of a motor or power control of a laser, is generated via a special pin function (hardware PWM) inside the ATmega328 (the microcontroller of the Arduino Uno / nano) on pin 11 (PB3, OC2A). This means the pin for the output of the PWM cannot be changed.

  • By default, the PWM frequency is set to 1 kHz. The duty cycle can be controlled between 0% and 100% to get an control voltage of 0V to 5V for the spindle or laser.
  • RC servos usually require a PWM signal of 50 Hz with a pulse width of 1 ms to 2 ms. The duty cycle is then just in the range of  5% to 10% - not suitable to control a spindle or laser.

Regular grbl: "By default, the spindle PWM frequency is 1kHz, which is the recommended PWM frequency for most current Grbl-compatible lasers system. If a different frequency is required, this may be altered by editing the cpu_map.h file."
Source: https://github.com/gnea/grbl/wiki/Grbl-v1.1-Laser-Mode#laser-mode-operation


Adapted grbl: "This is a special version with servo support (swichable in config.h) The PWM frequency is set to 61Hz (prescaler 1/1024). The pulse width range is 0.5 - 2.5ms." (Duty cycle it then from 3% to 15%).
Note: internally the PWM range goes from 7 (0.5 ms pulse width) to 38 (2.5 ms pulse width), which results to 32 possible different servo positions (probably less, because the regular range is from 1 ms to 2 ms). Source: https://github.com/cprezzi/grbl-servo
 

Common hardware

The following information refers to cheap (counterfeit?) boards that are available on ebay for 12€ to 15€ (including shield, arduino, A4988 drivers and USB cable).

The CNC shield V3 for Arduino Uno was designed for grbl 0.9. Because of a change in the pin-out in grbl version 1.1, the spindle-pwm signal can be found on the Z+ pin. Check schematic here.

 

 

The CNC shield V4 for Arduino nano shows a wrong layout for the micro-step jumpers. Check this link. Also step and dir-signals are swapped, which needs a adapted grbl version. I used this board at my foldable plotter. The adapted grbl firmware can be found in the GRBL plotter setup (grbl_v1.1f_Servo_switch_dir_step.hex).

We use our own or third party cookies to improve your web browsing experience. If you continue to browse we consider that you accept their use.  Accept  More information