Freesteel » Machining

We’re back here again in Denmark via the Harwich to Esbjerg ferry and slow train to Copenhagen having a look at some old machining algorithms and trying to learn what 5-axis strategies are going to be all about.

Interestingly, after years of complaints about the speed of the calculation, we’re now getting total silence on the issue, which is funny as one of the things we came here to do was sort out the parallelizing on multicore machines. Apparently, the calculations are now faster than with the competition, so it’s not a problem. The plan would be to leave it for a while for everyone else to catch up, and then put some work into it. I think it’s better to keep the advantage and push much further ahead while we’re here.

Last night we went out to see Billy Cross play guitar. The songs were all American rock-and-roll, with a lot of incomprehensible Danish chit-chat in between. Last Thursday I got to play Underwater Rugby for the second time in five years. Some time ago I had a session (reported in here) with what I think was the national squad, so I didn’t learn very much. This time it was with these guys who were very friendly and taught me the necessary tricks to know, such as keeping the ball in tucked in your armpit and adding a little spin when trying to throw it.

The power of letting python call OpenGL directly. I thought it wasn’t practicable, but it seems to be okay. Here I’m testing out the toolholder collision detection; showing a series of points where the cutter gets lifted to when there is a wide conical tool-holder in place.

The colour is according to how long the calculation takes (red for slower). It varies by where the sample is taken and will help tune where I need to make the speed improvements.

I’m working today. But there is time between compilations of code. I avoided surfing the internet onto anything democracy-related, because then I’d've got lost in something interesting and would still be at it at 3am. No chance of that happening when you restrict yourself to the webpages of CADCAM companies.

It’s good to see some of them realizing that the correct format for showing off machining features is the video. Although the quality and content — let alone the lack of sound — is very poor, Delcam has produced a selection to be getting started with. The top one repeatedly shows their user interface interchanging between loops or blobs as it area clearing path goes around corners. Now I know they’ve got a whole machine shop in their building, so why don’t we see how it cuts metal?

MasterCAM has a much better set of videos, although the user interface to them is questionable, and the image is too big. They do give narration and fade nicely between the scenes. Choose Peel Mill in the selection of videos to find a description of their limited trachoidal milling solution, otherwise only mentioned in this press release.

Obviously, both companies haven’t yet reached the state of the art for horizontal trachoidal machining embodied in our four-year-old Adaptive Clearing strategy. If they want to save a lot of time and hassle developing it, they only need to ask. Our rates have been quite reasonable.

WorkNC has 3 videos showing their old Adaptive Trachoidal Roughing. This looks like a retrofit of trachoidalism on a standard offset area clearing algorithm, truncated in the case of a core. At least, like the MasterCAM feature, it shows the capability of this way of machining deeply and cutting with the side of the tool.

I’ve checked out cimatron, solidcam, Tebis, esprit, vero, edgecam, and what became of nc graphics, and none of them seem to have any videos.

There are some on surfware, but the funny thing about it is you can find a far better video of surfcam on youtube, because it’s got music. Just say No to that grinding metal noise. OncCNC has some videos too.

Here is a video of Adaptive Clearing in graphite. And here is a page on HSMWorks where they tell you about Netviewer — a programme that allows someone in Denmark to demo the software remotely on your computer. Why not video one of those demonstrations to make it easier to show up?

It’s critical to be able to calculate the orientation of a triangle correctly, particularly if it’s the long thin kind where the endpoints differ by 1e-15 in the y direction. The orientation is either clockwise or anticlockwise, and it should be the same no matter which of the three vertices you start with.

For a triangle with points a, b and c, we consider the vectors u = b - a and v = c - a. If

CPerp(u) . v

is positive, then the triangle is oriented clockwise, where CPerp((x,y)) = (y, -x) is the function that turns a 2-dimensional vector 90 degrees clockwise.

Writing this in individual coordinates gives:

CPerp(b - a) . (c - a)
    = (by - ay, ax - bx) . (cx - ax, cy - ay)
    = (by - ay) (cx - ax) + (ax - bx) (cy - ay)

