Saturday 13 September 2014

CNC Mk2 - Engraving Test

Head over to my youtube channel for a short vid on the engraving test I ran with the new spindle, rails and Z assembly.

I still can't get the homing sequence right, so just resorting to jogging to the zero positions.

I also had a small issue of CamBam inserting G-codes into the output file that grbl doesn't support, but that was a 'user' problem and simply changing some option under the CamBam config.

Note:  If you upgrade grbl on the Arduino...just don't forget that all your custom settings will be back to the standard defaults.  So when your X/Y/Z starts heading off way too far...just remember your steps/mm setting.  I'm using nema17 2.5A steppers at 200 steps per revolution, and 6mm x 1mm pitch threaded one rev = 200 steps = 1mm.  Grbl is 250 steps by default.  Doh!

Anyhoo...comments/questions welcome.


Sunday 24 August 2014

CNC...slight mods

So after some engraving testing with pyCAM, and noticing how the workpiece was moving around the base plate, I decided to drop in a piece of 15mm MDF.  The uber magnet and silicon dots I was using before just wasn't cutting it (pardon the pun).  

I screwed in a bunch of M6 MDF inserts from the underside, countersunk slightly so as to keep the underside flat, which now gives me a range of screw anchor points for clamping down the material being engraved.  It also means I don't get stressed about the milling bit going too deep and messing up the sheet of 6mm acrylic that I used for the original bed.  After everything was up and running, I dropped a 13mm straight cut bit onto the CNC spindle and program in an overlapping grid cut run.  This shaves off a small layer of the MDF across the whole platform to make it absolutely parallel relative to the X & Y axis.

I was also having a bad time with the Y axis binding as the Z carrier got closer to the ends.  This was being caused by a misalignment between the ends of the threaded rod and the nut assembly on the Z carier.  Being 3 points of contact over a 270mm wide gap means that everything has to be perfectly parallel...which is not easy when you have a small bend in the threaded rod!  So my fix was move the bearing mount as close to the stepper as possible, which also makes it easier to line up. 

I then leave the far end of the rod to flap around in the breeze, doing it's thing.  I got the idea from the way my 3D printer Z axis is engineered (except the rods sit on top of the stepper shaft, and that carries the Z axis assembly weight).  It means that the threaded rod is free to move about and not cause binding.  The whole Y axis is now as smooth as silk and a vastly reduced load on the stepper.
I'm still getting my head around this CNC, g-code, homing (machine home and workpiece home), and not willing to fork out a small fortune to get some point-and-shoot software like CamBam or I'm floundering along with  good old faithful SketchUp, pyCAM and Grbl Controller.  However, I will have a photo/video worthy run soon, and will see some nice output coming from it.


Tuesday 19 August 2014


So it's been a couple of months since my last post, but it has been time spent planning, buying parts, printing parts and researching an upgrade path for the CNC machine.  The dremel was OK..ish, but anything other than lightweight engraving (with that 'rustic' look) it was hopeless.

So..the latest incarnation shopping list went like this:

  • 13mm smooth rod for the Y axis,
  • LM13UU linear bearings,
  • 400W 12,000 RPM air cooled CNC spindle + 48v 200W PSU + speed controler,
  • A bunch of ER11 collets,
  • A bunch of 3mm engraving and cutting bits (single flute cutter and 60deg engraver)

I knew it would be a close fit with a 66mm wide gap down from the top platform and a 50mm diameter CNC spindle.  I still wanted to keep the bodywork pretty much intact, so it called for some creative thinking, and I think I've done an OK job :-)

So rather than me waffle on about it, I'll let you see for yourself.

Now some might baulk at my  penchant for using acrylic..a lot...but it's actually a nice material to work with.

I made the base plate with 10mm acrylic, everything else is 6mm.

The top support/stepper motor mount is 3D printed on the Mendel90.  I love my 3D printer :-)

Here's a closer look at the new Y carrier and Z axis assembly.  The flexi tube clamp (for the spindle wiring), bearing mounts, top stepper mount and Z screw nut carrier (with anti-backlash) was all made on the 3D printer.

The screw rod is riding on a flanged bearing in the base plate, so the stepper and coupler is under no vertical load forces.

Now..before you gasp at the lack of fixtures attaching the side plates to the base's glued on.  I used Weldon 4, making sure the edges were clean and square, and the bond is surprisingly strong.  Since it's primarily dealing with vertical forces, it is stressed in a directly upwards direction.  I messed up on my first Z movement test and almost split the top I reckon the bond is plenty strong.  Time will tell, but I have a plan for if it all turns ugly.

These are the new rods and mounts (designed and printed the mounts)

