Archive for the '3D Printing' Category

Bus Servo Draw Bot

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.


Here is a video of the first run.


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.


The Polar Coaster – A Drink Coaster Drawing Machine

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.


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.


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.


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.







Digital vs. Analog Servos


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.



Yet Another Way to do the Kinematics


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.

T1 = atan2(Py,Px)

Step 2



Find T2 using the Law of Cosines

L12 + D2 – L22 = 2 * L1 * D *cos(T2)

rewritten …  T2 = acos( (L12 + D2 – L22) / (2 * L1 * D))

Step 3



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.

L12 + L22 – D2 = 2 * L1 * L3 * cos(T3)

rewritten … T3 = acos( (L12 + L22 – D2) / (2 * L1 * L2))

Step 4



Determine A1 and A2 from the angles we figured out.

A1 = T1 + T2

A2 = A1 + T3


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.


Line-us Clone Controlled by Easel and Grbl

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 Logo 250px

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.


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 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.


A Line-us Clone


I have been going to the monthly Amp Hour, Hardware Happy Hour meetup.  A lot of people bring something to show.  My projects are too big.  Also, you need to bring your own power.  The meetup standard seems to be running off a USB cord. I was brainstorming ideas, when I saw the Line-us project on Kickstarter. It looked like the perfect size and power. I also love the challenge of non linear kinematics.


I decided to make a clone of it.  I started by importing one if their drawings into CorelDRAW and scaling it up to 1:1.  I then added some measurements.  I rounded them up to 80mm for the pen arm and 30mm and 50mm for the linkages.


I looked into hobby servos and found that the “mini” size looked about right.  I ordered 4 of them from Amazon.  I made sure to get metal output shafts because I thought I might have to press them into the 3D printed arms.




I created a basic design in PTC CREO.  I added a lot of construction sketches for the linkages to help me with the kinematics later.  I downloaded a model of the servo from GrabCAD  to use while I waited the delivery.


I used 3mm bearings for all the joints.  These are pressed into the linkages.  This would allow me to firmly tighten the joints and not have to worry about slop in the joints.


When the servos arrived, there were slight differences in from the model.  The mounting holes we much smaller at about 2mm.  I had to reprint with some changes.

My concept was to press the arms onto the servo shafts.  This sort of worked, but after a few crashes, they loosened up.  I ended up using a drop of thick super glue to secure them.  They were able to stall the motor without slipping.  It is important to mount the arms at the precise angle.  I made an Arduino sketch to hold the servo in the precise position while attaching the arms at the angle I wanted.  Each servo has a 180° travel.  The upper arm travels from 135° to negative 45°.  The lower arm travels from 45° to 225°.


In order make the pen go where you want it to go, you have to figure out what angle to set the arms. This is not a simple linear equation. You have to solve a multi-step geometry problem for each new location. I’ll walk you through the basic process. I placed the axis of the two servos at XY 0,0 to simplify things. You know the desired Pen Tip location, so start working back towards the cranks.

  • Step1: Find the Pen A point. You know the lengths of the linkages between the 0,0 point and the pen tip. They are both 50mm. Each arm end has a set of points where it can exist that scribes a circle. If the desired pen point is within reach of the machine, the circles (green ones) will cross at two points. The solution is a well documented process. I used the C code from this page. So far, I found that using the location, of the two, with a higher Y value is the one to use.
  • Step 2: Find the Pen B point. Pen B is easy to find because you now know the slope of the Pen Arm. Multiply the X distance from the pen tip to the Pen A point by the ratio of the length of the pen arm (80mm) over the length of the arm from Pen Tip to Pen A (50mm) and add it to the pen tip. Do the same for the Y axis.
  • Step 3: Now that you know the Pen B location, you can do the intersecting circles (red ones) trick again. This time I used the left most point of the two.
  • Step 4: Find the angles. Use the X and Y distances of the crank tips and the atan function to get the angles. ( angle = atan(deltaY / deltaX) )

Another problem with non linear machines is that moving between two points will not be a straight line. The points will typically be connected with a slightly curved line. You need to constantly recalculate points along the way to keep it straight. If you break a line into smaller segments, the connecting curves also get smaller to the point where they are not notices.





