Tuesday, 14 July 2026

Update Centroid Acorn Lathe to 5.4 - and modifying the PLC code to suit - sneaky gotcha!!

I've updated the Tree CNC lathe with Centroid CNC12 latest major version ie 5.42 at the time of writing. The process is still a bit clunky - you have to take screenshots of each setup screen, run the CNC12 installer (having backed up the current, working example under a different folder name), then use the Setup Wizard to replicate every option, item by item, screen by screen.

But as I also had to create a custom PLC program for my powered ATC turret, I'll need to modify the 5.42 PLC in a similar fashion. This turret doesn't use Gray Code to report its position - instead it has a single switch for each of the 8 positions. These come in via the Ether1616 expansion board. There's no default option for an "8-input" turret position feedback.

The edits I made are documented here and there was a minor edit that resulted from testing it out. I'll now need to replicate those changes. The main PLC code will almost certainly have changed since I made my changes back in August 2022.

It's worth noting that the inputs from the turret feedback signals that come in via the Ether1616 expansion board aren't set up by the Setup Wizard - they are effectively hard coded in the PLC code. If you don't make the PLC edits, the ATC turret isn't going to know correctly which tool is loaded.

The final step, after editing the SRC code file is to compile it. Using CMD window, change to the c:\cnct folder, then run the compile:

cd c:\cnct
mpu compile acorn_lathe_plc.src mpu.plc

This generates a new mpu.plc file that will be picked up by CNC12 and run.

The gotcha

Ooof.

c:\cnct>mpucomp acorn_lathe_plc.src mpu.plc
MPUCOMP v5.42 Rev 07 MPU11 PLC compiler
$Id: mpucompiler.cpp 21173 2025-07-21 17:11:10Z keith $
Copyright 2001-2018 Centroid Corp.

Input file : acorn_lathe_plc.src
Output file: mpu.plc
Error Line 6913 Col 4: Undefined label TRUE
IF TRUE THEN CurrentTurretPosition_W = 0
   ^
Error Line 6922 Col 4: Undefined label TRUE
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
   ^
Error Line 6913 Col 4: Bad Numerical Factor
IF TRUE THEN CurrentTurretPosition_W = 0
   ^
Error Line 6922 Col 4: Bad Numerical Factor
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
   ^
Compilation failed.
c:\cnct>

WTF?? Turns out they changed the rules slightly somewhere between v5.20 (my last working installation) and v5.42 (today's update):

According to Mr AI, "If you try to compile a legacy .SRC file (written during the CNC12 v4.xx era or earlier) using the new mpucomp compiler from v5.xx+, it will instantly flag IF TRUE as a compiler syntax error. To upgrade old logic to work under v5.xx software, open your old .SRC file and find/replace every instance of TRUE used in logic statements to TRUE_M."

There are only 2 instances of the IF TRUE statement, both of which I pasted in when updating the turret code using snippets of the v5.20 code:

;==============================================================================
                               ATCGrayCodeStage
;==============================================================================
; EME 2024-11-10 ATC control trials
; Input 1 on Ether1616 with A0 address = CNC12 input 33 etc
; IF Tool1Input THEN CurrentTurretPosition_W = 1
; IF Tool2Input THEN CurrentTurretPosition_W = 2
; etc...
IF TRUE THEN CurrentTurretPosition_W = 0
IF INP33 THEN CurrentTurretPosition_W = 1
IF INP34 THEN CurrentTurretPosition_W = 2
IF INP35 THEN CurrentTurretPosition_W = 3
IF INP36 THEN CurrentTurretPosition_W = 4
IF INP37 THEN CurrentTurretPosition_W = 5
IF INP38 THEN CurrentTurretPosition_W = 6
IF INP39 THEN CurrentTurretPosition_W = 7
IF INP40 THEN CurrentTurretPosition_W = 8
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
; EME end of substitution

Replaced both TRUE instances with TRUE_M. That's better:

c:\cnct>mpucomp acorn_lathe_plc.src mpu.plc
MPUCOMP v5.42 Rev 07 MPU11 PLC compiler
$Id: mpucompiler.cpp 21173 2025-07-21 17:11:10Z keith $
Copyright 2001-2018 Centroid Corp.
Input file : acorn_lathe_plc.src
Output file: mpu.plc
Compilation successful
Max stack depth = 7
Program size: 13475 tokens (82.2449% of max)
c:\cnct>

That should work. It compiles and runs OK although I'll leave the testing of the turret until tomorrow, as it's a pretty noisy, brutal mechanism and it's late and I'm supposed to be getting tired soon.

No comments:

Post a Comment

Update Centroid Acorn Lathe to 5.4 - and modifying the PLC code to suit - sneaky gotcha!!

I've updated the Tree CNC lathe with Centroid CNC12  latest major version ie 5.42 at the time of writing . The process is still a bit cl...