This is part of the Mach lathe control code (brains, macros etc) I am using to control a slantback lathe (think large Hardinge) with a 12 position turret, hydraulic chuck, hydraulic tailstock, etc. The Mach software is linked to the lathe via a Automation Direct 405 PLC. This control system is still under development and will grow significantly so it can automatically control a bar feeder, chip conveyor, and further interlock with the lathe safety systems, etc. Please use this as an example of how you can implement the software, and not as a "drop in" for an automatic lathe. By the time this control is done, I expect the number of macros and brains to more than double, so this is far from finished. Hopefully this will give some of you a starting point so you can avoid some head banging!
Dave
Cole Controls Inc.