Everything I chose was for prototyping ease and probably not the final solution. I used an Arduino UNO as the controller. I used a PCA9685 based servo motor controller for the servo. The Arduino could probably handle it on its own, but the wiring is so clean and simple with this. I used a breadboard power supply to power the servos. It had a handy switch to kill the power to the servos without killing the Arduino.




The Results

Here is a video of the machine running. The rectangle is hard coded via some for loops recalculating at 1mm increments. The results are shaky, but consistent with the Line-us results. The machine is quite rigid. Most of the shakiness comes from the servo motion. I also do not have the machine held down. If I get some magnets like Line-us, it might help.


Open Source (sorry)

I don’t think it is fair to the Line-us folks to release any files at this time. I think there are plenty of resources in this blog post if you want to clone it yourself. So far I only have about 5-6 hours into the project, so it is pretty a pretty easy project.

The real Line-us looks very polished and they are selling it at a good price. I am sure a lot of the work they did was on the UI, which I did not replicate at all.

Next Steps

I need a way to stream drawing data to the machine. I would like to use g-code. It also needs a UI and I thought Easel might be best. For the gcode I might try hacking Grbl. I would just add a timer that reads the current location at about 5hz, send it through the math and set the servos. Any value above Z 0 would be pen up.

For Easel, I could create a template that shows the usable work area. You would then just click Carve.



Here is the firmware I used.  It is a quick and dirty port of my PSoC port of Grbl. I cannot give support for this. Only experienced PSoC programmers will be able to install and use this.

Grbl Line-us PSoC Firmware

CAD File

Here is my STEP file of the design. This contains all of the printed parts and some of the hardware.  You will need to figure out a few things on your own.

Line-us Clone STEP File







Camera Slider Controller Hack


I have been having fun with my camera slider controller.  It is a cool, little, general purpose motion and camera controller that will soon to go on sale at Inventables. Taking a picture is very easy.  You just plug the camera into it and run the takePicture() function.  It has a lot of spare I/O pins that can be used for some cool hacks.

I always thought it would be cool to take a time lapse movie of a 3D print, but do it exactly one layer per frame and have the picture be taken at the exact same location every time so the print appears to grow out of thin air.  I know people have done this before, and I could probably hack the circuit right onto the printer controller, but camera slider controller was ready to go with the circuit and connectors all ready to go.  With less than ten minutes of coding and making a cable, I was ready to go.

GCode Hacking

The first task was hacking the GCode to output a a signal I could read remotely.  Kisslicer has a feature where you can add a few lines of Gcode every “N” layers.  I added the following GCode.  Note the “1” in the layers box.  This means do it every layer.




G1 X0 Y0 means move to 0,0

G4 P500 means dwell for 500 milliseconds.  This was added because the next command was happening before the move completed.  I think this has to do with the way commands are buffered.  I think there is a more elegant fix for this, but adding a little delay here was a quick fix.

M42 P11 S255 means set I/O pin 11 to full on (255  is max).  Pin 11 is the first of the “servo” pins on my RAMPS controller.  This three pin connector would map directly to the servo connector on the camera controller.

G4 P1000 is a 1 second delay.  I had my DSLR on “auto” so it would need to focus for each shot, so I gave a little extra time.

M42 P11 S0 turns pin 11 off.

I ran a few test layers with my volt meter hooked up to the connector and it looked great.

Camera Slider Controller Hacking

The controller has 2 servo connectors that are intended to be used for hobby servos in a pan and tilt arrangement.  The signal pin on the connector can also be used as and input.  The code is simply going to watch for that pin to go high.  When it does it will display the next layer number and take the picture


Arduino Code

In the setup() section you need to make the PIN_SERVO_1 pin an input because that is connected to the printer controller.

pinMode(PIN_SERVO_1, INPUT);

The loop() section looks for the PIN_SERVO_1 pin to go high. When it does the layer number is incrememented the picture is taken and the LCD is updated. The camSignalRead flag is set so we don’t go read the same pulse more than once. The flag is cleared as soon as the signal