which you can either expand out into 8 terms (two of which are ±ayax which cancel immediately) and add them up, or you can evaluate them as they stand. You can get different answers; sometimes one is zero and the other is non-zero, and since the sign of the result determins the orientation of the triangle, we pick the non-zero answer.

To reduce loss of precision, sumations are done from large to small; after putting the six terms into the array double s[6];I write:

sort(s, s + 6, FabsOrder());
double sum = (((((s[5] + s[4]) + s[3]) + s[2]) + s[1]) + s[0]);

where

struct FabsOrder {
bool operator()(double a, double b)
{ return fabs(a) < fabs(b); } };

That’s the C++ done with. Now the problem. There was a conflict in the sign between one value and the other which was highlighted by the debug code, but, because it seemed infinitesimally small and we’d forgotten the significance, we commented it out and encountered a situation much later in the algorithm where there was a gouge that took a while to isolate.

The calculation problem.

In the above equation, if by = cy, then the the alternative ways to calculate the result are given by the two sides of the equation:

p (r - s) - q (r - s) = p r - p s - q r + q s

And if r - s is positive, then the result should be positive whenever p > q

But here’s a table of calculations that happens.

s 13.014700000000001 * t - 13.014699999999999 * t
20.0 5.6843418860808015e-14
20.677 0.0
21.0 5.6843418860808015e-14
1e15 2.0

Now I had been counting on the right hand column to be increasing, because 13.014700000000001 - 13.014699999999999 > 0, but unfortunately it does not. This explains how I can get the wrong sign in the answer, rather than 0.0 when the precision falls off the end, because I am taking the difference of two values where s is increasing in the expectation that the difference of the products will increase too.

This has been a day’s work. I’ve marked this down as yet another of many things to watch out for with floating point arithmetic.

Meanwhile, after scratching my head all day over this problem, the BBC reported that some computer keyboards are dirtier than a toilet seat. If I saw a toilet seat as grubby as this keyboard is now, I wouldn’t sit on it.

I’d recently read the following paragraph in the glossy accounts of VI Group plc:

The Department of Trade & Industry awarded a grant of £81,000 for the development of modelling technologies particularly applicable to areas of mould design that are not easily accessible to users of current precise modelling techniques. It is anticipated that this project will come to fruition in late 2006.[1]

when a friend of mine was building a Freedom of Information webpage and needed some examples to test it with. After a bit of messing around with the fact that the DTI has been replaced by the BERR,[2] and anyway it wasn’t awarded by them in the first place, we received the following reply about the grant from the Southwest Regional Development Agency:

I can confirm that Vero International Software were awarded a SMART award on 7 May 2003 for the development of modelling technologies particularly applicable to areas of mould design that are not easily accessible to users of current precise modelling techniques. In total they received £143,805.35 between 7 May 2003 and 8 Feb 2005. The South West Regional Development Agency holds a project file concerning this SMART award.

SMART (now re-branded as Grant for Research and Development) was a national Department of Trade and Industry product to help individuals starting up businesses and small and medium sized enterprises already based in England carry out research and development work on technologically innovative products and processes. By offering a grant towards the costs of carrying out the research and development work, the scheme encouraged businesses to carry out projects that they would not necessarily undertake without the grant.

The work carried out in SMART projects is often genuinely confidential and may lead to patentable ideas. In other cases the know-how developed is a trade secret. Following your request, Vero Software were contacted to see if they would agree to the release of any of the project information that we hold. They considered all the information to be commercially confidential. Our Freedom of Information (FOI) Decisions & Appeals Board then met to consider whether or not an exemption applied to this information… [and] decided that it is not in the public interest to release the information we hold about this project.[3]

So where did the £81k number originate? Now nothing in the Vero accounts has ever made any sense to me,[4] but I am starting to notice the liberty with which the money men are willing throw around totally meaningless figures like confetti. For example, in the preliminary results released last week:

Net debt increased to £2.7 million from £2.3 million. £2.6m of this relates to term loans from UK and Italian Banks repayable over 5 years. The company has total short term borrowing facilities of £1.4m in Italy and the UK to cover its working capital requirements. Interest payments during the year were £211,000 (2006: £81,000) and were covered 6 times (2006: 13 times) by profits.[5]

That’s a lot of increase in interest for a small increase in debt, don’t you think? The good news about debt levels that were touted six months ago totally vanished:

Net debt has reduced since the year end to £1.7m (31 December 2006: £2.3m).[6]

Whatever. The debt may have something to do with random acts of acquisition.[7] Just imagine the difference I could make to the world with that kind of money.

As far as I can see, all this gibberish is for one purpose and one purpose only– to persuade investors to buy shares in their company. That is, if they aren’t mind-bogglingly bored by the whole exercise first. For a software company in this day and age, they’ve managed to make their business appear exceptionally dull.

I have observed the steady increase in shareholding by a one Peter Gyllenhammar and his Union Discount Company of London Ltd[8] who, according to the 100% PR flim-flam that is the excuse for a business press, is a “Swedish activist investor”

specialis[ing] in companies trading at substantial discounts to net asset value or in need of restructuring, often through his investment vehicles, Erudite, F�rvaltnings AB and Silverslaggen. He often seeks board representation and works closely with management. Gyllenhammar has a background as an analyst and corporate finance advisor to several major Swedish corporations. He has interests in a number of UK public companies, and is chairman of British Mohair Holdings, and a director of Browallia International. Current significant holdings include Densitron Technologies, European Colour, The Jarvis Porter Group, Lonrho Africa and The Sherwood Group.[9]

This has been going on for about a year, and I’m still waiting for something interesting to happen.

Anyways, back to the FOI request. The answer is not good enough because communications between Vero and the Regional Development Agency about the extent of their proof that the money was actually used to carry out a project Vero would not necessarily undertake without a grant must be disclosed. They can give me the documents, but with all the trade secrets blotted out.

Unfortunately, this requires a complaint to be made through a different email address, and the FOI system doesn’t handle that yet. So there will be a delay. Hopefully a short one because my contacts are with the programmers rather than through a no-nothing manager in charge of the project who’s only option is to fob me off.

(Actually, the guy in charge of the FOI project, knows what he is doing. But that’s not my point– or maybe it is… That being if no one with any influence is interested in the software, then the software will probably wind up being uninteresting. See?)

You just can’t make this up!

On behalf of Vero Software, I as Chief Executive, make a commitment that we shall:

  • Actively encourage and support our employees to gain the skills and qualifications that will support their future employability and meet the needs of our business/organisation.
  • Actively encourage and support our employees to acquire basic literacy and numeracy skills, and with Government support work towards their first Level 2 qualification in an area that is relevant to our business/organisation.
  • Demonstrably raise our employees’ skills and competencies to improve company/organisation performance through investing.

Don Babbs

Same photo appears at novo executive research consultancy whose mission is “to make a significant commercial contribution to our clients’ successes through delivery of imaginative, creative and effective consultancy solutions.”

Now I’d be surprised if either a CAD/CAM company or a corporate executive recruitment company has managed to hire an employee without basic literacy and numeracy skills; and if they did they’d probably sack them immediately. It’s tough out there in the world of business: no room for dead wood losers or people who won’t contribute all their time to the bottom line.

But this is a Government idea. People obviously get a different perspective from the top of the heap above the sht storm. Weird ideas surface from there. To a Prime Minister or President, all these business leaders seem like jolly good chaps, don’t they? It’s as if they’re quite ignorant of the inherent nature of hierarchies: people in them treat those above with the greatest respect and humility, and those below as scum of the land who must pay back every right to a decent living.

There are transcripts of the Skills Strategy launch in June 2007 on the website of the Department for Children, Schools and Families, rather than where you would expect on, say, the Department for Innovation, Universities & Skills. How this strategy fits in with the third stupidly named Ministry, the Department for Business, Enterprise and Regulatory Reform, the one in charge of selling out to liaising with corporations, I do not know.

Isn’t it sweet how they care so much about us? All those junior ministers and corporate executives appearing in videos on the website Skill Stories, which has some very skillful graphics. I’ve surfed it for an hour and could find no substance in any form I could recognize. There is one dodgy statistic about functional illiteracy repeated ad nauseum by the likes of The Right Honourable Lord Jones of isoft Birmingham (Digby Jones) at the skills strategy launch event:

What I do is not on behalf of the government. I’m not the government skills envoy, I’m the UK skills envoy. I don’t do this for the government, I do this for the country because this is so important. But we do need a government representation to do this and there is a new commission, as you know. The new chairman is being announced today and he’ll be coming in with Gordon and Alan. More of that anon.

As you know, there are 7 million adults in this country today who are functionally illiterate. There are more than 11 million adults - some say it’s up as much as 17 million – who cannot add up two three figure numbers. That statistic has probably got better over the last few years, not worse. But of course, in the past, we used to put them down the pit, we used to put them in the fields, we used to put them in lime and oil and car factories, we used to put them in shipyards and woollen mills, cotton mills and steel mills, and those jobs have all gone. If we don’t do something about this, if we the employers in the public sector, in the private sector, in the third sector – the voluntary sector – if we don’t do something about this, this country is going to have a very, very nasty century.

Now I agree that it is going to be a very, very nasty century, and it is something to do with the lack of political literacy of the working class who would have strung up this bunch of clowns in jail a decade ago if they had any sense. Extraordinary rendition is good enough for any politician who is willing to lie that it isn’t happening.

In the first seven years of this century, the self-proclaimed literate ruling elite has — all by itself — sunk the world into a 6 trillion dollar war, presided over an utterly unnecessary financial crisis, and have participated in a morally unforgivable delay and denial about the need for action on climate change. This century is not going to end well. How nice of them to be concerned about whether we have enough skills to be put to use on their thoroughly evil schemes.

I have programming skills by the bucket-load, and so do many of my friends. But the standard business logic and employment contract law under which most people work forbids them to discuss or transfer those skills to other people. It’s commercially confidential, you see. Those skills are for them. They’re not for you and your friends. Even if it was your friends who taught you to program.

I spent over a week on a report that the Z-slicing was too slow. In particular it was five times slower than Machining Strategist. As I’d authored the code in that product back in 1994, and there was no evidence of substantial change, this wasn’t good enough.

Here is a Z-slice of a wobbly test surface.

Performance seemed okay when we first looked at it. The problem was most acute for very small tool diameters. A common function the Danes like to use in their machining algorithms is Silhouette Boundary. For this we define a very tall tool with a tiny diameter and ask for a Z-slice at height below the lowest point of the model. The tool only touches on its shaft and the result is exactly the shadow of the entire model, offset outwards by the shaft radius. You can offset this contour inwards to reach the desired result.

The silhouette boundary is used in HSMWorks to limit the extent of parallel passes machining. I can’t see the point of this, because it means you don’t machine the extent of the surface depending on its slope at the edge. For example, consider the convex hemisphere. The silhouette is a circle. Machining with a ballnosed tool whose central axis constrained by this boundary means you miss the edge by slightly less than the radius of the tool. If you want to machine all the way to the lower rim you have to offset the silhouette outwards by the tool radius, and then the boundary constraints will put the tool right on the limit at the tangent point of falling off the edge.

This is where it gets nasty.

Because the cut-off contour is on the exact margin where the tool drops off the model, half the points will fall off, and half the points will stay on. That’s the nature of using a curve along a line of discontinuity, and it has nothing to do with the precision; it would still happen if you were splitting electrons. If the Z-low plane is some distance below the split line of the model, then this boundary will produce a horrible zig-zag mess of toolpath ends at the edge. The best way to clean this up is to discard all line segments where one end makes contact with the Z-low base plane.

This works, and the beautiful thing is that the “clean-up” stage is so effective that you don’t need the silhouette boundary in the first place! All you need are parallel passes within a bounding box, and then you discard all toolpath motions that are in contact with the base plane to give a result that is as-if you trimmed it to a tool-radius offset silhouette boundary, only better.

The best way to fix something is to argue that it doesn’t need to be fixed.

This didn’t wash. They also use these boundaries for constant scallop machining. I had to look harder.

The Z-slice function is based on the creation of a slice for one triangle at a time, and using an area model that can very quickly find the union between these single triangle slices. This merges to create the contour for the whole part. In Machining Strategist I did it for a whole triangle at a time, which meant that there were duplicate calculations for these single triangle contours according their shared edges and points. In HSMWorks I tried to optimize out this duplication by separating the triangle into its seven components (1 facet, 3 edges, 3 points). However, by applying the facets last after the edges and points, I created an intermediate stage where the area model was highly fragmented (and therefore slow) before all the triangular holes were filled in. This was particularly bad when the tool diameter was smaller than the average triangle and could fall through.