I colour co-ordinated the mounts so I would know which one went where.  Nah!!...not really..I just ran out of the blue filament when I was partway through a printing session! :-)

The old ink tank lid was an ideal place for the spindle speed controller, but required a removal of the potentiometer and wiring it back in so I could mount the pot through the side of the lid.

And the old paper tray cavity was just the right size for the 48v PSU for the spindle.

I have to run 2 PSUs (24v + 48v) which is a bit of a pain, but can't be helped.

I did have a hell time with the endstop switch signal firing and causing a hard stop, even though the axis's (axii?..axisees?) were nowhere near the microswitches..but only if the spindle was running.  So obviously I was getting some line noise, possibly from the brushless motor.

I went and got some shielded twin-core cable for the switches, tested army!  So I took the 48v PSU out from where you see it and moved it away from the rest of it..viola! line noise and no false triggers.  So now it appears that something inside the PSU is creating a lot of noise.  A quick test of clipping a small jumper lead from one of the the PSU output posts common to the case...and problem went right away.  I'm not an electrician or electronics engineer, but I reckon that by earthing the case, I'm basically turning it into a shield.  Scares me to think what's going on inside that thing...but the fix works, and hasn't let the smoke out, so I'm happy.

So now I'm getting my head around G-Simple CAM program to make some g-code to chuck at it and test the beastie.  I did a test with manual commands via grbl controller..and it's already looking a meelion times better than the previous attempt.

Will upload a video to the tube once I have tested it..providing it doesn't all go horribly wrong.


Some readers have asked for more detail about the new Z Axis assembly, so here's some Sketchup models to help explain what I did.
Note: Items in blue are the 3D printed parts, semi-transparent parts are the acrylic, and all others are standard hardware (bearings, rods, nuts and bolts, etc)

The side plates are glued to the base with Weldon #4 acrylic cement, and the top mount (which also acts as the Z axis stepper mount) is attached to 2 lengths of 25mm aluminium angle bolted to the inside of each side plate.

The 13mm linear bearing mounts and Y axis nut carrier are attached to the underside of the base plate.  The bearings are held in place by the snap fit of the mount recess, and also secured by zip ties that fit in the slots along the front and back faces of the mount.

Here is a close-up, sectional view of the Y axis nut carrier, which also incorporates an anti-backlash spring and Z axis screw rod lower support bearing.

Saturday 12 April 2014

Heaxpod (Pt 3)

The wireless PS2 controller and 32ch servo driver board arrived, and has proven to be a minor challenge to work with.

For the last couple of days, the Torobot site has been down, possibly patching for the SSL HeartBleed vulnerability, and quite clearly having a few issues..just been there and their backend database just spilled it's contents onscreen for me.  Since I'm an ethical hacker, I'll just leave them to it. :-)

However, it has given me an updated manual for the controller/servo board and also access to the command software used to create actions.

What has been really interesting is the stuff I have found regarding sending serial data to the servo board from an Arduino Uno, receiving command data from the PS2 controller over wifi!  The servo controller uses PWM, not the degree values I have been used to with the servo library.  As it turns out, it's reasonably easy, once you know the PWM upper and lower limits for the servos.

In my case, I'm using TowerPro MG996R servos for all joints.  With some messing around (trial and error), I have a PWM range of 800 to 2500 microseconds(us).  This gives me the full 180deg sweep from 0 to 180.

I'm a bit new to this, and I got un-invited to 6th Form high school so the maths skills aren't that great, but the guts of it is:

If 0deg is 800us and 180 is 2500, then midpoint is ((2500-800)/2)+800 = 1650.
It also goes that 180 deg / 1700us (PWM range 2500-800)  = 0.105 deg per microsecond.
Therefore 1 deg = 9.52us  (1 / 0.105)

So if I want to send the servo to 40 deg, then (40deg / 0.105us) + 800 = 1180.95us

Now, they aren't the most accurate servos, and when it reaches the edges of the limits, it can overshoot.  These things are capable of 10kg/cm torque, which is enough to split the casing if the servo reckons it can go past the physical stop pin.  To counter that, I knock about 5 deg off each end of the sweep, giving me a range of 5 to 175.

Now I have a PWM range of 850 to 2450, with midpoint still at 1650..cos all I did was trim 50us off each end.

Still with me then? :-)

Right....Arduino has a really cool function named "map()" which makes it an absolute doddle to translate the values coming from the PS2 controller to PWM values.  It goes like this...

map(value to change, min value it will be, max value it will be, min value to assign, max value to assign), 0, 100, 0, 1000) will return 500...because 500 is the same to 0-1000 as 50 is to 0-100), 0, 255, 850, 2450) will return the value 1650...because 1650 is to the range 850 - 2450 as 127 is to the range 0 - 255...which is really handy because the PS2 controller joysticks produce values ranging from 0 - 255 in their full left to full right range of movement...with 127 being the sticks neutral point.

