# Avid CNC's SpindleWarmup routine

**URL:** <https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715>\
**Category:** General Chat\
**Created:** [February 12, 2023, 2:54am UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715 "2023-02-12T02:54:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 2:54am UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/1 "2023-02-12T02:54:19Z")

</div>

Hi all!  
I’m trying to find the uncompiled code for SpindleWarmup that comes with the Mach 4 Avid profile. I want to modify it for my specific spindle to turn on the air before hand, and turn it off when done.

Is that located anywhere? Otherwise I have to write my own in Lua.

thanks,  
Corbin

---

<div class="post-metadata">

**Author:** ![jjneeb](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/jjneeb/32/244_2.png) [@jjneeb](https://forum.avidcnc.com/u/jjneeb)\
**Post date:** [February 12, 2023, 4:33am UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/2 "2023-02-12T04:33:20Z")

</div>

You can ask AVID for it, but I would expect they won’t give it to you. They don’t provide any of the source code for thier modules as far as I know.

However, for what you want to do, you should be able to edit the code in the screen for the button to enable the warmup so that it turns on the air before calling the warmup routine, and then turns it off after. I see its a coroutine, so you might have to put a timer on the last part to turn off the air since I’m not sure if it will wait for the routine to be done before returning to the button code…I’m not a SW guy so I don’t know much about how the coroutines work in Lua.

---

<div class="post-metadata">

**Author:** ![subnoize](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/subnoize/32/2197_2.png) [@subnoize](https://forum.avidcnc.com/u/subnoize)\
**Post date:** [February 12, 2023, 6:57am UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/3 "2023-02-12T06:57:51Z")

</div>

It would look something like this;

```auto
S12000 M3
G04 P120.
S18000
G04 P120.
S24000
G04 P60.
M5
M30

```

Be careful, the dots (.) actually mean something and aren’t a typo.

G04 == Dwell  
PXX == Time in seconds  
. == Stop parsing the parameter

No, I haven’t run this code because I just typed it out on my phone. Please check it before executing 😬

PS. If you want to do this in Lua just do it in a `mc.mcCntlGcodeExecuteWait(...)` line.

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 12:43pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/4 "2023-02-12T12:43:53Z")

</div>

> [@jjneeb](#):
>
> You can ask AVID for it, but I would expect they won’t give it to you. They don’t provide any of the source code for thier modules as far as I know.

That’s kind of what I figured. Looking at the screen script I see they have a global variable that they are setting and check when the spindle switch is hit.

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 12:45pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/5 "2023-02-12T12:45:31Z")

</div>

> [@subnoize](#):
>
> It would look something like this;
> 
> ```auto
> 
> ```

Thanks! Yeah, I figure I can re-write it; I was just trying to avoid it.

---

<div class="post-metadata">

**Author:** ![subnoize](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/subnoize/32/2197_2.png) [@subnoize](https://forum.avidcnc.com/u/subnoize)\
**Post date:** [February 12, 2023, 4:37pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/6 "2023-02-12T16:37:09Z")

</div>

AvidCNC is only licensed to use the compiled version and they actually do not have the source for a lot of that stuff.

AvidCNC’s Mach4 install is the bare minimum to get up and running. It is NOT a negative statement against AvidCNC, they never intended it to be everything to everyone. It’s more a starting place to set you off on the right track.

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 7:13pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/7 "2023-02-12T19:13:15Z")

</div>

> [@subnoize](#):
>
> AvidCNC is only licensed to use the compiled version and they actually do not have the source for a lot of that stuff.

Who did they get the license from?

---

<div class="post-metadata">

**Author:** ![subnoize](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/subnoize/32/2197_2.png) [@subnoize](https://forum.avidcnc.com/u/subnoize)\
**Post date:** [February 12, 2023, 8:23pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/8 "2023-02-12T20:23:05Z")

</div>

Newfangled.

I have heard rumors that AvidCNC is looking for a new programmer if you are interested.

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 8:37pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/9 "2023-02-12T20:37:15Z")

</div>

Ah, of course! I actually would be interested in a programmer job with Avid…I just need to learn a little more about Mach 4. So far, I added some code to turn on some signals. One is for the ATC, and the other is for turning on air pressure and the spindle fan when M3 starts. Lua has been pretty easy to program with.

---

<div class="post-metadata">

**Author:** ![subnoize](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/subnoize/32/2197_2.png) [@subnoize](https://forum.avidcnc.com/u/subnoize)\
**Post date:** [February 12, 2023, 9:01pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/10 "2023-02-12T21:01:20Z")

</div>

> [@corbin](#):
>
> Lua has been pretty easy to program with.

Be careful, Lua doesn’t stop when you hit that cycle stop, pause or even worse, when you hit the e-stop.

About half my ATC code is checking error states in Mach4 and there are roughly 15 ways right now where I can still drop a tool if an error occurs during the M6.

Essentially the Lua engine is separate and independent of Mach4. Mach4 will update the values Lua needs when it feels like it… 😬

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 9:03pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/11 "2023-02-12T21:03:31Z")

</div>

ug…that sounds scary! Have you shared your M6 code? Eventually I’ll be working on that too…but first I have to finish setting up my machine.

---

<div class="post-metadata">

**Author:** ![subnoize](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/subnoize/32/2197_2.png) [@subnoize](https://forum.avidcnc.com/u/subnoize)\
**Post date:** [February 12, 2023, 9:17pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/12 "2023-02-12T21:17:53Z")

</div>

> [@corbin](#):
>
> ug…that sounds scary!

I have broken a lot of very expensive equipment so yes, very scary. Mach4 is not on the same level as LinuxCNC or other commercial motion planners.

> [@corbin](#):
>
> Have you shared your M6 code?

I am hoping April will be the big month. To be fair to AvidCNC and to respect their forum, my progress is covered under build logs. It is looking like the dust manifold will be first and will be independent of the tool carousel. So if you want static posts it will be a minor install. I think I might even make it a state machine for those who don’t mind losing the top 12 inches off the work envelop. The last foot will trigger the dust manifold to open so you can do a tool change.

> [@SUBNOIZE: 10 Tool Carousel, Tool Length Sensor and Dust Manifold](https://forum.avidcnc.com/t/subnoize-10-tool-carousel-tool-length-sensor-and-dust-manifold/1096/38):
>
> Ah! The thread was so long I had forgotten that. Yeah, that’s what my manifold did. Eight nozzles for each ring, one ring facing in, and one facing down. I look forward to trying it slight_smile

---

<div class="post-metadata">

**Author:** ![corbin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/corbin/32/2800_2.png) [@corbin](https://forum.avidcnc.com/u/corbin)\
**Post date:** [February 12, 2023, 9:23pm UTC](https://forum.avidcnc.com/t/avid-cncs-spindlewarmup-routine/1715/13 "2023-02-12T21:23:50Z")

</div>

Awesome! I checked out the thread. The build is looking really cool. I’ll definitely be following along. My Tormach run’s path pilot, which I’m sure you know is based off LinuxCNC. It is quite nice.
