For those of you who don't know, our CNC lathe is a Hardinge Conquest 42 with live tooling so is capable of both turning and limited milling and cross drilling functionality. It has been upgraded with all new controls/motors and my CNC software.
We were finally able to shut the lathe down long enough to install and debug the new software with the C axis code. I spent about a week writing the code that I thought would work, loaded it up, and after a couple of days debugging got it working....... Sort of. All it had at this point was spindle indexing, which is what I needed for the current parts design. So at this point it would switch between normal turning and C axis mode under G code control. In normal spindle mode the spindle was operated the same as would be operated with a VFD for speed control, and the C axis indexing mode the spindle would be moved some number of encoder pulses to position like any axis would be controlled in position mode.
Then I redesigned a part and realized that I could cut 2 minutes machining time off of that part by eliminating one operation if I had full C axis interpolation. We make thousands of those parts, so 2 minutes is huge. This required operating the spindle in a completely different control mode under all conditions. I had been controlling the spindle like you would when using a VFD rather than a servo motor, well, because I was using a VFD to run the spindle before the motor upgrade. The servo drive was perfectly happy to operate in that mode so I just continued to use it. This involves sending a +/- 10V analog command voltage out to the drive, where in this case, +10V = +3000 (CW rotation) RPM, -10V = -3000 (CCW rotation) RPM, and 0V = 0 RPM. The voltage command is linear and programmable from the controller in very small voltage increments, (volts/RPM) * the desired RPM. Very simple, and the drive takes care of the speed control, same as turning the speed pot on the VFD.
So back to the drawing board, and completely re-think the spindle operation mode. And do this while not screwing up constant surface speed, rigid tapping, thread milling, and single point threading which has been working flawlessly up until now.
Constant surface speed is where you give the machine (from the G code) a surface speed that you want to cut at, and it varies the spindle RPM based on the current diameter of the part, and updated about every 10ms. So as you are turning, the part diameter is getting smaller with each pass, so the spindle RPM is adjusted on the fly by an amount to maintain the programmed surface speed. The G code also has an upper and lower speed range to work in, without that, if the tool tip was at 0 diameter, like for a facing cut, the RPM required to maintain a constant surface speed would be infinity, maybe a bit fast for the spindle.
This of course required a complete and rather complex re-write of all the spindle operating code in both the controller software as well as the CNC program software, the math involved is a bit more complex as well as having additional servo parameters and variables to deal with. Then in addition modify the CNC program code to understand C axis interpolation and output the correct controller code to make it do what the G code tells it to do. I managed to pull this off and get it all working in two days. Of course anytime you make any software changes, you fix one thing and break 3 other things. Always makes programming a challenge. When writing code for an office application the worst that can happen is the program crashes or you get bad data out, but for real time machine control, things can go catastrophically wrong in a hurry. You can actually break expensive things, a lot more care in programming is required, and always keep your hand on the E-stop button when testing.
At the same time I was crazy enough to add 10 tools to the turret (in software) so we can run dual tool holders in some of the turret stations. So for instance tool 4 could be a drill and tool 14 could be a tap. Both would be in turret position 4 with different offsets. This code seemed to work correctly out of the gate. But I haven't really used it yet, so still needs to be proved out.
I fixed the last known bug last night and fired the machine up again making some needed parts. I still have not proved out all of C axis functionality, but not using it for the currently running parts, and the other needed functions seem to be working OK.
Overall I think this was a success, but time will tell how many unknown bugs are hiding in there just waiting to bite me at the worst possible moment.
I'll post a video of the C axis in action when we run some parts that actually use it.
On another note, we are looking at another Hardinge CNC lathe, 7 axis, with Y axis, live tooling, and a sub-spindle. Another upgrade project