Freesteel » Machining

Trying to clear some space on the front page of freesteel in order to fill it with videos and other attractive stuff. I’ve uploaded the old ones we have had there from years ago:

That final one has some banjo music in it rather than the usual machine tool howl.

We desperately need to get in to a machine shop and make our own footage at some point. Must lean on the university a bit harder.

Unless you can see what you are doing, it’s hard to program it. I’m trying to make some algorithms which work, before I have time to make them fast. As you can see, the model has very few triangles to make the holder collision calculations quick. But it is also an extremely hard case.

Current strategy involves creating a waterline pass for a sphere (a ball-nosed cutter without the shaft) and then find a smooth trajectory of holder orientations that do not collide with it.

Step one is to find any trajectory that works. Step two will be to make it go smoothly.

Suppose you have a function called process() which you want to apply to the members of an array, like so:

ProcessAllSingleThread(array<A> a)
{
    for (i = 0; i < a.size(); i++)
        a[i].process();
}

If it’s okay to execute the process() function simultaneously on entries of the array, the computation can be distributed across several processing cores using multiple threads, like so:

global ndone = 0;
global inext = 0;
bool ProcessAllMultiThread(array<A> a)    // several threads can enter this function
{
    while (true)
    {
        synchronized:
        {
            if (inext == a.size())
                return ndone == a.size();   // false means other threads are working
            i = inext;
            inext++;
        }

        a[i].process(); 

        synchronized:
            ndone++;
    }
}

… or some other more complex and correct form that involves the ability to chunk up groups of elements in the array a if the individual process() functions are so trivial that the synchronizing events would overwhelm them individually.

The important thing is it’s not be important to the daily programmer how it is done. All we need to learn is learn how to encapsulate the simple single threaded version in a way that makes it possible to engage the whole multithreaded system.

To do this effectively it helps to have a framework that is general enough to apply to most places you want to.

We can remove the dependency on using an array, and base it on a class T that can return pointers of type A to make a loop like so:

while (true)
{
    synchronized:
        b = T.getnext()
    if (b == 0)
        return T.alldone()
    b.process()
    synchronized:
        T.release(b)
}

The above ProcessAllMultiThread() fits exactly into this system, which is now flexible enough to handle when the process elements are not quite independent of each other.

For example, if it’s unsafe to process a[i] and a[i + 1] at the same time, but a[i] and a[j] are safe for all abs(i - j) >= 2, then by including a variable processstate in the class A initially set to NOT_DONE, we can implement the two functions, like so:

T::getnext()
{
    for (i = 0; i < a.size(); i++)
    {
        if ((a[i].processstate == NOT_DONE) &&
            (a[i+1].processstate != PROCESSING) &&
            (a[i-1].processstate != PROCESSING))
        {
            a[i].processstate = PROCESSING;
            return a[i];
        }
    }
}

T::release(b)
{
    b.processstate = DONE;
}

These functions, subject to some obvious debugging and efficiency improvements, should fit into the parallelizing machinery and make it move forwards when you finally get your shiny new eight core computer and need to prove that the investment was worth it.

Now this framework isn’t quite good enough for cases where there is an aggregation of a result. It needs to be taken further.

Suppose the process function returns a value, and you need the sum of these values. For example, you are measuring the area of a surface composed of a billion triangles with a loop of the form:

sum = 0
for (i = 0; i < a.size(); i++)
    sum += a[i].calcarea();

Let’s assume it’s okay to chunk this sum up into sub-sums, so you don’t need to lock the sum variable a billion times. The framework we might use is:

synchronized:
    w = T.getworkspace()
while (synchronized: w.loadnext()):
{
    w.process();
    synchronized:
        w.release(); 

    optional:
    {
        sychronized:
        w.commitdata();
    }
}
synchronized:
    w.commitdata()
synchronized:
    T.releaseworkspace(w)

I’ve actually got no knowledge of parallel processing, and I don’t want to know anything about it. What’s important to me is the idea I can deliver my algorithm within a set of brick-like (ie small enough to hold in your hand, but large enough to make things with) building blocks so that someone who does have the time and inclination can put them together.

It’s very much like the sort routine. I’ve no interest in the quick-sort, shell-sort or bubble-sort at all. What I do know is if I prepare an array and an operator<() function on its elements, then I can take whatever is the state of the art at the time.

The sort function is something that can be obviously parallelized by virtue of breaking the array up into large chunks and merging the sorted pieces. This only works when your operator<() is thread safe, which it almost always is.

In our code we’ve created the new function called sortMT() that will automatically engages all this machinery if it finds that the array has over a thousand elements, say. Now we have to go through the code everywhere, changing sort() to sortMT(), because the non-threadable case is the default, even though it’s likely to be a very rare exception.

So why don’t we just make sort() to use multi-threads, and establish a sortNonMT() function for these exceptional cases? Why is the default case the exceptional one, and not what we want to apply in the overwhelming situation?

Good question. Maybe we’re not very confident that this multithreading thing is right yet, and this is how it shows.


The morning ride from Copenhagen to Lyngby was very wet and too fast. I was on Peter’s good bike — the one which had been kept in the store-room for the last three years until we hack-sawed through the spoke lock — rather than the cheap Chinese super-market bought folding bike that had been rescued from the store the day before because it wasn’t locked, so I didn’t have a good excuse for falling so far behind.

It rained heavily all day. In the afternoon a 5-axis machining expert came round to give us the tour of the capabilities of hypermill, delcam, and moduleworks, and it all looked completely straightforward to replicate and improve on from where we stood in relation to our software — which means there’s probably some pitfall on the development path we don’t know about yet. As the Danish say, we don’t know where the dead dog is buried. They also tell you that you can’t blow air and have flour in your mouth.

I got away at 6pm after the rain had stopped and cycled all the way south across Copenhagen where Pelle, one of the players from last Thursday’s game, had invited me dinner before today’s session of underwater rugby. I was late to get there, then stuffed myself on four very large spring rolls and rice, and then we cycled together to the pool. I was assured that the advice against doing violent excercise in the water immediately after a meal was out of date.

The pool was a bit shallower than the one before, and there was only one woman out of the twelve of us. Consequently, the game seemed more violent than before. The bigger guys are harder to tackle because you can’t get your arms halfway around their circumference to hold them down. Surprisingly, I never got kicked in the face, though I did get a nasty muscle cramp in both my legs at the same time. It was a good game. I wish it was played in England instead of underwater hockey all the time.

I had time to eat dessert afterwards when Pelle told me a story from his period in Greenland when an english couple showed up to tow a cycle rickshaw across the ice-cap and left it behind on the glacier. This sounded ridiculous. But some diligent searching on the internet produced a corroboration on this page:

In the summer of 2002 I resumed the journey, heading further north to Aberdeen and then on to the Faroe Islands, Iceland, and Greenland, where “mush mush”, huskies will became involved. Things did not go well on the first attempt to cross the Greenland Icecap and We turned back leaving the rickshaw on the icecap. The following spring, We attempted to re-locate it but there was no trace. Later that year with metal detectors and a glaciologist, we made a second foray up there but without result. At this point I officially declared it lost. This summer I am off to Madras to get a replacement rickshaw and have it shipped to Greenland. After much heart ache, I realize I cannot stop now!

The whole project, (photos here) is about establishing a Cyclerickshawallah Day and giving petrol (or electric) motors to the cyclerickshaws so that the drivers don’t die so young. The health implications of the job are not mentioned on the wikipedia cyclerickshaw page. If they are true, it should be reported there, with links to the medical papers.

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.

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