With the servos, VFD etc all set up and working, it seemed like a good time to focus on cracking the controls for the turret toolchanger on the Tree. This is fairly simple - there's a single hydraulic solenoid that takes care of withdrawing the locking pawl, driving the turret off its locking "teeth" and rotating the turret (using a hydraulic motor). Once deactivated, the 2-way action of the solenoid applies reverse pressure, driving the turret backwards against the locking pawl, forcing the turret against its locking teeth and holding it there. There's also a Sanyo 8 way position switch (which appears to be a set of reed switches and a rotor-mounted magnet), which reports the current tool position.
There are several flavours of ATC catered for in the standard wizard options but none of them are exactly what I need. The closest uses 3 or 4 bit Gray code to report the position and a single output to drive the turret. Although I could arguably use a series of diodes to convert my 8-way switch outputs to Gray code, I'd rather do it in software. Otherwise it should be very close to what I require.
The PLC code is provided in the default cnct folder after installation and you are enabled / encouraged to make your own edits, then compile and test it for yourself.
;==============================================================================
AtcGrayCode3Stage
;==============================================================================
IF TRUE THEN CurrentTurretPosition_W = 0
IF ToolTurretPosBit1 && ToolTurretPosBit2 && !ToolTurretPosBit3 THEN CurrentTurretPosition_W = 1
IF !ToolTurretPosBit1 && ToolTurretPosBit2 && !ToolTurretPosBit3 THEN CurrentTurretPosition_W = 2 ;**** Bit2
IF !ToolTurretPosBit1 && !ToolTurretPosBit2 && !ToolTurretPosBit3 THEN CurrentTurretPosition_W = 3
IF ToolTurretPosBit1 && !ToolTurretPosBit2 && !ToolTurretPosBit3 THEN CurrentTurretPosition_W = 4 ;**** Bit1
IF ToolTurretPosBit1 && !ToolTurretPosBit2 && ToolTurretPosBit3 THEN CurrentTurretPosition_W = 5
IF !ToolTurretPosBit1 && !ToolTurretPosBit2 && ToolTurretPosBit3 THEN CurrentTurretPosition_W = 6 ;**** Bit3
IF !ToolTurretPosBit1 && ToolTurretPosBit2 && ToolTurretPosBit3 THEN CurrentTurretPosition_W = 7
IF ToolTurretPosBit1 && ToolTurretPosBit2 && ToolTurretPosBit3 THEN CurrentTurretPosition_W = 8
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
With this (simpler) code:
ATCGrayCodeStage
;=========================================================================
; EME 2022-08-13 ATC control trials
; Input 1 on Ether1616 with A0 address = CNC12 input 33 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
Looks pretty straightforward. But obvs it wasn't clear to me if it was actually working when I tried it "dry" ie without the hydraulics running.
In the end, I went though the whole thing and deleted out everything that wasn't turret-related or specific to my turret type ("W4"). When I did that, it actually became quite understandable.
It all looks pretty reasonable with the exception of the MonitorIndexATCRequestStage bit, which I suspect isn't relevant here.
And indeed, that all seems to work. Admittedly, I haven't got the hydraulic pump running but everything else computes. If you run the PLC Detective (press Alt-E while CNC12 is running), you can see the status of the variables that are displayed as they change. So hovering the mouse over RequestedTurretPosition_W would show the currently requested tool position etc. That's pretty handy for checking what it thinks is going on.
No comments:
Post a Comment