Simple answer: rearrange the code to change the order of the parts.

It improved it a bit, but still didn’t make it fast enough.

After a few more days looking at it I found that someone had altered the size of the bucketing of the surface. The bucketing is important so that for each component of the area model (it’s composed of fibres, as seen in the skeleton model below) you don’t need to apply all the triangle components from the whole model, but just the ones in the local area.

This stage, which I think is known as “preparing the surface” in the HSMWorks task manager, was taking too long to execute, so someone had widened its resolution to “speed it up”. This wasn’t very helpful because it slowed everything else down, including my Z-slicing routine.

Well, at least that got to the bottom of that. There is an optimal value for the bucket width so that the sum of the time to generate the buckets and the time for the Z-slice is minimized — and it had been set far from optimal.

This then becomes another thing on the list to look at first when I get the next complaint that it is not running fast enough.

Theoretically, the algorithm should be running faster than the version in Machining Strategist because it is the same but more developed. In practice I don’t know, and I am not very interested.

Generally, the programmer only hears about it when the code is running more slowly than the rivals; nobody bothers to mention it when it is running much faster. In this world, when a programmer does produce something significantly faster because they immediately get used to it. Instead it’ll be the programmers in the other companies who will get hassled about it, while the guy responsible for producing something efficient has no idea of the grief he has caused.

That is, until he quits and works for one of those rival firms and his earlier work is used as a stick to beat him.

Things falling behind here. With all these distractions like seeing a public inquiry and expanding wikipedia articles such as SS Castilian as I have just taken order of Volume 2 of the best dive guide ever (coz it covers my local area). Only thing wrong with it is there’s no kayak diving.

I have to try to do less with wikipedia. It must be those marine wrecks which caused me to find the
UNESCO Convention on the Protection of the Underwater Cultural Heritage
(not signed by the UK). Anyway, it has to stop. Not even when attracted by a page with the title Middle Mouse.

I’ve got lots of serious HSMWorks bugs piling up which need sorting out NOW! Too many days lost on the constant scallop again. I discovered better ways to choose the place to subdivide the cells. Many issues disappeared, I hope.


Right, I’ve been at this algorithm continually since before I went to Euromold at the start of December, and I’m bored now. It doesn’t crash. It runs twice as fast. It now has the capability of operating in parallel on multiple processors — which I thought it did before, but I had made a mistake.

There’s still lots of cruft, unnecessary functions, code that needs to be cleaned out, and improvements on the fact that, in the pictured example, if doesn’t operate perfectly when two sides of the collapsing toolpath appear on the same vertical wall, but who cares? This needs to a major rest and reprieve to collect some further bugs.

Meanwhile, our colleagues are at SolidWorkWorld showing off the new Solid Gold Star Partner Solution Product HSMWorks. The other two Golds in the sector are called SolidCam and CAMWorks. All we need now to complete the picture is a new product called “SolidHSM” which, for the sake of symmetry, would have a similar performance. Later, a Chinese hacker would merge them all together into one single categorically superior multi-kernel system called “HSMCam” which everyone could download for free but didn’t because they preferred to use MasterCam.

There’s a SolidWorksWorld podcast, which I have now downloaded. I wonder what it’s going to be like to listen to.

This press release about the winner of Mori Seiki’s Cutting Dream Contest (news inexplicably released from “Gloucestershire, UK”) cites WorkNC as the CAM system of choice by Kawanami Ironworks of Kyoto for cutting their amazing metal jacket.

So much for my recent rant about what appeared to be the effects of WorkNC system in Berlin.

The engineer responsible at Kawanami Ironworks explained the process. “The model was entirely made up of free form surfaces, so the most difficult task was planning the sequence of operations and positioning the job datum.” The ultimate aim was to produce a finished product which properly represented the look and feel of the jacket. He continued, “The majority of the part was cut with WorkNC’s machining between two curves strategy. We found that this gave the best result for expressing the softness of the fabric.” Kawanami Ironworks’ engineers also used many of the other finishing toolpaths in WorkNC, these enabled them to pick out the fine detail and access confined areas without tool or holder collisions.

