I showed off an early version of my DrawBot Badge at the Hardware Happy Hour last night. Some tweeted pictures generated a lot of questions, so I thought I would write a quick post about it.
I have been following the #badgelife thing for a few years and felt that the mechanical and CNC world needed to be represented. The goal was to create something small, safe, fun and something anyone could learn to use. A drawing machine seemed the perfect fit.
Drawing Surface
I decided to use 3″ square Post-It notes. The main feature is that they are self stick, so I don’t need any clamps or tape. It is also cool that you can stick them to things when the drawing is done. They are cheap and easy to find. I like the kind that have the majority of the back (full stick) covered in adhesive. This means you can use a small stack of them and peel them off as they are done.
Drawing Mechanism
I tried to make the drawing mechanism as tiny as possible. The size is about 30mm x 70mm. It uses (3) of the smallest readily available class of hobby servos call micro servos. You can buy these from AliExpress for as low $1-$2 in low quantities. The choice of the arm configurations was primarily based on tightly packing the the motors, but I also wanted something new and interesting.
The pen lift is simply a cam on one of the motors. The entire mechanism rotates on two 3mm bearings. In my experience with drawing machines, gravity is the best way to engage the pen to the work. The mechanism needed to work hanging from a lanyard or sitting on a table.
Electronics
There is only one electronic item right now. It is an ESP32 dev module. There are also (3) connectors for the servos and (1) for voltage monitoring. The entire back of the badge is a PCB. I made the board full size to enclose the back and the pen lift cam need to push on something. I have big plans for the rest of the area though. The ESP32 provides the Bluetooth and Wifi needed for the remote control.
Firmware
It is running my ESP32 port of Grbl with a little hacking for the servos. The ESP32 uses an RTOS, so I just created a low priority, repeating task (20Hz). The task checks the position of a virtual CNC machine, does some kinematic math and updates the servos. The software supports streaming drawing data (gcode) via serial port, bluetooth, SD card or wifi. I am using the bluetooth option to send via my phone. I will publish the firmware soon.
Crazy Math (Kinematics)
The math is actually not too hard. You know the desired pen location, the axes of the servos and the lengths of the linkages. There are two ways to do the math. The first way is using the law of cosines and the Pythagorean theorem.
The second method uses intersecting circles. Each linkage can sweep a circle from a axis point and radius. Any two linkage’s circles will intersect at two points. It is easy to pick one of the points as more desirable. While it is less deterministic, due to the two points thing, it appears to run about 40% faster on the ESP32.
The Z is very simple. Any Z value less than 0 is pen down and everything else is pen up.
Drawing Quality
The quality is basically “Adorably Wiggly”. I am using the cheapest analog servos. That means I might get about 200 x 200 resolution at best at the servo hubs. If you mapped that grid to the paper it would be a warped grid with dense and sparse areas of the grid due to the non-linear nature of the mechanism. Digital servos with very low deadbands (~1us) it would probably do a lot better, but I am not sure that is worth it. It would only be a little less wiggly. They cost about 4x what analog servos do (still pretty cheap).
There is a calibration feature. Each servo is a little different and it is difficult to precisely mount the arms at the right angle. The calibration adjusts the zero angle and pwm/degree of rotation.
Next Steps
This project is part of a talk proposal for Hackaday SuperCon 2018. If that gets accepted, the badge will become a full featured CNC controller capable of running a router, laser cutters, high res plotter, etc, as well as the Drawbot badge. Only the DrawBot will be populated. The rest will be modular like this board.
I may also make a simple version that is only the draw bot. The BOM cost is currently about $10-$12 (without 3D printed parts)
Regardless of what happens all source files will be publish sometime in October.
Follow me on Twitter (@buildlog) or subscribe to this blog if you want to follow the project.
If you want to be notified of future blog posts, please subscribe.
I recently ran out of the original TWANG shields. I took the opportunity to make a few changes.
Audio Jack
The internal speaker is powered by the Arduino I/O pins. This limits it to the low voltage and current that those pins can provide. In normal environments that sound has plenty of volume. I have used it at some very loud events where that sound level is not loud enough.
This version adds a standard 3mm (1/8 in.) audio jack. You can connect this to a powered, external speaker.
Power Capacitor
Some old LED strips like the WS2812 are very sensitive to voltage spikes that might come from lower quality power supplies at turn on. They recommend adding a large capacitor to reduce voltage spikes. A larger 1000uF capacitor has been added to the PCB, so you do not need to install it externally.
Life LEDs
The TWANG firmware supports the use of remaining life LEDs. The firmware normally shows the remaining life LEDs on the LED strip. This has the advantage of making it easy to change the lives per level without having to change your hardware. On version 1, there was a place to install (3) life LEDs, but the LEDs were never installed. This version removes that feature.
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.
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.
I wanted to complete a start to finish project with the LX-16A bus servos to do a complete review of their viability for the type of mechatronics projects I do. The low price of the LewanSoul bus servos make them a competitive option over digital servos. I chose to do a remake of the Line-Us clone drawing machine because I would not need to spend too much design time and it would be a good 1:1 comparison with digital servos. Since the bus servos are quite a bit larger, I decided to scale up the machine by 1.5x.
Made My Own Brackets.
I started by buying one servo and it came with brackets. When I went to get more, I noticed the price was lower. I did not realize I was getting these without brackets. These are the brackets you get with the more complete kit.
I requested some 3D models from LewanSoul. They were only able to provide 2D DXF files, but they were easy to convert in Fusion 360. This allowed me to 3D print some brackets. It actually worked out quite well because I was able to thicken up the brackets and integrate some captive square nuts.
They mounted easily to the servos and were plenty strong for this project.
Servo Arms
I made two arms and one short cam for the Z. They were about 4mm thick and had a little pocket that slid over the standard round actuator. They screwed on with the screws that come with the servos. Before mounting anything I turned on the servos and moved them to the center of the range. This put the arms at a known angle.
Support Bracket and Base
The support bracket holds all three servos and there are 2 pockets on the bottom for some shaft bushings.
The base has two shafts pressed into it.
The shafts slide into the bushings and there is a spring to hold the parts together. The spring prevents the pieces from separating and also provides a little extra pull down force in case the shafts bind a little. The cam provides about 6mm of lift.
Final Assembly
The servos are mounted to the support bracket.
The wires are connected to the servos. They just daisy chain from one servo to the next.
The remaining links are then connected.
Testing
Here is a video of the first run.
Results
I think these are a good alternative to digital servos. They are very strong, easy to mount and accurate. Depending on the design of the controller, using a simple UART might be easier than having multiple PWM signals or extra hardware. The servo’s size might be larger than some machines need but that comes with the higher power.
Source Code
Some people have asked for the source code. Here is what I have. I just tweaked something I had to be good enough for this demo. I can’t offer support for it other than a few quick questions asked on this blog post.
I designed this machine to draw custom, round drink coasters. I already have a laser cutter for square coasters and I wanted to try something unique for round coaster.
The Base
The base of the machine has two stacked 5mm bearings in the center for the bed to rotate on. There are (3) 3mm bearings on the bed perimeter that provide support and keep it level. They have little shafts that snap into the base.
The Bed
The bed is a 156 tooth GT2 pulley. It has little springy fingers that grip the coaster when it is on the bed. The bed connects to the motor pulley with a closed loop belt.
The Radial Arm.
This is a belt driven, cantilevered arm that uses 6mm shafts and linear bearings. The belt is a cut pieces with the ends clamped at the carriage. It has a slotted mounting hole that lets the arm rotate. The pen must be adjustable to get to the exact center of the coaster or the drawing will be distorted. There is a limit switch on the top. This is the only axis that needs to be homed. To setup the machine you home it and jog the pen until it is exactly over the center of the bed. You then set the work zero for X (Gcode: “G10 L20 P0 X0”). This only needs to be done once. If you use different types of pens, the center should be rechecked.
The Z Axis
The Z axis uses a micro servo and a cam to control the height of the pen. The firmware is setup to only have (2) Z positions, pen up and pen down. It uses 3mm rods and tiny little 3mm linear bearings. There is a compression spring on one of the rods that applies a little pressure to the pen, and allows the pen to float a little on uneven coasters.
The Controller
I used my Grbl HAT controller. It is a bit overkill for this project but works perfectly. It is attached to a Raspberry Pi in this photo, but I have not been using the Pi in this project yet. I just connect directly via USB.
Kinematics and Pre-Processin
See this blog post on how it was done. The pre-processor is written in C#, but it is rather simple and you could probably read the source file and convert if you cannot deal with C# on Windows.
Firmware
I use a modified version of Grbl 1.1f. Grbl does not support servos, so I needed to hack that in. I used the PWM that is normally used for the spindle speed to control the servo. I turned off the variable speed spindle option and streamlined the spindle functions to the bare minimum I thought Grbl needed. I adjusted the PWM parameters for use with a servo and added pen_up() and pen_down() functions. I tried to put as much of the custom code into one file spindle_control.c. I had to add a few lines in stepper.c to look at the current machine Z height and apply the correct pen up/down function.
CAM
You can use anything to generate the gcode that works with Grbl. The pen will go up when the Z is above zero and down when it is below zero. Therefore, you want the Z movement as short as possible to speed up the drawing and not have the pen dwell on the material and bleed. I make the depth of cut 1mm and the z clearance 3mm.
CAD Files.
The design was done using PTC CREO 3.0. A STEP version of the design is linked at the end of the post.
Performance
It does a great job. Here a recent coaster. This was done from a rasterized bitmap image found online (searched: circular Celtic braid).
Here is a Fat Tire beer themed coaster.
Coasters are made to be super absorbent, so larger tipped felt pens tend to bleed a little too much. I like to sketch with Micron pens and the thinner ones really work well on this machine.
Build You Own?
The build is not difficult, but covers a lot of areas. You should know how to work with STEP files and compile firmware.
The design is open source with no commercial restrictions, so feel free to use any part of my work. I found most of the parts on Amazon and eBay. I bought the belt from Stock Drive Products. The polar motor pulley is 36 tooth and the arm pulley is 20 tooth. Cutting the shafts requires an abrasive cutoff wheel.
Please post any questions in the comments section and I will try to address them.
There is quite a bit of wiggliness on my drawing bot. While it is a bit adorable as it draws, I wanted to see if I could improve the line quality. I thought increasing the the rate at which I updated the position would make it smoother. I took it all the way up to 48Hz, but was not getting much better quality than I did at a 1/4 of that.
Analog Servos
I little research into analog servos brought some possible solution to light. Analog servos are controlled with a PWM signal. The PWM pulse should be between 1ms and 2ms and repeat at 50Hz.
The basic technology inside an analog servo has been around longer than I have. The circuit converts the signal pulse into a voltage based on it’s length. The output shaft is coupled to a potentiometer which also outputs a voltage. These two voltages are compared to produce an error voltage. The error voltage would be positive or negative based on which direction off the output shaft potentiometer is from the input signal voltage. This voltage is sent through an amplifier and then to the motor. The motor turns in the proper direction until the error voltage is zero.
One problem with this method is the voltage to the motor is proportional to the error voltage. The motor will have very little torque when the error is small, as would occur with small moves.
To keep the servo from being overly sensitive to small changes changes in the pulse length, the servos have a deadband. Over sensitivity would cause jittering and use a lot of power. The deadband is expressed in microseconds (us). Analog servos typically have a 5us deadband. If the error is less than the deadband, the servo will not move.
If the servo pulse range is 1ms to 2ms or a 1000us range, then this causes the second problem. A 1000us range divided by the 5us deadband is 200. This means I basically have to move more the 1/200 of the usable range to get it to move. The full range is 180° so I have roughly 1° resolution. That will cause lines to look very jittery.
Try this to get a feel for an analog servo. With the servo receiving a commanded position, attempt to rotate the output. You will notice two thing. First you will notice the strength of the servo is proportional to how far you twist it off the commanded position. The second thing to notice is noise and vibration. That vibration is the 50Hz PWM period.
Digital Servos
Digital Servos use the same same basic input method (1ms to 2ms pulse) to preserve backward compatibility, but everything is done digitally. Additionally, most of the servo’s parameters can be programmed. The digital circuit does not need to be limited to the 50Hz period and the control loop can be more sophisticated than simply using the error voltage.
The two immediate things I can take advantage of is lowering the deadband. I can program it down to 1us or on some servos even lower. This give me a 5x improvement in resolution. The other thing is the higher torque at small moves.
Try this to get the feel for a digital servo. With the servo receiving a commanded position, attempt to rotate the output. You will notice two thing. First you will notice the strength is very strong regardless of how far you twist it. The second thing to notice is noise and vibration. That vibration is going to be a much higher pitch.
The results.
The results are subtle, but I think it is better. With no changes to the firmware it got a little better. I changed the update rate from 50Hz to 200Hz and it got a little better again.
I used Hitec HS5055MG servos. I wanted a brand name servo, I know I could program. Out of the box the servo only had about 90deg of rotation. I was able to up that to about 178. I was quite surprised I could not get 180°. That needed to be accounted for in the kinematic or the shapes are distorted.
I think if you want the best, go for the digital, but in my opinion, the improment in quality did not justify the cost.
Paul Kaplan, originator of the Easel project, came up with another way to do the kinematics for the Line-us Clone. My method used intersecting circles. His method uses the Law of Cosines.
The Law of Cosines relates the lengths of the sides of a triangle to the cosine of one of its angles.
This can be used to find the angles of the servo arms.
(Click on the images if you want a larger view)
The Goal
The goal is to find the two angles, A1 and A2, of the servo arms
Known Values
Px is the desired X location of the pen
Py is the desired Y location of the pen
L1 is the length of the upper servo arm (50mm)
L2 is the length of the end of the Pen Arm (50mm)
Step 1
Find the distance “D” of the pen to hub using the Pythagorean Theroem and the angle T1 using arctangent.
Px2 + Py2 = D2
rewritten … D = Sqrt(Px2 + Py2)
T1 can be found using the arctangent or inverse tangent formula. Note: When programming use the atan2(x,y) function to preserve the quadtrant.
Find T3 using the Law of Cosines. We want the left one of the two T3 angles, but since the linkages form a parallelogram that same angle shows occurs in several places. We will use the right one and the dimensions associated with it.
Determine A1 and A2 from the angles we figured out.
A1 = T1 + T2
A2 = A1 + T3
Conclusion
I think I will switch the code to use this method. I think I can optimize it better in C code. The speed of the code is important. The faster it runs, the most times per second we can run it. The more often we run it, the smoother it will run.
Last week I made a Line-us drawing robot clone. Unfortunately I had no good way to make it draw easily. I thought I would give the CNC toolpath a shot. My goal is to have a super portable thing to generate conversation at meetups. If I used Easel it would allow anyone with a web connection to easily make something.
Grbl
The most compact machine controller is Grbl and I have a lot of experience with it. Grbl is designed to send step and direction signals to stepper motors. The draw ‘bot uses hobby servos. The nice thing about hobby servos is they don’t need to be homed. They have feedback to tell them where they are. They also don’t care about speed, acceleration or steps/mm. They just go wherever you tell them as fast as they can go. It occurred to me, the easiest way to hack this into Grbl was to not modify the Grbl code at all. I would let Grbl think it is using stepper motors. I would just add some extra code that runs on regular interval to tell the hobby servos where the stepper motors are in 3D space and they would be told to go there. I played around with some intervals and 8 times per second (8Hz) seemed to work pretty well. The ‘bot uses machine coordinates. The work coordinates are offset to the left because the ‘bot cannot draw at 0,0. The pen would crash into the frame.
PSoC
I recently port Grbl to PSoC. I used (3) 16bit PWM components to control the hobby servos. See this blog post on how I did that. I then attached a 8Hz clock signal to an interrupt. The interrupt sets a flag when it is time to update the servos. When the main code sees this flag it does the calculations and and sets the PWM values. Keeping the code out of the interrupts gets Grbl happier.
Easel
Easel is already setup to use Grbl. You can either import gcode or create a design right in Easel. I started out with importing gcode because the Benchy design was not in a format I could import. I created a template that shows the allowable work area. This will allow anyone to quickly create a drawing.
2D Benchy
I wanted to have a little fun with the first print. “Hello World” was not good enough. 3D printers use benchmark prints, so I thought I would do a 2D version of the classic 3DBenchy. To get a 2D drawing of 3DBenchy, I traced over an image with the line tool in CorelDRAW. I then exported a DXF of that.