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:\cnctmpu 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.plcMPUCOMP 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.srcOutput file: mpu.plcError Line 6913 Col 4: Undefined label TRUEIF TRUE THEN CurrentTurretPosition_W = 0^Error Line 6922 Col 4: Undefined label TRUEIF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W^Error Line 6913 Col 4: Bad Numerical FactorIF TRUE THEN CurrentTurretPosition_W = 0^Error Line 6922 Col 4: Bad Numerical FactorIF 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:
Replaced both TRUE instances with TRUE_M. That's better:
c:\cnct>mpucomp acorn_lathe_plc.src mpu.plcMPUCOMP 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.srcOutput file: mpu.plcCompilation successfulMax stack depth = 7Program 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