What's new
What's new

Macro B Part Count to Adjust RPMs

RevHaus

Plastic
Joined
Oct 31, 2019
Location
Illinois, USA
Hello,

I'm a novice with Macro B programming, and I'm okay with G and M code programming.
I am working on a Romi M27 Lathe, using a GE Fanuc Series 21i-TB control.
We are running a 12 foot plastic tube. We machine a part, cut it off, stop the machine, manually move the tube further into the machine, and repeat until we can't make any more parts from that tube. We get 13 parts from each tube.

For the first half of the tube length we run the machine at 300RPM because of how much tube sticks out of the machine through the spindle. For the 2nd half, once the tube is shorter, we run the parts at 600RPM to speed up our production rate.

The RPM adjustment is manual. I am trying to eliminate the manual adjustment and human error from the equation in running these parts, and make sure that no one can forget to adjust the RPMs and crash the machine.

I am pretty sure we can use Macro B to adjust the RPM automatically based on the part count, so that it runs the machine at 300rpm for the first 7 parts, then changes to 600RPM for the next 6 parts, then resets to 300RPM for the first half of the next tube. While I am pretty sure that this can be done, I simply don't have the skill level with Macro B syntax to be able to make it happen.

Is this actually possible?
Will someone help me with this if it is?
Please and thank you.
I appreciate your time and assistance with this in advance.

RevHaus
 
Hi Rev!

This should be possible. You need to create a part counter and then reference the value of the counter to use in your "S" word for RPM. Something like this:

#500=[#500+1]; (parts counter...goes up by 1 every time this line is processed)
#501=300; (default value used for spindle speed)
IF[#500GT7]THEN#501=600; (checking to see if it is time to change spindle speeds yet by referencing part count)
;
M3S[#501]; (spindle on line, using the value in macro variable "501" for the speed...either 300 or 600)
;
;
IF[#500EQ13]THEN#500=0; (this line resets the part counter to "0" once the 13th part is made, thus putting the RPM back down to 300)
;
M30;

In that example macro variable #500 is your parts counter. This is usually accessible through the Offset page if you want to view it. It goes up by one at the beginning of each program. You could also put this at the end of the program, which might make more sense. #501 is either 300 or 600 and used as the numerical value for your spindle speed "S" word.

There is undoubtedly a more-elegant way to do it, probably using a "WHILE" statement but I am not familiar enough with that. You also need to check on which variables are available to you and safe to use (i.e. not used/referenced by the machine in other programs, subprograms, etc.)...I believe the "500's" are always safe to use but someone else here can confirm that.

Good luck!
 
Rough idea here, typed up on my lunch break, flesh it out as you need to, don't use #500 variables unless you're sure they're not being used by something else, not responsible if you crash your machine, etc.

Also, this requires your operator to set #502 = 0 manually at the start of the job, and if they change bars before they get to 13 parts, or you're gonna have a bad time.


(PART COUNTER VAR IS #502)


WHILE[#502LT8]DO1
M3S1=3000
M98H1
END1

WHILE [#502LT14]DO2
M3S1=6000
M98H1
END2

#502=0

M2
M99


N1
YOUR PROGRAM, MINUS THE M3 HERE
 
So you pretty much just need variables. Here is where it could mess you around... Are you running the same program till the end (A M2 or M30 at the end) and then it cycles back to the top of the program and you run the same program again?
If so you need to be careful on how your parameters are set up. Variables #1-#33 and #100-#199 are cleared (depending on parameter set up but generally they are set like this) when M2 or M30 is read or you hit the Reset button. I generally change my parameters so that the 100's don't get cancelled but this could also lead you in to some trouble if you do not clear them in your program or if you don't assign a new "number per say" to them.

So for your application I would just use variables in the 500-999 range.

At the head of your program insert a

#501 = 8 (First Parts)
#502 = 7 (Second parts)
#500 = #500 + 1 (Add to counter for first few parts)
IF [ #500 LTE #501] GOTO 2 (To skip the next few lines and go to N2)
#600 = 600 (Second RPM Value)
#504 = #504 + 1 (Add to counter for second set)
IF [#504 LTE #502] GOTO 3 (To skip the next two lines)
#500 = 0 (To get your counter for first set back to 0)
#540 = 0 (To get the counter for second set back to 0)

N2 #600 = 300 (First RPM Value)
N3 Then when you call your S command, I assume G97, just put it in like this:
G97 S#600 M3

I am sure others will pich in and make it neater, even might find mistakes, it has been a long day, but this should get you started somewhere.
 
So you pretty much just need variables. Here is where it could mess you around... Are you running the same program till the end (A M2 or M30 at the end) and then it cycles back to the top of the program and you run the same program again?
If so you need to be careful on how your parameters are set up. Variables #1-#33 and #100-#199 are cleared (depending on parameter set up but generally they are set like this) when M2 or M30 is read or you hit the Reset button. I generally change my parameters so that the 100's don't get cancelled but this could also lead you in to some trouble if you do not clear them in your program or if you don't assign a new "number per say" to them.

So for your application I would just use variables in the 500-999 range.

At the head of your program insert a

#501 = 8 (First Parts)
#502 = 7 (Second parts)
#500 = #500 + 1 (Add to counter for first few parts)
IF [ #500 LTE #501] GOTO 2 (To skip the next few lines and go to N2)
#600 = 600 (Second RPM Value)
#504 = #504 + 1 (Add to counter for second set)
IF [#504 LTE #502] GOTO 3 (To skip the next two lines)
#500 = 0 (To get your counter for first set back to 0)
#540 = 0 (To get the counter for second set back to 0)

N2 #600 = 300 (First RPM Value)
N3 Then when you call your S command, I assume G97, just put it in like this:
G97 S#600 M3

I am sure others will pitch in and make it neater, even might find mistakes, it has been a long day, but this should get you started somewhere.
 
I'd make a main program that sets a variable for your RPM and then calls the part program with M98, then sets the variable for the next RPM and calls the part program again, etc. Put an M99 in the part program to return to the main, and an M00 somewhere in the loop to pull the stock out. That way you can fiddle with the RPM's for each part in the sequence, maybe increment by a certain amount as you go.
 
Thank you all for the quick replies.
I truly appreciate the help.

Each part is one cycle of the machine, with M30 at the end of the program to start over for the next part after the tube is advanced into the machine. This is why I was trying to get the part count figured out, so that I could use it to adjust the RPM automatically. The goal was to get the part count to automatically reset to zero at the end of one tube before starting the next tube. Removing any operator input, either for part counts or RPMs.

I have will dig into this next week and see what I can figure out.
I have a half day today for a fairly routine Doctor's appointment.
More info or ideas are certainly welcome if someone comes up with something.

Thanks again gentlemen.
It's great to have this kind of resource available, especially with intelligent and friendly people willing to try and help. You're all great. Stay safe.
RevHaus
 
Thanks again for all your suggestions and help.
I managed to get the program to work the way I wanted it to work, though the code I ended up with is quite a bit different than what you guys suggested. I am not knocking any of it or you, I wouldn't have gotten to where I am with this if it wasn't for the help I got here. I truly appreciate it. I will share the code I used, and try to explain why I did what I did. Hopefully I make sense.

So here is the code and my explanation:

IF[#3902GT12]THEN#3902=12 (Variable #3902 is the manufactures built in "Part Required" target number)
IF[#3902LT12]THEN#3902=12 (Because the machine runs a "zero part", the target number is one less than the actual desired
(completed parts. So these two lines set the "Parts Required" number to 12 automatically if it
(is anything other than that when the machine runs this program)

IF[#3901GT#3902]THEN#3901=0 (Variable #3901 is the manufacturers built in "Part Counter" variable. We don't run a lot of
(parts where the part count matters, and the machine automatically counts parts whether we put
(it in the program or not, so this sets the "Part Counter" to zero if it is higher than the
("Parts Required" value)


#3901=#3901 (This calls the #3901 variable into the program for the "If" line below, this may be redundant and/or
(unnecessary. I have to experiment with this a bit to see if its necessary or not.)

#105=300 (I used the variable #105 instead of #500. I have been taught that the 500 series of variables are global,
(meaning they will alter things in all programs that they appear in. So by using #105 I have isolated this
(variable to this program alone. This sets the initial S to 300RPM)
IF[#3901GT6]THEN#105=600 (This line adjusts S to 600RPM after 6 parts, or roughly half the length of the raw stock)



That's what I got.
It works great.
The "zero part" threw me a little bit, as did the built in part counter.
It took me a few hours (3 1/2 or so) Monday morning to figure this out with the advice I got from you guys here.
If it hadn't been for you guys, I would not have even been close for who knows how long.
Thank you all once again.
Stay safe,
RevHaus
 
After tinkering with the code some more, and finding out that they run the tubes in thirds with each shorter section spinning faster then the previous section I came up with the following code that works the way we need it to.

IF[#3902GT12]THEN#3902=12
IF[#3902LT12]THEN#3902=12
IF[#3901GT#3902]THEN#3901=0
#3901=#3901

#105=300
IF[#3901GE5]THEN#105=450
IF[#3901GE9]THEN#105=600

(The rest of the program goes here as normal with M3S[#105]) for the spindle speed call outs).

This Macro B code sets the "Parts Required" t0 12, it also sets the "Parts Completed" to zero if it is higher than 12. Parts zero through 4 run at 300RPM, parts 5 through 8 run at 450RPM, and parts 9 through 13 run at 600RPM. Then it resets the "Parts Completed" back to zero, for the new tube along with starting us back at 300RPMs.

Thanks again for your help.
I know it doesn't exactly look like what you guys gave me to work with, but I got it to where I needed it to be for us, maybe something I figured out can help you.
Stay Safe,
RevHaus
 
Are you at all worried about getting a short bar and only getting 12 parts out of it? Then your next bar would start out at the highest rpm.
 
This is actually a really good thought.
Honestly not something that I had considered or thought of yet.
To be fair, we run these parts from raw stock, straight from the manufacturer.
It would be incredibly rare to have a short tube that would not yield the correct amount of parts.
That being said, I am going to add some notes into the program to make the operator aware that if they get short tubes that they have to manually adjust the speed at the start of the next tube.
Thanks for the idea.
 








 
Back
Top