Archive for the 'Uncategorized' Category

TWANG32 – An ESP32 Port of TWANG


I ported the TWANG game over to ESP32. I wanted to do this for several reasons.

  • Cost: The ESP32 is generally lower cost than the Arduino Mega
  • Speed: The ESP32 has a dual core 80MHz processor vs. the 16MHz Arduino Mega
  • Memory: The ESP32 has much more RAM and program space to allow more features, levels and audio files.
  • Physical Size: A Mega is very big. This creates a large enclosure that takes a while to print. The smaller enclosure is also more portable.
  • DAC Pins: The audio capabilities on the Mega are very crude and basically limited to square wave tones. A DAC can output digital audio. Currently I am just using a similar square wave tone to the Mega, but it works much better for adjusting the volume.
  • Wireless: The ESP32 has Wifi and Bluetooth. This will allow easier (smartphone) interfacing for options (brightness, volume) and level pack uploads. I also want to consider dual player battle type games with linked controllers.

The Audio

The original TWANG bit banged audio directly from I/O to a speaker. This was super simple, but the volume at max was not loud enough for noisy environments. The ESP32 I/O is a lower voltage (3.3v) and less current, so something needed to be done. I prototyped with a PAM8403 based amplifier (~$4 on Amazon). This worked great, so I added that I.C. to my shield. The volume is controlled by the amplitude of the DAC.

The Shield

I made a shield to simply the wiring and provide a stable way to mount the ESP32. I used a NodeMCU 32S development board for the ESP32. Under the ESP32 is a the audio circuitry. I should have some extra boards to sell on Tindie soon. I will publish the source files soon.

The Firmware

The code is on Github. The port was relatively easy, but I had to rewrite a few libraries. They were designed so the main “setup” and “loop” parts did not change much. Currently the serial port based setup from the Mega version was not ported. This probably won’t be used. A wireless version is in the works.


The new enclosure is smaller. It prints quicker and is easier to fit in my backpack. The size is still big enough to hold comfortably while playing. The files will be uploaded to Thingiverse within the week.

Next Steps

  • Wireless control: I want a simple way to read the game statistics (average score, levels played, boos kills, etc) and tweak simple settings like audio volume and brightness. I think the easiest way is to make it a wifi access point with a simple web server. This eliminates having to write any client side apps and any smartphone or computer can hope on easily.
  • Levels: Make some way to edit or upload levels via wifi.
  • Multiplayer: I should be able to link multiple controllers. If I can think of a good dual player game idea, I might try to add that.
  • Python: It might be a fun challenge to write the game in Micro Python. This might open up the development to more people.

If you want to be notified of future blog posts, please subscribe.


Laser Galvo Control Experiments



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.

Click here to interact with the circuit.

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.

Here is a short Instagram video of some testing.


Playing with my laser galvos at NERP tonight.

A post shared by @ buildlog on

If you want to be notified of future blog posts, please subscribe.

Building a TWANG


First…. Most of the credit must go to Robin Baumgarten and Critters for the inspiration and firmware. While I have hacked and tweaked the firmware a lot, the basic design is still all Critter’s. He did a great job.

A lot of people have asked me to help them build one, so this blog post is here to help them out. It is easy and fun to design and build your own parts and electronics. You can also either use my or Critters 3D printed parts.

The Electronics

The electronics are quite simple and only consist of a few basic pieces.

Arduino Mega – The firmware will not fit on an Arduino UNO, so you must use an Arduino Mega or anything using the the atmega2560 micro-controller. You can tpyically find a clone for less than $10.

MPU-6050 – This is a 3 axis MEMS accelerometer and gyroscope. The easiest way is to buy a GY-521 breakout board. You only need to use the VCC, GND, SCL and SDA pins. Note: My shield also has the INT pin, but that was for experimentation. You can find these breakout boards on Amazon for less than $5.

Speaker – You need a small standard speaker. The sound quality is not great, so don’t invest in anything expensive. I used an 8 Ohm speaker, but anything should probably work. The speaker is hooked directly to the Mega I/O, so you also need a 100 Ohm resistor in the speaker circuit. Typically a 1/10w to 1/4w resistor would be used. Note: This resistor is included on my shield. If you use my 3D printed design you will want a 40mm diameter with very little depth to it. Note: Do not connect directly to an amplifier. It is not designed for that.

