Wednesday, March 23rd, 2016 at 11:19 am - - Kayak Dive

I really have been neglecting to blog. I’m going to bang out a few quick posts on this the day before my holiday.

Saturday 12 March involved a grumpy day paddling around Hilbre Island with a rather fuzzy camera.

This is the stone wall on the northwest corner of the island at high water:

The professor on the water had just gone on a 10 day trip to Japan to use up an academic travel budget, and at the same time busted a chunk out of the dwindling global carbon budget [podcast here]. You don’t want to see what the bailiffs do when they collect on an unpaid carbon debt. They’ll take your food.

I’ve been speculating about a specialization of my Question from Hell proposal where visiting professors who have just flown to give a lecture get routinely asked about their carbon budget (which they could have avoided by teleconferencing) as the first audience question from a young student. It will be rude and ungrateful to ask such questions of a visiting guest, and will embarrass everybody. The excuses are lame.

The top excuse will be: “We don’t have the equipment”.

If that one gets a lot of laughter, the second excuse will be: “Meeting in person makes a big difference”. To which I’d like to respond: “Where’s the research?”

There isn’t any.

I’d love to set up a controlled experiment where the person who doesn’t do the 10 day trip to Japan gets to take a 24 hour bus ride to a hotel opposite a Japanese takeaway in Dundee via Plymouth and is locked-in with the internet where his only communications portal for the next 120 hours is a telepresence robot parked in the corner of the lab in Japan. He is free to rove the corridors if he’s being ignored. Maybe one of the brighter students would take pity on the robot and take it home overnight for late night chat with bottle of sake, or even for a night tour round the city on a motorbike. I hear these VR goggles and hi-def cameras are pretty good these days.

The time duration exposure, the portability, and the lessening of inhibitions could easily mean that human bonds and interaction could be much enhanced compared to proceeding to these places as a meat embodiment that smells and needs to go to the toilet occasionally.

If this Questioning takes off I am expecting that university administrators, who can be blindingly stupid, commit to ban such questions, as you cannot ban something like this without actually telling people what it is you are banning.

PS. Cory Doctorow was burning up the planet ten years ago.

Monday, March 7th, 2016 at 12:12 pm - - Machining 1 Comment »

The less said and remembered about the fighting I’ve had over the past three weeks attempting to get this working the better.


Basically, the problem was eventually traced down to a faulty solder joint on the ground pin of the six channel open collector chip which created too much of a resistance to drain the 5V signal down to ground for the gecko drive to respond in the rare case where four 1-signals were emitted from the Machinekit controller at the same time. This happened only when two of the axes were moving with the direction pins high and two step signals went to the motors simultaneously. This resulted in travel in the Y-positive direction missing 1% of its pulses so that the cutting toolpath drifted ever so slightly in the Y-negative direction as cutting progressed, but there being no effect when you jogged the table or arm axes individually. Drove me nuts, as you can imagine.

It was a learning experience. If we can nail this bug, we can nail anything (we had to check through so many other problems which weren’t there to find it), but it set us back weeks of worry, pain, late nights and missing weekends

Quick edited movie with limited footage as I forgot to film a lot of the exciting bits (like the helix ramping) as was a bit too scared to think of it.

Wednesday, February 24th, 2016 at 9:59 am - - Hang-glide

Work interrupted by a couple of mid-week trips, first to Long Mynd:

Then to Llangollen, where I didn’t fly so well and spent the entire time getting buzzed by this huge dual hang-glider that seemed always able to keep up with me.
That’s why you’re supposed to learn a lot by flying with really good pilots so you can see exactly why you’re not anything special at any time.

And anyway, the data logger was bust with a loose wire on the I2C connection. I should have enough data from the Long Mynd flight that I ought to be doing stuff with this morning. Instead I’ll probably work on the serial connection to the orientation sensor or do some on-line shopping for other electronic gadgets whose data streams I record and ignore.

Record and ignore

Remember the rule: the further removed in time and place is the data, the lower its value. While some data becomes relevant when it gets old, it’s as rare as antique furniture. You can count on the crap rotting in your garage not being within that category. The conclusion is if you don’t find an application for the data now, you’re not going to find it later on.

