Author Topic: Maths help please: Approximating a Flat Iteratively  (Read 13238 times)

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #50 on: June 17, 2019, 12:07:23 PM »
 :clap: :clap:  Whoopee   :clap: :clap:

We have a flat :thumbup: :thumbup:

Thanks Archie, and of course everyone else who contributed - what a result, but what a journey - I was running out of 1" bar  :lol:

Yes the order of calculation MUST be strictly left to right and ignoring good old BODMAS

As for the intricacies of Excel I'm glad to say all my professional report writing and playing with spread sheets was over 15 years ago :)

Andrew Mawson
East Sussex

Offline Archie Opteryx

  • Jr. Member
  • **
  • Posts: 16
Re: Maths help please: Approximating a Flat Iteratively
« Reply #51 on: June 17, 2019, 02:25:28 PM »
Well done, Andrew. That's an excellent result  :clap:

It's not surprising that the controller doesn't handle expressions fully. It's quite a tricky business https://en.wikipedia.org/wiki/Shunting-yard_algorithm and needs a lot of resources for a machine of that vintage. Hopefully the instructions warn you about this though.

According to the spreadsheet I posted earlier, the cusp height for the conditions you used should be between 0.038mm near the centre and 0.081mm near the edge. I don't know how that compares with the reality...

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #52 on: June 17, 2019, 03:17:32 PM »
Archie I'm really chuffed  :thumbup:

I did try setting the starting angle to 180 to do the 'other flat' of the spanner flats, but it faulted out saying a destination was beyond the soft limits. Not had time to trace what's happening  but presumably the cos function isn't happy in that / those quadrants.

The finish to be honest is rather rough - the poor old end mill has been being used without coolant so that I could see what is happening, so it's not as sharp as it was!

However I did put a vernier guessing stick on the one flat and work out what the AF would have come out to and it's 18.02 mm so not to bad without any tweaking.

Many thanks for your help with this little conundrum .
Andrew Mawson
East Sussex

Offline Archie Opteryx

  • Jr. Member
  • **
  • Posts: 16
Re: Maths help please: Approximating a Flat Iteratively
« Reply #53 on: June 17, 2019, 03:48:47 PM »
It's probably not the cosine function itself that's unhappy, but rather that the cosine of 180 degrees is -1. Your X distance will therefore work out negative, which will probably make the tool try to emerge from the front of the cabinet  :bugeye: Good for soft limits, eh?

You'll probably need to subtract an additional 180 degrees from the value you give to the cosine function.

It's good to know the dimensions are coming out as expected  :D

Offline PekkaNF

  • Hero Member
  • *****
  • Posts: 2523
  • Country: fi
Re: Maths help please: Approximating a Flat Iteratively
« Reply #54 on: June 18, 2019, 01:37:25 AM »
Happy that you guys got it sorted very elegant.


These PLC controllers don't quite work as expected and sometimes even reading the programmer guide does to reveal all. I hope I never need to get too deep on them again. I remember few ocassion when same Siemes S5 machine code produced different results with different model CPU:s. I.E. the instruction was supported, but result was different. Once on night sift at the site the function call would return garbage (worked on the office with different CPU), tracking the error was not too easy and in the end we had to write subsitute function in ASM, because it was time critical. Brown pants moment. Felt really awkward. We did not want to rewrite the code (no-one wants fork), but sometimes you really have to get dirty to get system up and running. I think we ended up supporting internally two codes, because customer did not want to upgrade CPU (cost of spares and all).

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #55 on: June 18, 2019, 07:24:54 AM »
As you suspected Archie, it was the fact that the X travel was going negative that was upsetting things. I ended up forming the modulus of the evaluated travel distance by multiplying by -1 if it was less than zero, as the controller doesn't appear to have a modulus function.

I had to do a few more tweaks regarding loop values now that the angle are bigger, but now it works for start=0 and start =180 degrees. I suspect that it will fault if asked to cut a flat where the angle goes through 359.99 but that's for the future - as predicted the flat AF is 18.02 so that's good :thumbup:

This is just one feature of a series to make a part (CNC CAT40 special Beaver Pull Stud) to try and avoid second ops off the lathe
Andrew Mawson
East Sussex

Offline Archie Opteryx

  • Jr. Member
  • **
  • Posts: 16
Re: Maths help please: Approximating a Flat Iteratively
« Reply #56 on: June 18, 2019, 03:28:15 PM »
Andrew, those flats look very good, It's great to see the final result  :clap:
The spanner seems to be a good fit on them too. They could almost have been made for it  :lol:

I'm curious to know how you intend to program the rest of the part. Are you going to write all the g code for it by hand, or are you going to use a CAD program to generate the other features?

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #57 on: June 18, 2019, 03:52:20 PM »
Archie, I've had an Autocad sketch of the stud that I drew up years ago as these studs are now unobtainable. It will be a two operation process. Firstly I will thread a bit of suitable steel with an M16 stud with those flats on the chuck side, which will be parted off with sufficient length to make the rest of the part.

This will then be screwed into an M16 female 'receiver' in the chuck, and the stud shape turned to completion, the stud unscrewed (using those flats!) and the next blank inserted.

The thread I have modelled in FeatureCAM and the stud end I have yet to model. I have written a post processor for FeatureCAM that generates passable code for the Siemens control. I will probably hand stitch the bits of code together.


Andrew Mawson
East Sussex

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2434
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #58 on: June 18, 2019, 06:13:49 PM »
So.. I googled "CNC CAT40 special Beaver Pull Stud", found lots of pictures of similar looking things, and I still have no idea what it's supposed to do  :scratch:

Looks nice though!
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Occasionally: Zhengzhou, China. An even longer way from anywhere...

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #59 on: June 19, 2019, 02:37:00 AM »
The 'pull stud' is what pulls the 40 taper tool shank tightly into the female socket in the milling machine spindle. It is gripped by a special finger collet. The arrangement performs the same function as the draw bar on a Bridgeport manual mill. Your interact of course has no draw bar as its presumably a QC30 nose?

Using the pull stud allows for automatic tool changing. There are many shapes in use and Beaver of course HAD to design their own  :ddb:
Andrew Mawson
East Sussex

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2434
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #60 on: June 19, 2019, 03:37:25 AM »
 :doh: Obvious when you know! Yes, you're right, my Interact has the QC30 spindle which uses a ring to push the tool into the taper from below. No automatic tool changes for me!
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Occasionally: Zhengzhou, China. An even longer way from anywhere...

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #61 on: June 22, 2019, 09:36:55 AM »
Having got this program cutting a pair of flats @0 and 180 degrees, I though that before I 'put it away' I'd try and cut a full hexagon, so flats at 0, 60, 120, 180, 240 and 300 degrees.

Well it didn't  :bang:

Only 0 & 180 worked - the rest calculated increasingly large opposite sign cutter movements ie outwards. It dawned on me that the cos function needed to be limited to angles between plus and minus half of the span term, (so +-40 degrees usually) where as the rotation of the work piece needs the actual angle being used. So I split it up into two formats with a variable for the cosine function and a separate variable for the angular positioning.

This worked fine until I came to the case of a flat at 300 degrees, 300 plus the angle (usually 80 degrees) is larger than the M19 spindle positioning function will accept, being limited to 0-359.9 degrees - so another tweak was added to correct this, and lo and behold it is now a general function that will cut a flat at any angle I dictate in the R10 variable on the first line.

So have a picture of a hexagon  :ddb:
Andrew Mawson
East Sussex