LED Strip – The FastLED library that is used, supports a lot of types. I like the APA102C (Dotstar) type. I have also tested WS2812 (Neopixel) types. Most of the testing I did was on a 1 meter 144 LED APA102C strand and it looked great. The game gets difficult when there are less LEDs, so I would recommend at least 90. I have also tested with (2) 1 meter 144/m strips soldered together and a giant 5 meter 90 LED/M strip. They all look and work great.  The firmware supports up to 1000. Most longer strips are soldered smaller sections. It is easy to solder strips together like the image below. Be sure the 5V, Gnd, etc. are aligned the right way. I have some strips that are waterproof. That is not required, but does not hurt.

Note: Do not power the LED strip directly from the Arduino. Power it separately from a power supply. Note: My shield has an input for this. It will also power the Arduino.

Power Supply – Technically, you could need upwards of 40mA per LED. I bought a 10A supply and it has worked fine without getting hot up to 450 LEDs.

Life LEDs – The firmware supports remaining “life” LEDs. I prefer to use the main LED strip for this. It is fun to live within the limitations of the LED strip as the sole display. Using the strip also allows you to adjust the life count in firmware. The default is 3 lives per level, but I have boosted it to 5 for testing.  Note: My shield uses different I/O pins for the LED than the original TWANG firmware, so you need to check this if using them.


The image below shows all the required connections to the Arduino Mega. My prototype used male header pins poked into the Arduino headers. It worked fine, but wires did often pop out when removing the cover.

The TWANG Shield

While hand wiring is very simple, I found it to be messy and I worried about failures. I made a basic shield to clean everything up. Here are the features of the shield.

  • LED Strip Terminal Block – It is very easy to hook up the strip. It works with both 3 and 4 wire strips. The power comes from the shield and no additional connections are required on the strip. Connections are clearly labeled. 3 wires LED strips do not use the CLK connection.
  • Accelerometer Terminal Block: This has clearly labeled connections using the same names that are on the MPU-6050 accelerometer module. Just hook them up 1 to 1.
  • Speaker Terminal Block: This also has 5V and Gnd if your hacking requires these connections. The 10 Ohm speaker resistor is mounted on the board.
  • Main 5V power entry connector: This powers the LED strip. It also powers the Arduino. It uses a diode so you can also power the Arduino via USB for programming.
  • Arduino UNO compatible: While the default firmware will not fit on an UNO, future compact version might be possible.
  • Life LEDs – My enclosure does not use them, but you could wire some in. The resistors are included, but not the LEDs. You could solder LEDS on the board or remotely locate them and solder wires to the PCB.

Shield Source Files

The 3D Printed Parts and other hardware

You need to 3D print a bunch of parts, a door spring, some hardware and a little hot glue.

Tindie Store

Typically I buy a small batch of PCBs for all my projects. If everything goes well I sell the rest on Tindie and often order more if they sell out.

  • Just the assembled shield. (coming soon)
  • A kit with all the custom parts
    • Assembled Shield
    • MPU-6050 wired and terminated with wire ferrules.
    • Speaker wired and terminated with wire ferrules
    • Door Spring

The Firmware

All of this is fully compatible with the original TWANG firmware. I forked the original and added a few changes. I would be happy to merge back to the original some time in future. The firmware relies on several libraries. Follow the instructions on GitHub pages to get those libraries.

Hacking the Firmware.

Hacking the firmware is quite easy. You should at least try editing some levels. More advanced hacking could improve the graphics and sounds.  Please give feedback if anyone has made any improvements.

At a minimum you have to set the number of LEDs and the LED strip type in the firmware before compiling.


(coming soon) This thing looks so awesome in person, but is nearly impossible to video due to the crazy brightness of the LEDs. A friend is going to help me try to get a decent video.

In the mean time, take a look at Critter’s videos.

If you want to be notified of future blog posts, please subscribe.

TWANG Play Testing


I took my TWANG Clone to ORD Camp, NERP and the Hardware Happy Hour Meetup over the past week. It got a ton of play time.  I received a lot of feedback to work on.

Observations and Feedback.

It’s difficult to beat.  Only one person got all the way to the boss level and defeated it. Amazingly, it was Elan Lee. He loved the game and gave me some good ideas to work on.

Most people got killed in the second to last level. It has a lot of enemies and a conveyor that keeps pushing you back to the bottom. There is also a sneaky enemy spawner at the bottom that gets a lot of people.  It is a great level, so I don’t want to remove it. I have added a few more levels before it to practice before that.