The Torobot board uses a serial data string format of "#[servo port]P[PWM value]T[Time in ms]"
To send servo on port 1 to the midpoint => "#1P1650T500" mash it all together:

Connect the PS2 wifi receiver to the Uno with some female/male jumpers.  The receiver pinouts are(left to right, looking into the socket end with the D shape smiling at you):

  1. Data -> UNO pin 12 (NOTE: Must use a 10k resistor for pullup..else the signal is all squiffy and won't work)
  2. Command -> UNO pin 11
  3. Not used
  4. Earth/ground -> Have a guess..
  5. 3.3v in -> You got it...
  6. Attention -> UNO pin 10
  7. Clock -> UNO pin 13
  8. Not Used
  9. Not Used
Connect the UNO to the Servo Controller board:
  • UNO TX -> RX0 (next to the mini USB socket, bank of 3x2 header pins ahead of "S1")
  • UNO RX -> TX0
  • (Screw block)
    • Gnd -> ..well...ground!
    • VS - Voltage supply in for the servo main power..this does not power the board itself
    • VSS -> 5v from UNO for powering the board processor.  Can power from the USB and has voltage protection so you don't zap back up the USB cable
Download and import the PS2 controller Arduino Library from Bill Porter ( shout out to him and the awesome work he's done on this.

Connect your servos to the header pins...dealers choice which ones you use.

Here's my test sketch for one robot arm (3 servos), and has been vastly trimmed just for testing.
Note that you can move mulitple servos with a single line...just add the string with "#[servo number]P[PWM value]" prior to the "T" value and the final "println"  The servo controller reacts when it gets a newline character.

[code starts here]

#include <PS2X_lib.h>  //for v1.6

PS2X ps2x; // create PS2 Controller Class

//right now, the library does NOT support hot pluggable controllers, meaning 
//you must always either restart your Arduino after you conect the controller, 
//or call config_gamepad(pins) again after connecting the controller.
int error = 0; 
byte type = 0;
byte vibrate = 0;

void setup(){

 error = ps2x.config_gamepad(13,11,10,12, true, true);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error

void loop(){
  //DualShock Controller

  ps2x.read_gamepad(false, vibrate);          //read controller and set large motor to spin at 'vibrate' speed

    Serial.print(map(ps2x.Analog(PSS_LY),0,255,900,2400));     // Read the left joystick values
    Serial.println("T500");    //Send the string off to the controller board

[End code]

You may have seen the min/max for servo 3 is around the other way?..You can swap them to actually change the servo sweep direction.  This servo is for the shin section of the leg, and by swapping the values you can get it to move "leg cramping curling up" style..or "Mr Miyagi whoopass crane" style.

I have found that if you don't disconnect the power to the servo board (the 5v and/or the USB cable), the sketch won't upload to the arduino.  I'm not sure why, but I think it gets messed up with the serial data responses from the servo board?..anyone want to chip in here?

Well...after all that, I've got remote control of a hexapod leg with a wireless PS2 controller joystick.  The photo is a couple of the legs set up in a test rig to see how well the legs move and test range and servo jitter.

Just for $hits and giggles I moved the rig so it was resting in the middle of the table, then moved the leg in a "stand up" type of movement.  Impressed with those servos..because the rig is being held in place with a 3kg dive weight..and the leg tipped it off without any bother at all.

I am encouraged! :-)

I'll upload a video of the test when I can borrow the camera (again!).

Video of the abovementioned rig in action..

See ya next post.

Friday 4 April 2014

Hexapod (Pt2) it might seem a short timeframe between my last blog, and this one where I proudly announce that I have finished printing the leg parts for the hexapod.  I do actually have a day job, and as much as I would like to spend all day making robot stuff, it don't pay the bills.

I started printing the parts a couple of weeks ago, then had to wait for some hardware to turn up (long 3mm screws, 21mm brass standoffs, etc).  So tonight, I have finished the printing and assembly of the legs, complete with servos.  I did have to re-print a couple of parts because I hadn't taken into account the left side/right side thing.  However, because of the way I designed it, it was a simple case of mirroring a couple of parts in netFabb, slice and dice in slic3r, and print them out.

All in all though, everything has gone as planned, all the parts fit nice and snug, and now ready to be attached to a body.

As you can see...SU to the rescue again.  I plan to use 6mm acrylic sheet, but will wait until the servo controller board arrives so I can model it up and see where I might put the boards.

For a better view of the model, check out the new vid ( for a quick fly-around of the model.

Might be a while for the next instalment where I'll be getting the legs calibrated for midpoints on the servos as well as testing the (hopefully arriving soon!) 24 channel servo driver board with wireless PS controller.

Bye for now.

Tuesday 1 April 2014

The hexapod (Pt1) now I have the printer, have learned some stuff from building the printer and the CNC conversion...those 6 legged roboty things look way cool!..So here I go.

Been looking at a large number of designs, blogs, thingiverse thingies, youtube, get the point.  So since I'm into doing things the hard way, I will design and build my own hexy...once I have finished the printed cats that her majesty found on thingiverse, and promised her workmates I would print for them.  Cats!!...all this technology, money, combined knowledge and resources...and she wants cats!

Anyhoo...I start with SketchUp (herein referred to as "SU"), and I have been playing with SU for years.  I'm still living on SU pro 8...It's perfect for my needs, so why upgrade?  SU has a massive number of plugins which are really useful for this sort of thing.  Granted, SU is not industrial strength like AutoCAD, AutoDesk, SolidWorks or Truespace (and the many, many others out there), but a powerful beast nonetheless.  Once you add in a few plugins, you start to see exactly how powerful it is.

Once of the first to get is SketchyPhysics.  If you want to do some basic mechanical design, and then test things like movement, clearances, and general aesthetic, then this is a must.  You can add servos, hinges, pistons, sliders and then animate them.

Then you get the STL exporter...kind of goes without saying what this is for, but for the readers that are new to this 3D thing, it's the 3D model format used to create the code used by 3D printers.

There's a couple of others that I recently added since building the printer.  Shape Bender and DrawHelix combo is awesome for creating nuts and bolts.  The standard followme tool in SU doesn't work that well to create the bolt threads, or even a nice smooth helix, but ShapeBender and DrawHelix are the schizzle at it.

One more...CurviLoft.  This is one I recently started using, and for organic shapes, you can't go past it.  This would be an interesting one to try with a laserline scan of something like a face, and then use the loft tool to create a surface over the profiles.  Hmm...that sounds like a project :-)

So the grand plan involves using an Arduino board (Uno, possibly Mega), some sort of servo controller chip like the JP Serial Servo chip (24ch), MG996R servos and a whole bunch of freshly printed parts.

Here's the basic concept, with some motion added to check the actions..

Of course, best laid plans and all....The legs went through a bit of a redesign because I could see there would be problems printing those shapes, and print them in a way that maintained a high degree of structural inegrity.  Trying to screw in a self tapping screw through the side of a printed item is no just delaminates the plastic.  There's also the issue of assembly.  Very easy to design the impossible-to-assemble shape.

So what I ended up with is a little convoluted, possibly slightly over-engineered, but I reckon it might just work.  I've seen these set up with just struts on the servo horns, everything off to one side, and only pivoting on the servo shaft.  That would be OK for lasercut or CNC milled aluminium parts...but I'm printing mine and I want something a bit more here it is.

There's 8 parts to each leg, 4 parts are identical, so only 6 different models to deal with.
After some test parts, working out that you have to give items clearance (if you don't then things are such a close fit, you can't fit them!), I settled on the final design for the legs.

 Let the printing begin!

Next project...3D printer (Pt2)

(Yes...I could have written this in a single blog..but I have a short attention span and only 330ml bottles of beer)

In no particular is some points from the Mendel90 build.

Spend the $$ and get the frame templates printed on a single sheet of paper!  It took an age to get 4 sheets lined up square, not stretched, and taped together enough to survive the hole drilling exercise (..or the whole drilling exercise...either one fits)

Careful when attaching heat sinks to the stepper driver chips.  The tops of the pins are pretty close to the edges of the aluminuim heatsink block..and they don't really like being powered up with a whole side all shorted to each other.  Lucky I bought a batch of 10 of them...I have 3 left (you only need 4 for the RAMPS board)

When wiring up the Z motors, check out how to wire them in series, rather than parallel.  The RAMPS board has header pins for parallel, but it works so much better in series keeping the Z axis steppers in sync.

Get your end stops sorted!..(seems a common theme from the CNC build)..especially those Z axis stops.  Seeing your extruder try and plow it's way through the top of the print bed is not a happy thing.  Be ready to hit that reset button!

Be prepared to chew through a lot of filament fine tuning the Z height.  I can't stress how important it is to get the bed level, and the zero height set properly to ensure that first print layer goes down properly, without zits (lumps that will make the steppers skip when they get hit by the nozzle), and with enough coverage to make the print stick to the print surface enough to hold on for the rest of the layers.

Search, search, and more search...before you ask.  It's a big community out there, and they have been doing this a while.  Chances are that a noob question has been asked before.  Go look for it, and you will find a wealth of additional information on the way.

That is all...for now.