Wednesday, February 17th, 2016 at 3:02 pm - - Machining 1 Comment »

I bricked a BeagleBone Black on Monday by plugging a 5Vs into a 3.3V pin while attempting to get it to run a stepper motor (using the exact same installed software that we have for the milling machine tool).

Oh well. I shall have to financially reward the BeagleBone corporation for their easily broken products by getting a replacement. Time to try out one of these cheaper BeagleNone Greens if I’m going to make a habit out of this.

Here’s what my order from looked like:
Note: I ordered 2 boards so as to qualify for free shipping.

And here’s the report from Fedex of the route:

The seamless efficiency is a little bit scary. I drank a whole cup of coffee staring at it. Then I went downstairs and picked it up from the front desk.

Tuesday, February 16th, 2016 at 6:30 pm - - Flightlogger, Hang-glide

Following a very grumpy Friday and an off-the-cuff comment by someone on Facebook to the Wrynose Pass as a potential easterly site, I headed off from Bull Pot Farm into the Lake District where I have never been before.

I was not in the most ideal mood for this sort of thing, being alone with a hang-glider on an unfamiliar craggy hill at 3degreesC and 27mph wind. Fortunately I stopped myself from doing anything really stupid, and sat in the car stewing and programming until suddenly and unexpectedly the wind dropped to something between too light and perfect.

I didn’t hang around, having already scouted for my hillock of a take-off point.


Thursday, February 11th, 2016 at 3:50 pm - - Flightlogger, Machining

After months and months of stirring through the compact three-dimensional enclosed arrangement of overheated servo motor drivers and circuit boards, unplugging and plugging them back in again, attempting to tune them, and causing all sorts of interference signal spikes and yanked wire problems, I decided that it would be better just spread everything out on a triangle of scrap plywood.


Now that I have totally lost faith in these Leadshine drivers, it’s going to be easy to replace them with gecko drivers, when they show up. They have Error signal pins, which also need wiring into the system, along with other signals. Everything is now completely accessible. The folded shelter material is to keep out the rain of iron filings from the milling that can’t possibly do this circuitry any good.

Then I performed the same trick on the hang glider logger, which similarly was enclosed in a 3D box of circuits. This has been opened out onto a flat panel of wood — after Adrian warned me that acrylic would likely be too brittle and crack. (He didn’t have any spare Delrin after touting how wonderful this type of plastic is.)


It’s an enormously heavy and large panel, even though it contains exactly what was in the original setup. It’s kind of like unpacking your rucksack into a hotel room and making it knee deep in stuff.

Things have to be in the open to be worked on.

It took forever to measure out all the mounting points and design them, even though I mostly resisted the temptation to over-engineer any of it with convenient clip-together holes.


The hardest thing to design is the battery case. I wanted one where the batteries slid in from the end, instead of the usual side entry from which they tend to easily fall out. This is version 5 where the bolts holding it down go between the two battery cylinder channels.

I must have consumed about a kilo of 3D printing filament (we only had black) building all the mounting points. The old box is the coloured bit.


Originally I was going to have this panel mounted on the upright of the glider and poking out forwards on a aluminium rod, like this:


Then when I tried it yesterday morning I realized there would be too much vibration — something I hadn’t noticed while merely handling the rod in my hands without one end stiffly anchored. This wouldn’t do any good to the accelerometers.

I do get a lot of things wrong, so I am used to changing designs suddenly (hence all that scrap). I wonder how much harder it is to change when working in a team and you have to persuade more than one other person that we need to junk everything right away and not waste more time on the wrong track. It’s the inertia, so to speak.

We went walking in the rain on Saturday at Loggerheads and cycling in the murk on Sunday just before it began pelting it down. Here’s a video of the plughole at Ladybower Reservoir from that day.

Monday, February 1st, 2016 at 5:57 pm - - Adaptive, Machining

Well, at least I sorted out the metal supplies by cycling to Scimitar Steels in Bootle at the furthest public limit of the dock road and persuaded him to cut me the most pitifully small piece of mild steel anyone has ever ordered from him. Couldn’t even be bothered to charge me. I think he said the substance was “080A15 EM32B” steel, which according to kvsteel is:

General purpose steel bars for machining, suitable for lightly stressed components including studs, bolts, gears and shafts. Often specified where weldability is a requirement. Can be case-hardened to improve wear resistance. Available in bright rounds, squares and flats, and hot rolled rounds. Can be supplied in sawn blanks, and bespoke size blocks.

Sounds like the correct stuff to me.


Then, as I was fetching my bike, I spotted a picture of a milling cutter on the side of a Lloyd&Jones Engineering truck parked outside the shop, and went in. I didn’t see any on display, so I had to check their website to find out about their sensibly priced 2 flute solid carbide tian coated end mills among their limited selection. It’s 2 flute so I don’t need to run it so fast according to the feeds and speeds calculations.

Back home on the machine it proved rather good for facing off, being as I could run the spindle at 7000rpm instead of the near-stalling at the minimum of 2400 owing to the fact that the mill cutting speed surface ft/min should be 350 with carbide cutters as opposed to 70 (for “steel 4140″, whatever that is).

I got everything sorted out, probed, position and then gouged.

What happened here is one of the drivers decided to give up and go into an error state, and the other one carried on going back and forth in its arc as though it was still following the rectangle. Luckily it was only a test cut of 0.2mm deep.

This problem means it’s not reliable enough to do the whole job without a proper gouge. We need to put a feedback from the servo driver to the controller to cut everything when one of the axes trips out like this.

I reset it (by power cycling) ran it again far enough to where the linking motions came into play. I’d dialed for a toolpath with the maximum staydown and no retracts — which was a feature I spent a whole year working on.

It’s rubbish. It takes so long to retrace its steps back round the metal instead of nipping over the top. Now I understand why Mr Denmark kept referring to this as a “perception thing” when he urged me to work on this feature, because he knew (even if I didn’t) that it was a waste of time because it made a slower toolpath. But like a know-nothing that I was, I had to try it to believe it. And until you try it, you will want it. But you only need to use it once to be satisfied.

This reminded me of Adrian taking apart a cheap toy car remote control unit the other week and discovering that the aerial poking out the top wasn’t attached to anything. The circuit board didn’t need it, but since most customers believed it should have an aerial, the designers put a pretend one in for them to extend and retract to keep them happy because it was a whole lot easier than attempting to educate them about it.

I was only going for 2D Adaptive clearing here, because I am intending to control the depth with G92 settings to reposition the Z, and so be able to try different depths of cuts. This meant that the retract plane has to be high enough so it works for my lowest cuts, which is not efficient.

I’m pretty sure now that linking motions should totally be calculated by the controller, and not be done in the CAM system. It knows where the material is (and could laser scan it if necessary). That way we wouldn’t have these overly high retract planes, and it could work out its own rounded trajectories, knowing its own kinematics. That should be its job.


Meantime, I found this very detailed video blog of someone systematically testing out four different 3D printer software slicers to see how they performed on the same printer. I watched both episodes last night.

I’ve put this here to tell you that reviewing of CAM software is a thing. In this case it’s just for the extrusion 3D printers by one guy who gets the idea. You can see the core developer teams for the different products being able to use this information to direct their work, as well as for users to be informed about which is the best software to use.

In all my experience, this thing — independent benchmarking and reviewing of CAM software with an admirable degree of curiosity for the benefit of users — has never happened for 3axis machining software. Even though such software costs many thousands of dollars, runs on machines that cost hundreds of thousands of dollars, and has been around in various states of development for decades.

The problem is that customers, who are almost always professional engineering firms, are not curious and don’t go looking for stuff. Instead they’re busy earning money and working all the time. So they don’t do anything until a salesmen comes to them personally to sell them software products for them to consider. This massively inflates the prices (to cover the cost of the salesman) and guarantees that the only information they receive is biased and not even generated. By that I mean that the salesman probably won’t even know what’s the best performing software on the market. It’s difficult to find out, and he doesn’t care, because his commission comes from sales of this product only. This is a business after all. Nobody is paid to care about getting things right.

If a detailed independent review of the 3axis CAM software on the market ever took place, it should to discover which of the different products are actually using the same machining kernels under the hood. That would be a minimum outcome.

Monday, January 25th, 2016 at 1:42 pm - - Adaptive, Machining 2 Comments »