The Lava Pools. The lava pools confused some people. I changed the pools to look more red, flickering and scary when they are on and less scary when off.  To me it looks more obvious now what to do.

The Sound. I love the chip tune style sound out of the Arduino, but it needs to be way louder. In a large crowd, you cannot hear it at all. I think it needs an amplifier or an option for an external speaker.

Boss Level: By design, the exit at the top of the boss level does not appear until all bosses are dead. People did not understand this and tried to exit out the top early, because the boss respawns below you after the first “kill”. That caused the players to try to leave the game without ending the level. If you exited the top in this mode, the player disappeared without a way back.  This is very annoying if you get all the way to this last level.  I fixed the code so you can’t goes past the second to last LED when the boss is still alive.

New Features: I asked several people for new ideas. I got some to work on, but already added one. The attack width is now adjustable. It will default to the old width, but you can change it per level.

More levels. A typical game lasts about about 1-2 minutes. I think a few more medium difficulty levels would help.

Scoring System: It would be cool to know how you did compared to others. It could display the score as a bar on the strip, with the max possible being the full length. You could then mark your level somehow by the strip. (Postit note flag, dry erase pen, etc)

Next Steps

  • Release all the source files.
    • Firmware: I have been hacking the code quite a bit.  I’ll release my changes after some clean up and testing.
    • STL files: I have been using odd sized speakers harvested from some cheap external speakers. When looking looking to buy some, it seems like 40mm diameter is a good standard size that is cheap and available. As soon as I get some and test them, I will release the files for this size.
    • Sell on Tindie. My shield makes wiring super easy, but is definitely not required.  I think I’ll sell everything, except for the Mega and LED strip. I’ll also just sell the assembled PCB by itself.
  • New Hardware:
    • Raspberry Pi Zero W: I have looked into several hardware options and this seems to be a good candidate. I think it will be a simple way to get good audio and connectivity. I have the accelerometer and LED strip working so far.  The audio will be an I2S amp chip that will be put on a shield. The (2) drawbacks are boot time (20-30 second) and you are probably limited to APA102C (dotstar) type LED strips. Edit: I got a good portion of the code on the Pi running. It runs fine, but I don’t like the requirement for a slow and controlled shutdown of the Pi. It would require a button and some sort of visual feedback.



TWANG Pi Zero Prototype

If you want to be notified of future blog posts, please subscribe.

TWANG Shield

While the my TWANG clone has been running great, I wanted to clean up the wiring, so I made a shield to plug into the Arduino. I previously used header connectors plugging into the Arduino. The connectors go to three different places and come from all over the Arduino , so there were a lot of connectors including some single pin ones. I was worried they might pop out or fail. I also had to externally power the LED strip and supply power via USB to the Arduino.

The shield takes care of all of this and groups all of the external connections by function on easy to connect and clearly labeled terminal blocks. Here are the features I have…

  • Single 5V Power Connector: This connector powers the LED strip via a very heavy trace on the PCB. It also powers the Arduino. The Arduino is powered through a Schottke diode. If you plug in the USB, the Arduino switches to be powered by the USB. This allows you to program and hack the firmware while the LED strip is powered.
  • Terminal Block Connections: The wires are grouped by peripheral (Accel, Speaker, LED Strip) and clearly labeled.
  • LED Strip Connections: This powers and controls the LED strip. I have tested it with 4 wire (APA102, Dotstar) and 3 wire (Neopixel) strips.
  • Speaker Connection: There is an integral 100 Ohm resistor that is required when you directly power the a speaker from an Arduino. The terminal block also has 5V and Gnd in case you want to add a simple amplifier. BTW: Driving the speaker directly from the Arduino is plenty loud in my opinion.
  • Shield Size: The shield will work on both an Arduino Mega sized board or an Arduino UNO sized board. The TWANG firmware requires the extra memory of the Mega, but a tiny, reduced feature, UNO version could probably be made.
  • Life LEDs: There are provisions for 3 LEDs that are typically used to show remaining lives. I have not been using those. I prefer to use the LED strip to show remaining lives. I like working with the restriction of a 1D LED strip display.

