# Thread: Macro Math formula problem

1. ## Macro Math formula problem

Hi all here is the problem the new citizens when using H cant go past 9999. So I was wanting to maybe make a (while/do) formula that can do the formula and decide how many times it needs to divide itself so I can make a universal program to work with older and newer machines. (I am Thread whirling B.T.W.) Here is what I was thinking so far. I haven't tried this yet just wanting some feedback to see if I'm going in the right direction.

Example

#502= Pitch
#503=[[[#501+.05]/#502]*360]
IF[#503LT9999.]GOTO77
#504=2
WHILE[#503GT9999.]DO1
#506=#503/#504
#503=#506
#504=#504+1
END1

Basically what I want is to pass the #503 and #504 variable down to the the next while/do with the new numbers to perform the whirling as needed in increments less than 9999. (I'm just not sure if you can do it like this or if it will confuse the machine)

example for the next while/do in the program.

#507=[[#503/360]*#502]
#508=1
WHILE[#504GT1]DO2
#509=#507*#508
X-.075Z#509H[[[#507]/#502]*360]
G50 C0
#508=[#508-#504]+#504
#508=#508+1
#504=#504-1
END2

So what I am wanting this to do is create the amount of H loops I need and each one will subtract till at 0 and also I need it to add to the final z each loops so if I started off at .250 for each z the second z needs to be .5 3rd .75 etc. Not even sure if I'm even close to being right or if its even possible just wanted to through this out to some of you programing wiz's and see what you think.

I know I could use G32 and have separate programs but I like to tinker

Thanks

2. Originally Posted by Machinist_X
...the new citizens ...
What are considering new?

3. So you want us to stare blankly at macro programming because you like to tinker?

sure, i'm game.

4. As for how old of machine's i would say any we have from the last 6 or 7 years or so, also we installed a new motherboard on a m12 2m3 and it now wont take H past 9999.

Lol Tea hole yep. No I was just wanting you guys to punch in some numbers for 501 and 502 and see if you thought it would work out b4 I tested it in a machine. Hopefully this week I will have time to put it in a machine and test it to see if it works just thought I would throw it out b4 I tried to test it to see if I was close or way wrong and needed to do it a different way.

5. There are more concise ways to achieve what you want to do.
The issue is not with the machines ability to read a C value beyond 9999 but rather the softwares ability to accept an input value greater than 9999 for C or H.
For that reason, you would not need to us G50 C0 in your WHILE/DO loop.

Here is the basic problem at hand...

• Given the total thread length and pitch, how many full rotations exsist?
• How do I handle the last partial rotation

Once you determine these two things, you can achieve what you want in a single W/D loop.
If you want to put some more thought into it using the above ideas, I would be happy to assist you here.
If not, that's fine too, and good luck to you.

6. Thanks for the reply pro-process and if there is a better way to do what I'm trying to do I would greatly appreciate your assistance. Thanks

7. Originally Posted by Machinist_X
Thanks for the reply pro-process and if there is a better way to do what I'm trying to do I would greatly appreciate your assistance. Thanks

Well, I've given you the two main components of what you need to solve your issue ...

Originally Posted by ProProcess
...
Here is the basic problem at hand...

• Given the total thread length and pitch, how many full rotations exsist?
• How do I handle the last partial rotation

....
I'm not going to write out your soloution for you.
Give the info I'ver provided, what can YOU come up with that is different than what you've already done?
Show some code using the new info and lets work form there.
Good luck!

8. How often do you think you will need to do 10 thousand loops?
Seems to me that nine thousand, nine hundred and ninety nine should be enough.

9. Originally Posted by cogsman1
How often do you think you will need to do 10 thousand loops?
Seems to me that nine thousand, nine hundred and ninety nine should be enough.
The issue is not that the loop is 9,999 it's that the Input for commanding C/H can only handle up to 9999 as in

Code:
`G1 G98 Z3.7 H9999(THIS IS THE MAX INPUT FOR C OR H)`
So if you had a thread that was 3/8"-16 and it was 2.5 long and you wanted to thread whirl using C/H instead of G32...

1/16=.0625
2.5 / .0625 = 40 revoloutions.
360° * 40 revolutions = 14,400°

so that code would be...

Code:
```G1 Z0
Z2.5 H14400.(THIS WILL ALARM AS THE INPUT IS OUT OF RANGE)```
According to the OP this limitation did not exsist in some older models and the OP want to Macro a utility that will be usable on new and old machines.

10. Sorry for the slow response back but I don't get online much but thank you very much Pro-Process for the hints in the right direction after I read your post I didn't think I would figure out a easier way but put a couple of days into thinking about what you said and it clicked. I got a nice streamlined macro'd program that I will now start using for all my whirl programs thanks again.

11. Originally Posted by Machinist_X
Sorry for the slow response back but I don't get online much but thank you very much Pro-Process for the hints in the right direction after I read your post I didn't think I would figure out a easier way but put a couple of days into thinking about what you said and it clicked. I got a nice streamlined macro'd program that I will now start using for all my whirl programs thanks again.
Cool!