Here’s a quick offering from the “Well it’s better than nothing video editing department”. This is the result of 2 days of cutting from short videos taken with my camera. (I’ve got no talent with video editing.)

I learnt one heck of a lot in the process.

  1. Steel is really difficult to work with
  2. Small 3mm cutters are easy to snap
  3. The spindle is under-powered
  4. Big 6mm cutters can handle being bent when the spindle stalls if you hit stop soon enough
  5. You can drop the feedrate briefly to stop the spindle stalling
  6. Multiple cutters with rest machining are essential
  7. 0.1mm stepovers are a better than 0.2mm
  8. I probably need a tapered cutter to create a draft angle
  9. Clamps are a real hassle; I’m going to get a vice
  10. The noise of the machine sounds terrible, but nobody has complained yet because it doesn’t seem to carry into the hallway
  11. My 3D printed ductwork for automatically hoovering out the chips was a failure; I need to prod in the nozzle by hand to remove the chips

I was using the Adaptive Clearing toolpaths in Autodesk Fusion, which I had spent 10 years developing before and after it got sold to AD.

It sucked in several ways that I did not know about, because I’d never used it myself to get something I wanted to get done. I always said I ought to have been put on the job of using CAM software to cut steel on a machine in a factory for a couple of months at some point in my career before being allowed to continue writing software that didn’t quite do stuff right. People get into positions like I was, and seem to do pretty well, but should get the opportunity to go back and fill in some gaping holes in their experience.

The problems I found were:

1) Adaptive takes too long time to calculate small stepovers when clearing around a tongue of material and it has to turn right towards the material to stay in contact. This is probably because the sample rate has to go very small in order to maintain engagement when it does its straight line forward samples. It should detect these situations and do its initial step forward with a curve to the right so that begins with being engaged on the first sample and doesn’t need to resample backwards blindly until it makes contact again.

2) The helix ramp down pitch was not linked to the tiny stepover I was setting and I couldn’t see how to change it. I had to hack the G-code directly.

3) In spite of claims to the contrary and it being mathematically accurate, I am sure that the load going into the corners is higher than when the flank cutting is on the straight. I can hear the spindle being slowed down. This could be because the chip length is longer for the same chip width. The chip length is the distance around the circumference of the cutter that is tearing off the metal, and it can approach a semicircle in a tight corner, or be insignificant when it first engages with the 90degree outer corner of the stock.

Now a real machine tool probably has so much angular momentum in the spindle that no one is going to notice this, but on some underpowered low-spec experimental device, such as this, it becomes apparent. That’s why future innovations would happen here, and are unlikely on the big machines where you don’t notice the flaws.

I can now pretty much see how companies like IBM missed the first wave of the PC, which were toy devices in comparison to the big mainframes they were playing with. Nobody was ever going to do any real work on those barely-up-to-scratch microcontroller-based computers with deplorable amounts of RAM, audio cassette tapes for backup, a complete joke parody of an operating system from Microsoft, and a lack of customers able to pay big bucks. Most of the professional engineers in the world (software and hardware) had all the access they needed to mainframe computers in their workplace or university institutions to do fluid dynamics or graphics or simulations. I’m sure when some overly keen teenager came along with their toy machine he’d soldered together, they put him in his place with a back-of-the-envelope calculation of how many centuries it would take that Apple2 to do something real, like predict tomorrow’s weather, which was something they could do with their latest cool CrayXMP super-computer machines. PCs were obviously an utter waste of time, and because was clear where the cutting edge was if you wanted to actually get stuff done.

Sure, you could say this left a huge gap in the economy for new tech billionaires to emerge and for IBM to eventually become an embarrassment, but think about the wasted capital and precious engineering time of talented people who should have been deployed to make this microcomputer tech good from the beginning. MS/DOS and MSWord might not have existed in the horrible no-good forms they did had it not been left only to people who didn’t know what they were doing and had to learn as they went along, thus locked in their anti-productive design mistakes into the way this tech worked for the next 30 years.

Meanwhile I’ve no idea what I am doing. Should I spray WD-40 onto the metal while it is cutting?

Friday, January 22nd, 2016 at 1:03 pm - - Flightlogger, Machining

The old hang-glider flight logger is falling apart due to shoddy wiring, strip board soldering, being crammed into a 3D printed plastic box and then thrown about in my bag and on the field for a year.