Prototype Assembly Notes: I did not have all of the correct parts for the build. I did not have a 100 Ohm SMD part, so I tacked on a through hole part. I did not have the right terminal blocks, so I cut one and only used 3 positions for the speaker. The correct parts will arrive soon.

Here are some more images.


Future Changes

  • I will probably get rid of the life LEDs.
  • I will add a large capacitor for sensitive LEDs, like Neopixels. Right now I just connect the cap to the terminal block.
  • I will probably sell the rest of this batch on my Tindie store in a week or two. I will probably sell assembled boards and full assemblies (less LED strip and Mega)
  • I will release of the documentation under an CC4.0-A-SA license.

If you want to be notified of future blog posts, please subscribe.


I have been a Patron of Robin Baumgarten for a while. He makes experimental hardware for games. His Line Wobbler one dimensional dungeon crawler is my favorite and I have always wanted to play it. It uses a door stop spring as the controller. An accelerometer in the knob allows it to work like a joystick and also detect the wobble used to attack the enemies.

Original Line Wobbler (Robin B.)

After seeing his playable Christmas tree version of the game, I had to make one for myself. I could not find any source files that he published, but I was able to find an open source clone called TWANG. The game is quite fun and surprisingly challenging.

Original Twang Version

Electronic Hardware

Here is a list of the electronics hardware used.

  • Arduino Mega.  The Mega is way overkill for the I/O requirements, but an UNO does not have enough memory.
  • MPU-6050 3 Axis Accel/Gyro Breakout Board. These are available for about $5 and have good library support for Arduino.
  • Small Speaker. I bought a pair of external PC speakers at Micro Center for $4 and pulled out some 2″ speakers. You need to use a 100 Ohm resistor on one of the wires.
  • RGB LED Strip: The default code is written for the APA102 type strips. The FastLED library used also supports the cheaper WS2812 (Neopixel) strips. I used a 144 LED 1 meter APA102 strip. The Clock and Data type strips can work faster and they typically have an overall brightness factor that gives them a more useful brightness range than Neopixels. The brightness of these strips is insane and you typically run them at about 1/2 brightness.
  • Life LEDs: You can use 3 individual LEDs to indicate the number of lives you have left. I decided to skip that. I preferred the simplicity of a signal display element. I added a game over animation to the game to make it more clear that you are dead, dead.

Printed Parts

I created my own 3D printed parts. I was having trouble with the TWANG Thingiverse files. They are OBJ files and the parts are grouped. Cura was not creating good prints. My speaker was not going to fit anyway.

  • Chassis: I made a heavy walled enclosure to give it a little weight and make it extra strong.
  • Cover: The cover is also very thick. The speaker mounts in a pocket and is attached with hot glue.
  • Spring Clamp. This holds the spring to the cover securely. I also added a little hot glue to prevent it from rotating.
  • Knob Base. This is very similar to the official TWANG version. It has a longer, threaded interface to grab the spring. This parts takes a lot of abuse.
  • Knob Top: Snaps on, but also gets a little hot glue.

The Firmware

The firmware is well written and pretty easy to follow. You need to download a lot of libraries. Some can be installed from the Arduino IDE and some must be downloaded manually. This is pretty well explained on the Github page.

Everything works on a 60 frames/second loop. This includes the display and the sound. I was able to tweak a few things easily and add a game over animation.

The levels are very easy to edit. You really don’t need to know how to program. I tweaked a few to make them easier for beginners.


Build Spring Assembly

  • Solder wires to the accel module.
  • Slide the spring clamp over the spring.
  • Assemble the knob to the spring top.
  • Feed the wires through the knob base and spring.
  • Screw the module to the knob base.
  • Attach the knob top to the knob base.



Attach Spring to Cover (make sure spring stays vertical when attaching)

  • Adjust the metal spring base until the spring stands vertically.
  • Put a little bead of hot glue in recess on the cover
  • Feed the wires through and place the spring in the recess.
  •  Put a little hot glue around the spring where the clamp goes. Screw it down.

Attach Speaker to Cover

  • Blah
  • Attach some wires. Put a 100 Ohm, 1/4W inline on one of the wires.

