Archive for the 'Prototyping' Category

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.


Hobby/RC Servo Control in PSoC



The PSoC family is my go to line of processors for prototyping.  It is like having a breadboard full of digital and analog circuits that you can wire up on the fly. I have been doing some stuff with hobby servos lately so I needed to figure out how to do it on the PSoC.

Hobby Servos


From Wikipedia


Image from Adafruit


Hobby servos set their rotation based on the length or a repeating pulse. The pulse should be 1ms to 2ms long and repeat every 20ms.  One end of the rotation is at 1ms and the other is at 2ms.

The PSoC PWM  Component


The PWM component is perfect for this job.  The PWM component can be setup to have a period and an on time.  The period should be 20ms and the on time would be between 1ms and 2ms.  The component uses a clock and two counter values.  The component will count on every clock pulse.  It resets the counters after the period count has been reached and the CMP value determines how long the pulse is logic high.

The PWM output goes to the servo control line.  Here is the configuration dialog box for the PWM component. The graph at the top is a good reference for what the output will look like.


The goal is to have a pretty decent resolution to set the 1ms to 2ms pulse.  I chose a 2MHz clock.  I picked the fastest clock that would still fit within the 16bit (65535) limit of the control.  PSoC clocks are derived from system clocks, so you need to pick values easily divided down from them.  The IDE helps with creation of these clocks.  At 2Mhz the period (repeat rate) should be set to 40,000.  The equation is the clock * period(in second) = period counts (2,000,000 counts/sec * 0.02 secs = 40,000 counts).

The CMP Value is how many counts the high pulse should last.  The equation is the same. For 1ms the count would be (2,000,000 cnts/sec * 0.001secs =  2,000 counts) and for 2ms the counts would be 4,000.  The range is 2,000 to 4,000 (2,000 count resolution).  This is better than most hobby servos can do.

The Code

The IDE will generate a bunch of functions, a custom API, for each component used when the application is built. There are two PWM Component functions we need to use for this application .

  • PWM_Servo_Start() This will initialize the component and get it running. This is called once at the beginning of the program.
  • PWM_Servo_WriteCompare(val) This sets the CMP Value that will be used to set the pulse length.

I also wrote a function the can set the value by degrees.

void setServo(float degrees)
unsigned int val;
// convert degrees to compare value
// 2000 to 4000 = 0 to 180
// value is
val = (degrees / 180.0 * 2000.0) + 2000;


The Results

Here is a screen shot of my logic analyzer. The output was set for 1/2 rotation. The pulse is 1.51ms and the period is 20.14ms.  That is close enough for me.  It is likely the clock speed is different between the PSoC and  and the analyzer.



Typically you will have to tune the to the actual servos used.  Just tweak the endpoint values until you get the rotation you want.

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






DIY Jumper Wires

I love using these jumper wires for prototyping. They work great for breadboards and Arduino headers.

You can buy them all over the place including SparkFun.  They are available male/male, male/female and female/female in various lengths.

Sometimes you need to hook up something that already has wires attached. I got these pins and single pin housings from Pololu the other day.

I really like them.  The housing works for either male or female pins.  You can either manually crimp the pins with a needle nose pliers or use a real crimper.  The crimper works for both the male and female pins.

Here are the links to the parts.  If you know of other sources, please add them in the comments.

Male Pins

Female Pins

Single Pin Housing.


Proper use of a crimper is a learned skill.  You need to take the time to learn it.  I lend out my crimpers all the time.  Many people try to use their first attempt in project.  The pin falls off or does not have a connection.  They then give up and use pliers.  The bottom line is there is no better way to put the pin on than a proper set of crimpers.  This is how the professionals do it.  It only takes a few attempts to get it right.  Take the time.

One of the biggest mistakes newbies make is stripping too much insulation.  It is usually just a tiny amount and only the length of the wire barrel portion.  It is very important that the insulation barrel of the crimp grabs onto the insulation.  That is the thing that really holds the pin from being pulled off.

I always buy my crimpers from eBay where they are usually about 25% of retail.  Avoid generic or all purpose crimpers.  Try to get the manufacturers brand.

The crimpers I used are Ampmodu Mod 90418-1.  The can be found used on eBay for around $50.  Pololu suggests you can use this general purpose crimper.  I also have that crimper and it works better than anything you could do by hand, but is no where near as good as the real one.  The 90418-1 has a little “gate” thing that fits between the part the crimps on the insulation vs the part that crimps on the wire.  This allows it to crimp just right on each part and sets the depth of the inserted wire.  It also has two different wire size ranges.You can see this gate in the picture as the shiny bit with the square cuts.



Pololu Compatible Relay Driver

I just got my production boards for my Pololu compatible relay driver. This is a little plug in module that can be used to drive off board relays. It uses the signals that are normally used for step and direction to control two relays with the voltage that is normally used to power motors.

Pololu stepper drivers are great little items.  They are inexpensive and very easy to use.  You only need a step and direction signal to control them.  If you use them in sockets, as I show here, they are portable between projects and experiments.  If you accidentally smoke one, you only need to replace the single driver.

