Hi all. so I'm fairly new to macro programming in general, but I find myself in need of some help. I'm trying to emulate the Haas spindle speed variation that they use on their lathes...but on a mill. I have a macro that works to vary the spindle speed and will run indefinitely, but I'm having a hard time figuring out how to make it run in the background while the main program code executes. I'm sure there must be a way to do this in a while loop, but for the life of me, I can't seem to think of a solution that works. Ideally I'd love to apply my program to a custom mcode (I know how to do that) so I can use it on a few different programs and have another mcode that cancels it.

Any thoughts or tips would be appreciated. Thanks.