Assemble Base

  • Install the Arduino Mega into the base with screws.
  • Connect all the wires per the graphic below. I wired the accel SCL/SDA at the left end, but you can also wire them to pins 20 & 21 at the right end.
  • Attach Cover


  • You need to power the LED strip with a separate 5V power supply. I used a 10A supply for my 144 LED strip.
  • You also need to power the Arduino. The easiest way is to do it via the USB port.  You could wire the power supply in the first step to the 5V on the Arduino, but be careful to never power from the power supply and the USB at the same time or something will likely break.
  • Note: I have been hooking up the LED power first. When I only power the Arduino, I see some flickering of LEDs.  That concerns me that it is drawing some power from the I/O pins.

Next Steps.

  • Make it Easier to Build: The wiring is a pain and probably not too durable. I used pins crimped into connectors that mated to the Arduino Mega. To make it easier I designed a little shield with screw clamps. It will also power the Arduino through a diode that will allow the USB to also be used. The speaker resistor is part of shield. It is also compatible with an Arduino UNO, so a pocket sized TWANG might be possible. That arrives next week. I will likely sell the extras on Tindie.
  • ESP32 Version: I would really like to try this. The sound and speed should be better and the ability to network with another player sounds cool. It is also smaller and cheaper.
  • Scoring System: Everyone want to compete.


Here is a video of the Twang.


If you want to be notified of future blog posts, please subscribe.

Coasty Controller Setup and Use Instructions


I have receive a lot of requests to sell Coasty laser cutters. It just is not practical for me to do this at this time, but the parts are easy to buy and/or print yourself. The only part that is difficult is the custom controller. I have about 10 extra ones and will sell them. If they go quickly I may buy more. They are here in my Tindie Shop.

What you get with the controller.

  • Fully assembled PCB
  • Arduino Nano programmed with Grbl and setup for the Coasty
  • An HC-05 Bluetooth module programmed with the proper settings baud rate.
  • (2) TI DRV8825 stepper motor drivers with heatsinks and the current set to a recommended value
  • (2) Fans with wires trimmed and connectorized.
  • A cable for the laser module
  • A door switch switch with proper length wires and connector.

These are the only electronic items you need to provide.

  • Laser Module: It is designed for the Eleksmaker 3.5W LA03-3500. Most other types probably won’t fit in the tight size of the Coasty or bolt properly to the PCB
  • 12V Power Supply: I recommend about 5A of current. They can be found on Amazon for less than $10. Make sure it has a standard barrel connector end.

Default Calibration

The controller will come setup with settings that work for me. You can fine tune the settings later, but these should get you started. Here are the settings you see if you send the $$ command to Grbl. The setting codes are listed here.


The homing switches locate the edge of the coaster and the left extent of the laser travel. This is not the X,Y zero of the work area on the coaster. That is set by the G54 work offset. The G28 and G30 locations are also set so they can be used as a coaster eject command. Here are the offsets you will see if you send the $# command.


Note: If you want to reset the G54 to the value above send this command  G10 L2 P0 X-186.500 Y-245.000 Z0.000 For more information regarding work offsets see this video. You could also manually jog the machine to the exact position you want the 0,0, to be and send this command G10 L20 P0 X0 Y0 Z0