I stand in awe. However, this is clearly in the 5-axis department. I am a 3-axis expert, although getting a bit tired of it now. Eventually I will get all the programming I need done and then I can move on. 3-axis is special because there is no more than one cutter location for every point on the model. This means the field isn’t endless because the basic algorithms and geometric structures on which everything else is built can be counted on the fingers of one hand (even if the most fundamental one is generally overlooked by academic study). 5-axis has two degrees of freedom for every point on the part. This makes the whole business a lot less obvious.

What’s missing is a good video on youtube of the winning entry. WorkNC, at least, has some videos of small operations on their webpage. (Not all of them impressive, but it’s moving in the right direction — video is the natural media for promoting these products.)

Meanwhile, the sponsor of the competition, Mori Seiki machine tool company (Japan), looks highly interesting — not only because they have an eco policy.

Their Digital Technology Lab (DTL) in California has…[link]:

pioneered in proactively working with the following CAM software vendors in helping them develop post processors for Mori Seiki machines. Through this collaboration our mutual customers will now be able to get reliable post processors as soon as they purchase Mori Seiki machines, hence jump starting their productivity. Working with several top CAM software vendors enables our customers to choose the CAM software(s) of their choice and be able to fully utilize the machines. DTL provides post processor specifications, requirements, testing and consulting support to the CAM software vendors. DTL also provides assistance in creating realistic machine solid models to our partners, so they can build Machine Simulation solutions as an added benefit for our customers.

About time too, I’d say.

The history of post-processors, in my opinion, encapsulates everything that is wrong in the CAM industry. There is virtually zero communication between the machine tool manufacturers and the CAM software developers. The language accepted by the machine tools has never been successfully standardized, and continually forks. And the machine tool manufacturers do not take any responsibility for the chaos they have created.

Contrast this with printer manufacturers who will distribute printer drivers for their printers and your operating system without any questions. There are thousands of them. I’ve never known why they can’t all use the same driver since they all do the same thing with the same input, so why not put the transformation which specializes it to the hardware in the printer itself?

With machine tools, the CAM system supplier has to build the post processor to drive the machine. You can phone up the manufacturer, but the most you will get is a copy of the manual documenting thousands of features you never need to use. No working code. Nothing.

So usually in the CAM company someone who doesn’t know anything (for example: me) botches something up to replicate the look of a file which the customer has supplied until he is happy with it. Maybe it sets the feedrate on every single line, or just when it changes. Maybe feedrates are on their own line, and rapid motions are programmed with G0, F9999 or FMAX, you never really know why. But as long as the customer is eventually happy, you never know if he’s losing 15% of the efficiency of the machine because there are too many unnecessary characters and causing block starvation. Amazingly, we heard problems about how machine tools stalled creating marks because it moved faster than it processed the motion instructions. Given that the machine is always varying its speed to go round corners outside of the control of the instructions, why couldn’t it slow down a little to avoid this stalling? Why couldn’t we get a warning? We were in no position to debug it. Usually it needs lots of points to go round corners, so should be going slower anyway. As the speed of processors was increasing faster than the speed of the machines, we ignored this problem and hoped it would go away.

I wrote the postprocessors at NC Graphics for six months before I even saw a machine tool. Even today there’s a man who makes a living by writing post-processors from scratch. Post-processors should be the first place where open-source software gets a foot-hold in this industry. Machine tool manufacturers should write them, distribute them, and maintain them to encourage best performance from their machines.

Mori Seki has a page explaining the status of post-processor development for each CAM system, eg MasterCAM. Unfortunately these link to the CAM vendor’s webpage rather than to a direct download. They seem to be reluctant to step on the toes of the CAM software suppliers. They say:

Mori Seiki or DTL do not recommend any CAM software in particular and it is up to our customers to decide the best choice for their needs.

Why! What are they afraid of? Why don’t they do some benchmarking and give us guidance so that we know which parts of our software are substandard, and which parts are great? Nobody has any idea.

Bad Behavior has blocked 608 access attempts in the last 7 days.