The new way to do things is to design the circuit separately and then cut a special PCB for it.

I’ve been extracting and running the individual components as best I can, including digging into the airspeed probe wheatstone bridge, which unfortunately needs an INA125 amplifier that I had stupidly soldered down onto the board instead of using a socket.

I’ve got very little understanding of the numerous files created by kicad, but I have committed them. Here is the diagram of the circuit:


Now I got to tidy the mess on the desk up and see if any of the electronics still works as well as it once did before I tried to reverse engineer my own work.

Maybe I should have done it this way in the first place. But then that would have added another wall into the learning curve. (The learning curve is the amount you can get done on the X-axis vs how much you need to know to get that amount done on the Y-axis, so a shallow curve means you can get stuff done without needing to know too much.)

Next job is to get some help laying out circuits from someone who has done it before. I hope to sandwich it between two sheets of laser cut acrylic and find some slick way of mounting it on the glider so I don’t kick it on the first day.

Not only that, I’ve got to get back to looking at the data so far. As usual, hardware hacking is a lot more fun than doing the software. This distraction must end. Normal service will be resumed.

Wednesday, January 20th, 2016 at 4:57 pm - - Machining

This is about C-shaped biarcs. I’m not interested in the S-shaped ones, so I’ve not looked at them.

A Biarc is a smooth curve composed of two consecutive tangential circular arcs that can be drawn between a given pair of points with a given tangency at those points.

In many ways a biarc fulfills the job of a cubic spline commonly used in CAD to interpolate a curve between two points with given tangencies. They can be chained to form a continuous curve that appears smooth to the eye (continuous first derivative) all along its length.

Given end points and tangent vectors, there are two extra degrees of freedom for the cubic spline. These are usually called the weight factors.

A biarc has only one extra degree of freedom, which determines the point where the two arcs join tangentially.

Biarcs have a larger application in CAM than CAD for the following reasons:

1) CNC mechanisms whose motions are controlled by G-code (most of them) have G1 for linear motion as well as G2 and G3 for circular arc clockwise and circular arc counter-clockwise. They do not have codes to do arcs (although Siemens tried to market a controller in the 1990s that had NURBS), so if you want to produce a perfectly smooth path then you need to provide a sequence of tangential arcs. Biarcs can effectively act as a drop-in replacement for cubic splines.

2) Physical machines in motion are limited by their maximum acceleration which is determined by the power. A cubic spline has a maximum acceleration (minimum curvature) at only one point along its length, and this means all the other points have to be run below this value. On the other hand, a circular arc has a constant and easy to calculate acceleration for a given velocity. This means it is more likely to be programmed to attain the maximum power over a longer distance than is the case for cubic splines which are too hard to optimize.

Let’s get to the point. After days of messy algebra, similar to what’s been done by this guy and in other papers I have read, I spotted a pattern, which I have reduced to a nice theorem in plane geometry.


Theorem: Given points A and B and tangent vectors at them that intersect at E, we consider any biarc that is consistent with these endpoints and tangents. (This is defined as two circular arcs that are tangent at these points and to each other)

This biarc is drawn as the arc AC (with centre a) and the arc CB (with centre b)

If we extend the line EB to the point D so that the length of ED equals the length of EA then the point C where the two arcs meet will always lie on the circle through the points A, B and D (whose centre is c)


The points A, B, E, D are given by the initial conditions. Points C, a, b are given by the choice of biarc.

By the definition of the biarc, the line aA (which is a radius of the left hand big arc) is perpendicular to the line AE, the line bB (which is a radius of the right hand small arc) is perpendicular to BE, and the points a, b and C must be collinear for the two arcs to be tangential at C.

Let f be the midpoint of the arc AC and g be the midpoint of the arc BC and draw in the lines af and bg to form bisectors of their respective arc angles.

Extend the line bg back to the point c where it intersects the line af.

By symmetry (of af being a bisection line), the lengths of cA and cC have the same length. Similarly the lines cC and cB have the same length. Therefore the three points A, B and C all lie on the orange circle whose centre is at c which we just constructed by intersecting these two bisector lines.