I will pre-test every controller, but there are many machine dependent things that need to be tested before safely operating the machine. You should only need to run these tests once.

  1. Watch this video completely before testing anything. You will get a general overview of the machine that will help you understand and successfully test it.
  2. Remove the Bluetooth Module. It will be easier to test with USB. Never use USB with the Bluetooth Module installed.
  3. Do not connect the external power supply until advised.
  4. Make sure the little power push button switch on the controller is in the off (out) position. This switch controls the laser and fans only. Other circuits remain on regardless of switch position.
  5. Connect a USB cable.
  6. Open a serial terminal connection at 115200. The terminal should be setup to send a carriage return at the end of each line. The Arduino IDE Serial Port Monitor is an easy terminal to use.
    1. It should reply with Grbl 1.1f [‘$’ for help] and  [MSG:’$H’|’$X’ to unlock] when connected
  7.  Send a question mark ?
    1. It should replay with some status like <Alarm|WPos:186.500… , but not have any switch status like Pn:…
  8. Send the $$ command.
    1. The values in the response should match the values listed in the calibration section above.
  9. Send the $# command
    1. The replied values should match the values listed in the calibration section.
  10. Connect power to the controller, but do not turn on the controller’s power switch. Be ready to pull the plug if anything goes wrong. The machine might make some motor noises as the motors engage for brief period.
  11. Open the door.
  12. Manually slide the laser carriage to the left to activate the X home switch.  While it is activating the switch send ? again.
    1. You should see Pn:X in the response.
  13.  Block the IR detector with a coaster and send ? again. Note: The IR detector requires external power and will always register as “on” when there is not external power.
    1. You should see Pn:Y in the response
  14. The next step is to test homing. There is a chance that it will home the wrong way, so be ready to disconnect power. You must pull the plug at the controller to fill power. Watch for the laser to move to the left and the coaster to move in.
  15. Send the $H command at the serial terminal.
    1. As soon as the motors start, watch for the laser to move to the left and you should feed in a coaster.
    2. If either go the wrong way, pull the plug.  See fixing direction errors below.
    3. The machine will only try homing for a few seconds. If you were unable to get it started in time, try $H again.
    4. If the coaster does not run smoothly you might need to sand the track a little.
  16. After a successful homing, send G1 X0 Y0 F400
    1. The machine should move so the laser is over the lower left corner of the coaster.
  17. Send G28 to eject the coaster. Remove it completely from the machine.
  18. Close the door and screw it shut.
  19. Turn on the laser with the push button. You should hear the fans turn on, but the laser should not fire.
  20. You will now test fire the laser. You only want to test fire it for a should period of time at low power.  Send the following commands. While the power will be low, do not leave it on for more than a second or 2.
    1. $X (this will make should the machine is not in alarm mode)
    2. G91 (this will allow you to move it in incremental mode)
    3. S10 (This will set the beam power to 1%. Full power is S1000)
    4. G1 X3 F400 (This will move the laser 3mm to the right. The primary purpose is to put the controller into g1 mode where we can turn on the laser)
    5. M3 (should turn on the laser. It will not be very bright.
    6. M5 (turn it off)
  21. Assuming all tests passed, the machine should be ready to use.

Fixing motor direction Errors

The easiest way to fix direction errors is to rotate the connector for the problem motor by 180°. The upper motor is for the X (the laser carriage) and the lower motor moves the coaster.

Rev 2.0 PCB Issues

  • There was one mistake on the PCB due to net naming issue. The 12V input did not get connected to the 12V to 5V DC power supply.  A small rework wire has been added on the back side of the PCB.

Source Files

Use Instructions

See this blog post … [Coming Soon]

If you want to be notified of future blog posts, please subscribe.

Coasty Version 1.2

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



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.


Here is a video of this version.

If you want to be notified of future blog posts, please subscribe.

ESP32: Sending short pulses with the RMT

Well that was easy!  About an hour ago I wrapped up a blog post on creating stepper motor driver pulses with the ESP32 using timer interrupts. I added a to do list at the end to look into using the RMT peripheral to do this. It only took about an hour to figure out.

RMT stands for “remote control”. It was designed for things like an IR remote control where tight timing on GPIO is required. The peripheral has a lot of features that make it good for a lot of things. Some people have been using it for the notoriously tight timing of the NEO Pixels.

The documentation is pretty complete on the API, but there are very few examples and tutorials. Most that do exist are for complicated things and not too well commented. This Ebook by Neil Kolban has a good example that my code started from. Look for the section called “RMT – The Remote Peripheral”. Due to my limited knowledge of the RMT, I will only go over my implementation.

Basically you start with two structures…(also see code below)

rmt_config_t config;

This is used to setup the configuration. I set config.clk_div = 80 so that each unit of time in my setup is 1us.

rmt_item32_t items[1];

This is an array of items that represent the outputs transitions that you want. In my case I only want a transition to high for 3us and then transition to low with no duration . Here is the definition of that struct.

typedef struct {
    union {
        struct {
            uint32_t duration0 :15;
            uint32_t level0 :1;
            uint32_t duration1 :15;
            uint32_t level1 :1;
        uint32_t val;
} rmt_item32_t;

Here is my code. I had the pulse repeat with a 1us delay, so that is would be easy to catch some on my logic analyzer.

#include <driver/rmt>

#define STEP_PIN  GPIO_NUM_17

// Reference

rmt_config_t config;
rmt_item32_t items[1];

void setup() {
  // put your setup code here, to run once:
  config.rmt_mode = RMT_MODE_TX; = RMT_CHANNEL_0;
  config.gpio_num = STEP_PIN;
  config.mem_block_num = 1;
  config.tx_config.loop_en = 0;
  config.tx_config.carrier_en = 0;
  config.tx_config.idle_output_en = 1;
  config.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
  config.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH;
  config.clk_div = 80; // 80MHx / 80 = 1MHz 0r 1uS per count

  rmt_driver_install(, 0, 0);  //  rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int rmt_intr_num)
  items[0].duration0 = 3;
  items[0].level0 = 1;
  items[0].duration1 = 0;
  items[0].level1 = 0;  


void loop() {
  // esp_err_t rmt_write_items(rmt_channel_t channel, rmt_item32_t *rmt_item, int item_num, bool wait_tx_done)
  rmt_write_items(, items, 1, 0);

Here is a screen shot of the output on a logic analyzer. (Step/dir signals are swapped in the labels)


I think this will work great. This will will be very efficient and rum completely in the background. I will definitely try to move ahead with this method.

If you want to be notified of future blog posts, please subscribe.

Using The midTbot Controller

The midTbot Controller is a controller for midTbot pen drawing machines. It is sold on my Tindie store. When fully populated, it has the following features.

  • (2) Stepper Motor Drivers for the X and Y axes with microstepping selector jumpers
  • Servo Connector for Pen Lift
  • Arduino Nano Controller
  • 5V power supply
  • (2) Homing switches
  • Bluetooth connector for HC-05 or HC-06 module.
  • Aux power connector for easy access to 5V and 12V power.

Power Supply

You will need a 12V DC power supply with at least 3A of power. The DC plug should be a coaxial 5.5mm x 2.1mm type with center positive. This type of plug is the most common type and should be pretty easy to find.


You should use an Arduino Nano compatible controller. The controller bootloader will need to be changed to the smaller Arduino UNO bootloader in order to fit the firmware. I have instructions on how to do this here. If you would like to buy one already modified, I sell them on my Tindie store. Be sure to install the controller in the correct orientation. The USB connector should face the edge of the controller as noted on the silkscreen of the controller PCB.

Stepper Drivers

You will need 2 stepper driver modules. I recommend ones based on the Allegro A4988 controller or the TI DRV 8825 controller. The drivers often come with heatsinks. The current will typically be set low enough that heatsinks are not needed.

You will need to set the microstepping level. I recommend using 1/8 microstepping. That gives a good balance of accuracy, smoothness and speed. You set this using the jumper blocks. Each stepper driver type has its own configuration. Here are the jumper setting for A4988 and DRV8825

Microstep ResolutionA4988 JumpersDRV 8825 Jumpers
1/8MS1 + MS2MS1+MS2
1/32Not AvailableMS1+MS2+MS3

Note the MS1, MS2 & MS3 labels next to the jumpers.

The orientation of the drivers is very important. You will break the drivers and likely other parts if you insert them wrong. Most drivers have the pins labeled and the the controller PCB has the corner pins labeled. Be sure the labels match. Here are the correct orientations for the A4988 and DRV8825.

You should set the stepper driver output current to the level required by your stepper motors. The midTbot does not need a lot of power. If you set the power too high, the motor could get hot and damage the 3D printed part it mounts to. You set the current by adjusting a potentiometer and reading a voltage. The drivers need to be powered when you do this. You can install them and power the board to do this. Do not connect the motors when adjusting the potentiometer. Each driver will have a small hole with exposed metal. This is the measurement point. The metal adjustment screw of the potentiometer is also a place you can measure. The reference voltage to current formulea are here.

DRV8825 Current = VREF * 2   (Example 0.4V = 0.8A current)

A4988 is a little more complicated because there are different versions. See this page.

Stepper motors:

The controller is designed for NEMA14 motors. Be sure to get 4 wire motors. Just about any size should work, but I prefer to use smaller ones to keep the size and weight down. You will need to attach connectors to them.  Trim the wires to the correct length so they reach the board connectors when installed. Wires colors should be installed as shown.

The wiring legend on the board that shows where to plug in the motors might not be right. It depends on the way the motor manufacturer wired the coils and which stepper drivers you use. You may need to swap them or rotate the connectors 180° if your axes are moving the wrong way. Here is a photo of how mine are wired. Try this first. Note the wire colors and which motor goes to which connector.


You can add an HC-05 or HC-06 Bluetooth module. They have different connectors, but just match the pin names on both sides. You will need to setup the module to have a baud rate of 115200, N,8,1. I have detail on how to do that here (HC-05, HC-06).



If you want to be notified of future blog posts, please subscribe.