void loop() {

   if (digitalRead(PIN_SERVO_1) == HIGH) {
     if (!camSignalRead) { // make sure we read once per pulse
       camSignalRead = true; // 

       lcd.cursorTo(2, 0);
       sprintf(sVal, "Layer %d", layerNumber);


   else {
     camSignalRead = false; //reset this. the pulse is over 



Simply connect the signal pin (D11) on the servo 1 connector of the printer controller to the signal pin on the servo 1 (J7) connector of the camera slider controller. You also need to connect together a ground pin on each controller.






Camera Setup

I setup my DSLR on fully automatic and disabled the flash. I am sure the movie would have been better if I manually focused and locked the speed and aperture settings, but I just wanted a quick result. The controller first sends a focus signal and then a shutter signal. The focus signal acts like the half button push you do to focus most cameras.

The Print

The printing was done on the Quantum Delta printer.  I used my CNC Ninja Squirrel as the test print. It was scaled to 50mm tall. At at 0.25mm layer height, that gave 200 layers. The print took about 45 minutes with the added delays. It was run in a busy room at Pumping Station One so there was a lot of activity in the background and some light level changes.



The Result

Click here if the video is not displayed below.


CNC Translator for BeagleBone

The Rosseta Bone is a “universal” CNC translator for BeagleBone Black.

Rosetta Bone

The BeagleBone is awesome little controller.  It is a lot like the Raspberry Pi, but it has one special feature that makes it viable for CNC.  It is the PRU.  This is Programmable Realtime Unit.  This a part of the CPU that runs separately from the OS and gives it the critical timing required for smooth stepper motor control.  People have tapped into this and LinuxCNC to make a real embedded version of LinuxCNC.  Add in all the other capabilities like HDMI, keyboard, mouse networking, etc and things get amazing really fast.


I bought the BeagleBone Black which is the second generation BeagleBone.  It has more features than the original “white” version and actually costs less.  There are several CNC capes for the BeagleBone, like the BeBoPr or Replicape, but they are expensive, can be hard to get and some have issues with pinout changes that came with the BeagleBone Black.

BeagleBone CNC

Continue reading ‘CNC Translator for BeagleBone’

Web Page G-code Viewer

Try this Web Page G-code Viewer

I met programmer and maker, Joe Walnes, through a few local Chicago maker groups.  He  showed me a really cool web based G-code viewer he wrote to preview his 3D printer G-code.   It used WebGL for super smooth motion of the model.  It also allowed you to drag and drop your own files right into the page.  It worked great, but really only worked with 3D printer G-code.  He posted the code on GitHub.

I have a couple programming projects in the works that need a G-code viewer, so I decided to update his program to handle more types of programs.  Joe had a really nice UI and design pattern for the code, so I left that  alone.  He also helped me out with a few issues as I worked.

G-code Parser

A parser is a bit of code that breaks down text into tokens, or the basic grammer of the G-code.  He was working with very well formatted G-code so his parser was pretty simple.

G1 X5 Y5 Z6 E0.124

I was dealing with really Fugly lines of G-Code like this, so I needed to totally rewrite the parser.


Graphics Generation

Reprap 3D printers basically use G1 (straight moves) for everything.   I needed to add the code to handle G2 and G3 (arc moves).  This was a little tricky because there are no arcs in WebGL.  I had to break them into small line segments.   Joe also treated each Z level as a separate layer.  That is nice for printers, but not for general G-code.  I changed that and the way the color of the lines worked.

A Work in Progress.

It works on all my CAM generated 3D printer and CNC router G-code, but I want to add code to deal with more advanced features that are often hand coded like incremental moves, machine offsets, parameters, math functions and subroutines.

I will post the source code soon.


You need a WebGL capable browser like Chrome, Opera or Firefox.  I hard to turn on WebGL  in my Firefox.  I got it to run on my Android phone in Opera, but could not spin/zoom the model with the screen controls.

To view your own files, just drag and drop the G-code into the browser.  It will use the zoom settings for the previous model, so if you drop something that is a different size or offset to the side you may need to zoom around to find it.


Filament Extruder Competition – $40K!

Inventables announced a filament extruder competition the GE Garage at Maker Faire on 5/19/2012.  The contest is to design a machine to extrude ABS or PLA filament from pellets to 1.75mm using less than $250 worth of materials.  The extruder must be able to add the colorant as well.  The first person to upload a solution wins.  Inventables plans make pellets and colorant available to people to play with.

The prize is $40,000 and a desktop fabrication lab.  The lab consists of a laser cutter, 3D print and a ShapeOko CNC router.  The details are at

Filament is running about $40-$50 dollars.  That is about 5-10 times the cost of raw pellets.  This would be a great resource for a MakerSpace, HackerSpace, club or school.