There are a lot of carrier boards for these.  There are Arduino shields and many other applications.  Often, it would be nice to be able to drive a larger external load like a spindle or blower.  You can then use the existing step and direction signals to drive the relays.  It uses the voltage normally used to drive the motors for the coil voltage.  The only wiring required is two wires to the relay.

I chose to put the relays off board because the real estate was pretty limited and I wanted to provide the voltage isolation for AC powered devices. I am also a big fan of DIN rail mounted relays. They are very reliable and inexpensive. They are easy to swap around and have some nice features. The relays shown have a LED indicator and also a manually test button that moves the contacts. The relays shown are about $10 each, including the DIN rail sockets.

I got the boards from Gold Phoenix in 2 sheets of 50. They were not cut out, only V scored. Fortunately I have access to a depanelizer at work and was able to easily separate them. I probably could have snapped them apart too. The depanelizer looks similar to this one. Two slowly spinning sharp disks chop them apart.

The boards have all the components required to drive the relay including a supression diode. I am using a pretty hefty transistor here, but you could substitute a smaller one.

Schematic (PDF)

Gerber Files

New 3D Printer For Sale

UP! Printer

There is a new additive thermo plastic printer for sale at  They call it the UP! printer.  They are selling the first 100 units for $1500 USD, then the price goes up to $2990 USD.  They claim a 0.2mm resolution.  The models do look quite good.  There was a video, after the jump.

UP! Printer

Continue reading ‘New 3D Printer For Sale’

Arduino G-Code Stepper Controller

rStep Project

Reza Naima has been working on an Arduino G-Code Interpreter.  There have been a few other projects like the grbl projects and the rerap type machines have some g-code history to them.  Most of the project is being documented over at the rStep Google Group.

It is nice to see more and more open source G-Code interpreters for micro controllers out there.  In some projects this can free up the PC or at least reduce the need for expensive and or complicated CAM controllers like Mach3.  A quick look at the firmware shows it handles a decent sub set of  G-Code commands including arcs.

rStep Arduino G-code Controller

To see the video…. Continue reading ‘Arduino G-Code Stepper Controller’

Ink Jet 3D Printer

This looks like an interesting hack.  There are not a lot of details, but apparently there is some good information at the Yahoo DIY 3D Printing and Fabrication Group and at  It looks like a lot of work and the results are questionable, but if you’ve read any blogs here you know I never criticize people for showing early, but rough results.

It appears he uses paper sheets on the powdering tray to set the height of each pass.  Remove at sheet and the level moved down.  Great, simple, consistent idea.

See video after the jump.

Continue reading ‘Ink Jet 3D Printer’

The Age of the Self Replicating Machine.

MC Escher - Drawing Hands

There is a saying amongst DIY CNC router builders that goes something like this… “You only need to build your first router good enough to build you second one“.  In my case that turned out to be true.

I built a wood, conduit and skate bearing Solsylva router.  I painstakingly layed out the various pieces using calipers, t-squares and compasses.  I cut them out using hand held tools like jigsaws and drills.  It worked remarkably well, but every time I routed out a perfect CAD drawn piece, I always thought “Gee, I wish I had this thing when I built the router“.

It wasn’t too long before I built my bigger, better, more accurate router.  I was able to use tougher materials, hold tighter tolerances and cut more exotic shapes.  It works much better.  A few months ago I finally pulled off all the good bits and Sawzall’ed the old one apart to get more room in the shop…a bitter sweet day.

Most of today’s designs develop inside a computer.  Resolution and accuracy are infinite in this realm.  We expect our fabrication machines to output similar accuracies, but how does one construct a machine with this accuracy with common (analog) tools.

Today’s open source machine are addressing this head on.  There is a big push towards self replication.  Struggle past the first one and the rest will be easy.  It is not just an accidental bonus it is initial design requirement.  It is a lot more work, but I think it builds the strong communities behind these projects that help insure their success.

Here are three examples of self replicating machines…

Continue reading ‘The Age of the Self Replicating Machine.’

D.I.Y. Selective Laser Sintering – Update

SLS Printer XY Stage

Update. Peter is still working on his SLS project.  He is experimenting with a new fully laser-cuttable x/y stage.  He is catching some flack for the ideas in some blog comment sections like hackaday.  Obviously there is some refinement needed for accuracy, backlash, etc, but I applaud his efforts.  I am sure some of his ideas will find their way into the final design and we will all benefit from it for this and other projects.

If he was just building a device for his own use, it would probably be easier and cheaper to use conventional materials, slides and gears, but he is clearing spending a lot of time to design something the budget conscious maker can afford.

Many people put similar questions to me on the design of the open source “self replicating” laser cutter.  I have redesigned and rebuilt constantly to lower the costs, tools and skills required to build it.  I swapped out very robust milled aluminum parts with laser cut Acrylic ones to prove they would work.

His most recent changes area aimed at removing the “shearing/binding issues” from the previous iteration.  He is using Kapton tape (Polyimide-film) to reduce friction and using a four gear contact point.

Continue reading ‘D.I.Y. Selective Laser Sintering – Update’