By bisector symmetry the angle aAc specified by d is equal to the angle aCc, and the angle cCb is equal to the angle cBb specified by d’. In other words d equals d’.

The tangent line to the orange circle at A is perpendicular to the radius line cA; if we rotate it anticlockwise about the point A through the angle d then it will be aligned with AE. Similarly, the tangent line to the orange circle at B is perpendicular to the radius line bB, and if we rotate it anticlockwise about the point B through the angle d’ then it will be aligned with EB.

Because the construction of both these lines are the equivalent (due to the sizes of the angles d and d’ being the same), the chord lengths of Ah and Bk are the same (where A, h and E are collinear and E, B and k are collinear).

We need to equate the angles chE and chE to prove symmetry. The perpendicular bisector of the chord Ah will pass through the centre of the circle c, and therefore by symmetry around this line the angle chE is equal to 90 degrees plus the angle d. But we also know that the angle cBE is also 90 degrees plus the same angle d’ (since the lines bB and BE are perpendicular).

This proves that the triangles chE and cBE are equal. Therefore the line length Eh equals EB. Since the chord lengths Ah and Bk are equal, the length of Bk is the length of AE minus the length of Eh, which puts k at exactly the point where we originally constructed D in the statement of the theorem.

The orange circle about c passes through the points A, B and D, which is a statement that crucially does not depend on the choice of the biarc.

I’m not saying that any of the above is easy. The consequence, however, is a remarkably easy method to find biarcs.

Using my namedtuple P2 class with a few basic functions, like so:

class P2(namedtuple('P2', ['u', 'v'])): ...
def Dot(a, b):  return a.u*b.u + a.v*b.v
def CPerp(v):  return P2(v.v, -v.u)
def APerp(v):  return P2(-v.v, v.u)

Start with the points A and B with unit normal vectors nA and nB.

To find the intersection of the tangents we need to solve:

E = A + CPerp(nA)*sA = B + APerp(nB)*sB

Compute the values of sA and sB by dotting this equation with nA and nB and dividing out:

sA = Dot(B-A, nB)/Dot(CPerp(nA), nB)
sB = Dot(A-B, nA)/Dot(APerp(nB), nA)
E = A + CPerp(nA)*sA
E = B + APerp(nB)*sB  # same value

The centre point c of the orange circle lies on the perpendicular bisector of BD at an unknown distance of h along this perpendicular where it interesects the angle bisector line from E (which is parallel to nA+nB).

sH = ((sA+sB)*0.5)
c = E + CPerp(nB)*sH + nB*h

solve: Dot(c - E, CPerp(nA + nB)) = 0
0 = Dot(CPerp(nB)*sH + nB*h, CPerp(nA) + CPerp(nB))
  = Dot(nA, nB)*sH + h*Dot(nB, CPerp(nA)) + sH
h = -(Dot(nB, nA)+1)*sH / Dot(nB, CPerp(nA))

This means we’re almost done as we know where the c lies. All that remains is to choose the point C on this circle.

Project a point from the chord between hB to the circle 
centred on c with radius rC.

Let 0<lam<1 refer to a point position along this chord.

rC = (CPerp(nA)*(s1-s0)/2 + nA*h).Len()
   = sqrt((s1-s0)**2/4 + h**2)
sM = min(sA, sB)
pC = E + (APerp(n0)*(1-lam) + CPerp(n1)*lam)*min(sA, sB)
cpC = pC - c
C = c + cpC*(rC/cpC.Len())

Now all that remains is to find the radii of the two arcs in the biarc.

Left hand arc has radius rA and centre cA:

   cA = A + nA*rA

Distance to C should also be rA:

   rA = (cA - C).Len() = (A + nA*rA - C).Len()
rA**2 = (A - C).Len()**2 + 2*Dot(A - C, nA)*nA + rA**2

   rA = -(A - C).Len()**2 / (2*Dot(A - C, nA))


   rB = -(B - C).Len()**2 / (2*Dot(B - C, nB))

Basically, the entire operation is done with with a few dot products and around 2 square roots. No quadratic equations needed to be solved, so we’ve not had to mess around with choosing the right polynomial root or any guesswork which this entails.

This should be able to extend into a reliable arc fitting algorithm to a point sequence which I’ll get to at some point later.