I have done several pen and laser machines lately, so I decided to create a custom PCB for Grbl_ESP32 for these types of machines. This is a small (70mm x 60mm) PCB with all the features a pen plotter or laser cutter/engraver would need.
These typically use stepper motors for the X and Y axes. On pen plotters, the Z axis is controlled by a servo or solenoid. On lasers you need an accurate PWM for laser power control.
Here are the features of the PCB assembly
(2) Stepper Motor Driver Sockets for standard stepper driver modules.
(1) Hobby Servo Connector.
(1) High Current (10A max) Output Control. This can be used for a solenoid, fans, etc.
(2) limit/Home Switch Connectors.
Laser Power PWM connector
Removable Micro SD card. Upload files via Wifi to reliably run off-line.
5V 3A Step Down Power Supply
Standard DC Barrel Connector for power input. (9-28 VDC)
Power Output Connection for laser module.
Grbl_ESP32 Advanced Features
32-Bit dual core processor
Fast 120kHz step rates
WiFi
Access point or station modes
Complete web user interface
Telnet
Bluetooth Serial
Compatible with phone apps
Compatible with most serial port gcode senders
16 bit laser power control.
Core XY kinematics supported for T style machines.
RTOS (real time operating system) allows the use of custom tasks.
Precise servo control accurately mapped to Z motion, plus interactive calibration.
Precise control of solenoids via adjustable pull and hold strengths using PWM. This allows a strong pull, yet a cool hold temperature.
Instant On/Off – Unlike a Raspberry Pi, there is no long boot time or formal shutdown required. It is typically ready to go in a few seconds.
How to control it
There are several ways to connect to the controller, but to run jobs, you basically either stream the gcode or run it from a file on the SD card. The SD card is a great feature because it is free from connectivity interruptions and you don’t need to stay connected to your machine while it is running the job. You can quickly upload files via WiFi or remove it and plug it into your computer.
Serial port
This controller is compatible with virtually all of the serial port gcode senders for Grbl. The default baud rate is 115200.
Bluetooth Serial
This is a great way to use your phone to control a machine. When you connect via bluetooth, your phone or computer will create a virtual serial port. This means you can then use existing serial port based gcode senders.
Wifi – WebUI
The controller has a web server. The controller can create its own WiFi access point or connect to an existing WiFi network. You connect to the controller with a web browser and it serves a full featured machine controller to browser.
Controlling the Pen Up/Down Servo
The servo is controlled using a separate RTOS task on the controller. Grbl thinks it is running a normal stepper motor on the Z axis. Each time the servo task runs, it looks at the current position of the Z. It then computes and sets a position for the servo. You map the servo’s range to a Z range. For example the range could be set for 0-5mm. Any values of Z above or below this range would would be limited by the range, so any Z value above 5mm in this example would not move the servo past where it was at 5mm.
You can calibrate the end points of the servo to fine tune it. We use the Z axis resolution and max travel settings to do this. $102=100 (100%) would be no change to the first end point. %102=90 or $120=110 would be 10% changes in either direction. $132 works the same way for the other end point. Make sure you do not adjust the servo so it hits the physical end point of its travel. You will feel the servo continuously vibrating as it pushes against the end point. This is very hard on a servo and will overheat and damage it.
The servo updates its position 20 times per second. Therefore it will do a good job of respecting the acceleration and speed settings in the gcode.
The feature also uses the $1 (Step idle delay) setting. It the steppers motors disable, so will the servo and can be moved manually.
Additional parts you need
The controller uses plug in modules for the the ESP32 controller and the stepper motor drivers.
ESP32 Controller
The ESP32 controller needs to be a ESP32 Dev Module. It should have 2 rows of 19 pins. The rows should be spaced 0.9 inch (22.86mm) apart. Be careful: Some similar controllers have a wider pitch.
Stepper Motor Drivers
The drivers are the standard StepStick (Pololu) style footprint. The (3) microstepping selection pins (MS1, MS2, MS3) are all connected to logic high. This typically results in the highest resolution (1/16 or 1/32). The Grbl_ESP32 step rates are high enough to make that not an issue. I typically use TI DRV 8825 or Allego A4988 modules, but others can be used as long as the pins are compatible. The PCB silkscreen has the corner pins labeled. Use them to insure you correctly install your driver modules.
Source Files (coming soon)
A completely assembled PCB is available on Tindie. The profits from Tindie help me to continue to develop the hardware and firmware for projects like this. If you want to roll your own, the source files are linked below.
The NickelBot is complete and it works great. The goal of the project was to create an easily portable machine that creates low cost items that could be given away at events like Maker Faires. I think it has completely achieved that goal. The nickels are purchased from Amazon and cost about $0.08 each.
Here is a video that explains the machine.
Results
It is quite reliable and the cycle time is is just about right at 1-2 minutes per nickel. I think the engraving quality is quite good. I ran it at the Chicago Northside Maker Faire last weekend. It made about 60 nickels without any problems. Here are some of the nickels it made.
Mechatronics
The NickelBot uses (2) NEMA14 stepper motors in a T-Bot configuration. These drive a single GT2 6mm belt. The linear bearings are (2) 6mm rods per axis with (1) LM6LUU per rod.
To handle the nickel loading and unloading, it uses a single micro hobby servo. This servo connects via a 0.03″ brass wire to a clamp. The firmware has (3) positions hard coded for the servo for fully open, nickel support only and supported plus clamped.
All 3D printed parts are PLA printed on a Lulzbot TAZ6. The colors just represent the color that happened to be in the printer at the time.
The Laser Module
The laser module is a 3.5W peak, 450nm (blue) laser. It comes with a laser power supply that has a 12V power input and TTL laser control input. It also comes with a 12V 5A power supply. I bought it a few months ago from Banggood.com when it was on sale for about $70, but they are typically around $99. I control the engraving power with a 5kHZ PWM from the microcontroller.
Controller
I used a PSoC5 development board as a plug in on a custom PCB. I knew adding an additional, accurate PWM for the servo was going to be vastly easier on the PSoC5 vs. an Arduino.
This dev board has a built in programmer debugger that makes firmware development very easy. It is great to be able to set breakpoints and check values with the debugger. I have have a another blog post with more details on this here.
Firmware
The firmware is a modified version of my PSoC5 Grbl port. The only modification needed was the code to handle the clamp servo. Rather than adding special gcodes for the clamp, I simply re-coded the M7,M8 and M9 coolant commands. I did this because all of the parsing and protocol issues were already done. Each command represents one of the clamp positions.
I may post the source code on Github soon.
Calibration
The machine has (2) home switches (X and Y). A homing sequence needs to be run each time you power up the machine. All other locations are referenced to this location. A one time calibration is done to locate the following locations.
G54: G54 is the the default work offset. I decided to use the center of the nickel as the 0,0. I jogged the machine visually until the nickel looked centered. I then set the G54 location with this gcode line”G20 L10 P0 X0 Y0″. I made a target shaped graphic that I used to test engrave this location(see above). I used a caliper to measure the centering error, jogged that amount and reset the 0,0. I did this about 5 times until I was satisfied with the centering.
G28: I used the G28 location as the location under the nickel hopper. You jog to the location and set it with “G28.1”.
G30: I used the G30 location as the position over the eject chute. This is set with the G30.1 gcode command.
This is a great program for this application. It does everything, starting with a bitmap image, to gcode sending in one application. It also has some macro (multi-line gcode) buttons that are very handy. The only drawback for some is that it is Windows only.
Here is an example of the macro to get the nickel.
G90G0X0Y0 ; rapid move to absolute 0,0
M9 ; loosen clamp
G28 ; move under nickels
G4 P0.75 ; wait for nickel to fall and settle
M7 ; close clamp
G4 P0.5; wait a bit
G0X0Y0 ; return to 0,0
Interlock switch: Right now there is no interlock switch for the door. If I make a new PCB, I will add a provision for that. I’ll probably just break all power to the laser module.
Nickel Flip: Right now the nickel always comes out of the chute upside down. This is not the best presentation. This was a compromise to make the machine as small as possible. The nickel has to fall between the Y rods. Rather than makethe distance between the rods wider than the nickel, I designed and aligned the clamp/support system so that one side of the nickel falls first and goes between the rods closer to vertical. There is a probably a way to design the chute to catch the nickel before flips over completely or re-flips it back.
Software:
More automation: LaserGRBL has macro buttons for the nickel feed and eject features, but it would be nice if that was automatic. They have added a gcode header and footer feature to the roadmap. Right now you can generate the gcode, save the file and paste the nickel handling code in an editor. That file is then fully automatic.
Customizing: It would have been fun to easily add names, etc to nickels for people.
If you want to be notified of future blog posts, please subscribe.
I got a chance to do some work into this project and I made some progress.
The X,Y mechanism is a free standing H-Bot. Here is a bottom view. You can see the Y home switch and the bottom of the servo to control the nickel.
Here is a top view of the mechanism. The yellow clamp piece opens partially to create a platform (ledge) for the nickel. This slides under the nickel feed tube and a nickel drops in. The bed is extra wide, so there is always something supporting the nickels in the feed tube.
The servo then clamps the nickel by pushing the tang on the yellow clamp piece into the nickel. Once the engraving is complete, the clamp completely retracts, removing the ledge. The nickel falls through into a hopper that is accessible from the front. This allows for a fully automated process and you don’t need to open the machine.
Here it is with a nickel in the clamp.
I have a temporary enclosure for testing. This supports the XY mech. You can see the nickel feed tube and the laser module support bracket. Currently it is open and a little larger than necessary to make it easy to test. It will eventually be cleaned up and get an access door with a window.
The next step is to work on the firmware. I plan to use Grbl in Core XY mode. I need to add a way to control the servo and figure out some commands to control the nickel handling.
If you want to be notified of future blog posts, please subscribe.
I started working on my next backpack scale CNC project. My backpack scale projects are tiny CNC machines that I can easy carry in a backpack to tech meetups and events. This machine is going to be a wooden nickel laser engraver.
Wooden nickels are small wooden discs. You can buy blanks from various places, including Amazon. You can usually get 100 for less than $10. The goal is to create a machine that loads them from a feed tube, engraves them, then ejects them.
Mechatronics
The basic drive will be an H-Bot. It will be similar to the midTbot, but the motors are at the ends of the X axis. It will be fully enclosed, but I not started work on that part yet.
Disc Feed System
I hope to be able to use a single hobby servo to handle the loading and unloading of the blanks. The servo will control a sliding device that has three positions.
In the first position it acts like a support shelf for the disc. The bed slides under the feed tube and a disk drops into the pocket.
The next position is the clamping position. This holds the disc still while engraving.
The final position retracts the shelf so the disc drops through.
Electronics
The goal is to use a low cost controller like an Arduino Nano.
(2) Stepper motors for the X,Y motion
(1) Hobby servo for the disc feed system (PWM)
(1) Laser power control (PWM)
(2) homing switches
(1) interlock switch loop if there is a door and/or cover
Status
The major new feature of this design is the disc feed system, so I am primarily working on that right now.
If you want to be notified of future blog posts, please subscribe.
I recently bought some laser galvos from Aliexpress. What I got was the basic guts of a laser light show system. It came with everything I needed except the lasers. My goal is to control a laser to make a large interactive artistic display or game controlled by a micro controller with a DAC. I have a PSoC 5 and an ESP32 that have DACs, so I may use those.
Galvos work like speakers, old school analog meters or hard drive arms. They move proportional to a current. They can move extremely fast and precisely with the ability to move to 30,000 positions per second. The galvos came with drivers. This simplifies the control to a simple differential voltage. A differential voltage is used to increase noise immunity. The ILDA spec says the differencial voltage is 0 to 10V. This means at one end of travel you supply -5V and 5V and at the other end of travel you swap the voltages supply +5V and -5V.
My DACs are 0V to 5V (0r 3.3V). I need to convert this range to a 10V differential voltage. The easiest way for me to do this is to use some op amps. With what I have on hand it is easiest to get the 10V differencial using 0 to 10V and -10V to 0. I tested on the galvos by outputting a -10V to 10V sin wave from a function generator. It worked great.
Assuming I use the 0-5V DAC, I need to map that to a -10V to 10V range. That is a 20V span and requires a 4x gain. I then need to offset that by -10V. The op amp circuit I show below is what I made.
I used an LM324N because I had some. That has (4) op amps in a single package. The rails of the device need to be hooked up to a + and – supply that is greater than the range I will be using. Fortunately the galvos came with a power supply that outputs +15V and -15V. I used some potentiometers in the circuit to allow me to adjust the circuit.
The lower op amp provides the gain. The gain on the positive side is 1 + 30k/10k which is 4. The negative side is used for the offset and its gain is 30k/10k which is 3. I need an offset of 10V, so 10V divided by the gain of 3 is 3.33V. I need that value to come from the upper op amp. That op amp has a gain of 1 so I simply need to adjust the pot in front of that to output 3.33V.
The DAC is connected to the lower left voltage source in the schematic shown as 2.49V. The galvos would be connected to Gnd and the output of the lower op amp (green line). The schematic is interactive. Click the link below and try adjusting the input voltage between 0V and 5V.
I needed to create 1 circuit for each axis. Here is my breadboard.
Here are the signals on an oscilloscope. The yellow trace is the 0-5V input as a 5kHz sin wave. The blue trace is the output. Both traces use the center line as the 0V. The scale is 5V per division. The input has a low of 0V and a high of 5V. The output goes from -10v to 10v.
I am using the tiniest laser I could find so that I don’t have to worry about safety yet. I 3D printed a base to keep things in line.
A lot of people have asked about building their own Coasty Laser Cutter. It takes a lot of work to get the files ready for release. I will release the source files in stages as they are ready so people can get started. Watch this post for updates. Subscribing to this blog or following me on Twitter (@buildlog) is a good way to keep up.
When everything is ready, I’ll probably also post on Thingiverse.
3D Printed Parts
Here are the STL files for the 3D printed parts. The parts are generally pretty easy to print. They require no support and can be printed in low resolution. I print at 0.28mm layer height. You need to watch out for warping on the chassis and front door. If the chassis warps it will stress the PCB and could damage some parts. The door needs to be flat in order to close properly.
I printed my parts in generic PLA. They printed fine, but if you have some crappier PLA or if you don’t have a heated bed, you should probably print with a brim. I would suggest printing the chassis first. If you can print that, the other parts are easier. I have some PETG on order to test. That supposedly warps less that PLA.
The holes used for the 8mm rods are designed to be a press fit. If the rods are hard to install, try cleaning the holes up a little by hand with a 5/16 or 8mm drill. The drive shaft bearing is also a tight fit. Try using a vise or clamp to press it into the chassis.
Here are some updates to Coasty – The Coaster Toaster, the tiny laser cutter specifically designed to cut drink coasters.
New Traction Roller
I made the traction roller diameter a lot smaller and moved it behind the beam. A smaller roller has a lot of advantages. It allows the beam to be closer to the contact points of the rubber orings. This improves the usable work area, because you can get closer to the edge of the coaster. With a smaller diameter the coaster travels less per revolution. This increases the torque and resolution.
Smaller Chassis
The chassis is now about 16mm smaller in depth due to the smaller roller and new location. The depth of the machine is quite a bit smaller than the coaster.
Fan Guard and Carbon Filter
I added a fan cover on the back. This acts as a finger guard and also allows a few layers of carbon filter cloth to be used. Bulk carbon filter cloth for use in air purifiers can be purchased on Amazon very cheaply. It removes a good portion of the odor of the smoke.
Carbon Filter Cloth
Door Interlock Switch
There is now a switch that cuts all power to the laser when the door is opened. You can still run the machine to test the motors, homing etc, the the beam cannot turn on with the door open.
IR Coaster Detector
I was not happy with the coaster homing switch used on the first version. While it never failed, it did not appear to be very robust and it caused some drag on the coaster. I changed to a IR LED and photo diode. When the light from the LED hits the photo diode, it conducts to the +5V. When the coaster blocks the light, it is pulled down to ground. I used a pot on the pull down because it did not know what he exact value would be. It turns out the value needs to be about 40k. The only catch was the microcontroller input pin pull up resistor on the Nano could not not used because it is less than the 40k. This required a slight hack to Grbl because Grbl is all or nothing on the pull ups for the limit switches.
I was not sure if ambient light changes might be a problem, like bright sunlight. The photo diode looks down and that appears to be good enough to avoid overhead light. I also have a mounting screw there in case I need to add a little shade/cover.
IR LED / Photo Diode Circuit
Bluetooth
I have been using Bluetooth on some other machines and really like it. Skipping USB cords and using a phone instead of a computer is great. I have found it to be very reliable. The real world bandwidth appears to be a little lower than 115200 USB. It has not been a problem, but I don’t do much gray scale engraving on this machine which needs higher bandwidth. Regardless, USB is still an option.
A standard HC-05 or HC-06 module plugs into a right angle connector.
Video
Here is a video of this version.
If you want to be notified of future blog posts, please subscribe.
People often ask me why the edges of their laser cuts are not square. The laser beam is being focused at an angle to a spot, so no cut can be perfectly square, but there are things that can make it worse. Note: All of the images are exaggerated to show the affects.
You first need to understand how the lens works. Laser cutters use a collimating lens. This means it takes parallel rays from the beam and focuses them to a single spot. For a couple of complicated physics reasons, it can never do this perfectly, but it should do it close enough not to be a factor in this discussion. Below is a picture of a collimating lens. A typical beam width is usually about 5mm-8mm and a typical lens is about 20mm-25mm wide.
You can see that the beam forms an hour glass shape. This can cause a little angle. With a 6mm wide lens and a 50mm focal length, this angle is typically 3-4 degrees.
To get the least affect on your part, you might want to center the focus in the middle of your material.
If you are getting a bigger angle than a few degrees, it is more likely because the beam is not in the center of the lens. The lens will still focus to that same point, but the hour glass is at quite an angle to your work piece.
This type of angle is offset in one direction, so you may see it more in certain directions of travel. If the beam is moving from right to left in the above image, you might not notice the problem at all.
Does a longer focal length help? It can, but due to the complicated physics issues I referred to earlier, a longer focal length creates a larger spot size, which reduces power density. See this calculator.
I have developed an inexpensive control system (less than $70) that can be used to both get more cutting power out of a DC discharge laser and significantly improve cutting accuracy for home built laser systems. The control system implements a control technique known as Pulse-Per-Inch (PPI) control. PPI control involves pulsing the laser every time the head travels a certain distance. PPI control allows a CNC laser to produce consistent cuts at the same power level setting over over a wide range of speeds. In effect, pulsing the laser as a function of distance along a cut decouples the power input to cut from the speed that the head travels. Therefore, the speed and acceleration of the CNC system have minimal bearing on the cut characteristics. Furthermore, the unique transient rise response of a DC discharge laser allow PPI to deliver more power to a cut in comparison to the same laser system with just on/off control.
Background and Motivation
A while back, I was active on a forum in which we were discussing the time it takes to turn a laser on and off and how that relates to engraving control. One of the forum members from Full Spectrum Engineering posted a high-speed intensity spectra for the cheap DC discharge lasers that we use for DIY laser cutters. I was quite surprised by the spectra. I expected to see a nice exponential rise to set power level, but what we saw was a rapid rise to a very high power level (nearly double the set value) followed by an exponential decay to a set value. The Spectrum in question is shown below (credit for the spectrum rests with Full Spectrum Engineering). The yellow square wave is a 5ms pulse sent to the laser power supply. The green spectra is the intensity spectra of the laser. For whatever reason, the magnitude of the spectra is upside down (I think the ground and signal leads were reversed), so on for the digital signal and higher intensity for the laser power spectra are down rather than up. Anyhow, the spike in intensity is caused by the necessity voltage to start a plasma in a DC Laser. The laser power supply generates a very high voltage to start the plasma which is stored in a capacitor. When the signal comes to turn on the power, the power supply dumps this charge into the system and then supplies a nominal (still very high) voltage to sustain the plasma once it is on.
A guy I met at WorkShop 88 is putting together a Maker Faire like event through the local ASME group. It is called the “AMSE Open Source Microcontroller Workshop“. He wants to get a bunch of local open source people to show off their machines and electronics. If you are interested in a meet up, stop by. I can probably get a few free tickets.
I agreed to go, but I don’t like hauling my laser around because I might break something. I have a second laser build going to test the MakerSlide changes. This will be fully functional except for the tube and tube power supply. It will also be run via Mach3 rather than an expensive controller.
The only problem with Mach3 is that you need to haul around a complete computer, with keyboard mouse and monitor. I am already bringing my laptop, so I was trying to figure out a passable way of using that. I know there are options like SmoothStepper and PCMCIA (rarely works) parallel ports, but I did not want to spend any money just for this event.
I have a very small desktop computer with a parallel port. I decided to try putting a VNC server on that computer to see if the laptop could be the display, keyboard and mouse for Mach3. I have used several flavors of VNC, but have found UltraVNC to be my favorite. VNC stands for Virtual Network Computing, but a better description is remote control software. You basically get to control the desktop of a remote computer.
I installed it as a service so that it would be available as soon as possible. I already had the computer setup to boot right into XP without a login. The server computer did not complain at all about not having a keyboard attached. I gave that computer and my laptop different static address on the same subnet. I connected the two computers with an Ethernet crossover cable. Once the VNC server (the Mach3 computer) booted, I connected with the viewer software from the laptop.
It connected fine and I was able to start Mach3 and run the laser. It worked quite well and the display update rate was acceptable, even on the DROs. The only issue I found was arrow key control of the axes was rough. It took me a little time too figure out the problem. The axis would start up fine then start to stutter a bit. I think it worked fine until the key went into auto repeat mode. If you hit the tab key to bring up the pendant looking thing, you can use the mouse to move the axes quite well.
I also hook up my Shuttle Pro and that works so much better than arrow keys any way.
Running G-Code worked perfectly. It is not a permanent solution, but it met my goal of not spending any money. It could also work as a simple remote monitor on a running job.