GRBL 0.9j - Running your laser with spindle pin

It has been a while, since I wrote something about my eShapeOko and GRBL. In the meantime, I upgraded my hardware to the black Pololu Edition, desoldered the GRBL Shield caps, and put them on the other side of the PCB, to cool the drivers from top and from the bottom with a heat sink.

The new big upgrade to my eShapeOko was a 250mW laser, ordered by Banggood for 10€. These can be driven with 5V and come with nearly everything you need, to get started. First of all, I upgraded the GRBL version on my Arduino Uno and ran into some problems, on how to drive the laser, to avoid, that this little beast is turned on all the time and leaves track, while speedfeeding to the next “cut location”.

I found out, that some people realized it, by using the spindle enable pin of GRBL. Thats what I wanted to do, because I don’t use the spindle control at the moment. So first of all I had to deal with the new GRBL version, which was v0.9j. In the 0.9 version, the pins for spindle enable and z limit were switched. But that isn’t our problem at the moment. Our current problem is, that GRBL 0.9j uses variable spindle speed on the pin I mentioned above and no spindle enable anymore. I need a clear 5v / 0v Signal (equivalent to spindle enabled = true/false).

To get the spindle enable feature back, you need to download the GRBL Sourcecode, and patch it, compile it and upload it. I’m glad, the developer thought of this scenario :).

These are the steps I did, to get there:

(Please read all possible ways in order to save some time :) )

1a. Download GRBL sourcecode from github ( https://github.com/grbl/grbl )

2a. Extract zip File

3a. Use Notepad++ and open the file called config.h (Folder: grbl-master\grbl)

4a. Search for a line, that starts with “#define VARIABLE_SPINDLE”

5a. Comment this line out ( Use a double Slash // )

6a. Save the File

7a. Download a Compiler. I have a Windows box and used WINAVR GCC from http://winavr.sourceforge.net/

8a. Install Compiler

9a. Open a Command prompt, switch to the grbl-master Folder, where the makefile is located

10a. type “make” and wait until a grbl.hex file is compiled in the same directory

1-10b. Or you can Copy the Hex Information from here to a file (this is my compiled Version of GRBL with disabled variable spindle)

11. Backup your current GRBL Settings

12. Use a tool to upload the hex file to your Arduino Uno (I use xloader from here: http://russemotto.com/xloader/ )

13. Done

Now we are prepared. We didn’t only change the behaviour of our Arduino, we change the pin outputs as well.

Here is the code, where you can read it (from GRBL):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Z Limit pin and spindle PWM/enable pin swapped to access hardware PWM on Pin 11.
#ifdef VARIABLE_SPINDLE
  #ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
    // If enabled, spindle direction pin now used as spindle enable, while PWM remains on D11.
    #define SPINDLE_ENABLE_BIT    5  // Uno Digital Pin 13 (NOTE: D13 can't be pulled-high input due to LED.)
  #else
    #define SPINDLE_ENABLE_BIT    3  // Uno Digital Pin 11
  #endif
#else
  #define SPINDLE_ENABLE_BIT    4  // Uno Digital Pin 12
#endif

Now your Arduino GRBL Box has GRBL 0.9j running, but with the pinlayout and pin functionality like 0.8. Now you can use Pin 12 on your Arduino to control the laser. In order to do this, I used and BS170 I have from a previous project. You need to read the Datasheet in order to know, if this transistor works for you.

The BS170 has 3 Pins, Source, Gate, Drain. This is how I connected it.

1. Connect Source to GND of power supply

2. Connect Gate to Arduino Pin12

3. Connect Drain to black cable of the Laser

Thats it, now you can use the GCode commands M3 / M03 to turn your Laser and M5 / M05 to turn your laser off. In the most cases, you can configure your CAM software, to add these commands, while speedfeeding / feeding, to get what you want.

If you need these settings for CAMBAM, leave me a message!

test

Licensed under CC BY-NC-SA 4.0
Zuletzt aktualisiert am Oct 13, 2015 07:24 UTC
comments powered by Disqus
Erstellt mit Hugo
Theme Stack gestaltet von Jimmy