Hello Guest it is March 19, 2024, 05:28:45 AM

Author Topic: Yet another Retrofit. Hardinge HXL-S  (Read 111470 times)

0 Members and 1 Guest are viewing this topic.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #90 on: September 09, 2008, 02:24:01 PM »
Thought they must have been fairly small with the size of the power supply.
Yes ModBUS is easily forgotten, I just got another PLC to use on the Beaver mill and took me ages to remember how to set it up.

Hood

Offline fdos

*
  •  326 326
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #91 on: September 10, 2008, 08:28:48 PM »
For anyone thats interested here's the M6Start macro for the 4 station turret on my Hardinge.

It passes the requested station # to the Cubloc PLC via a holding register mapped to 66 in mach and D12 on the Cubloc.

The Cubloc always has it's actual station # available in D13 (67 in Mach) via it's turret encoder routine.   = 0 when invalid = 1 to 4 for valid stations.

I'll probably post the Cubloc program when it's developed a bit more.

The Macro below is partially based on Hoods Churchill Macro.  Thanks Robin...


Wayne.....


'Toolchange macro for Hardinge HXL-S and Cubloc CUSB36R PLC
'September 10th 2008
 
   
   
tool = GetSelectedTool()

 
If Tool = GetCurrentTool() Then           'Ignore and Exit if already there

  End

End If
 

   


If Tool <1 Then                  'If tool called is < 1
  MsgBox ("Error! Tool "& tool & " Out Of Range")   'error message
  DoOemButton (1003)                       'Stop Button
  End                                      'End macro
End If

If Tool >4 Then                  'If tool called is > 4
  MsgBox ("Error! Tool "& tool & " Out Of Range")
  DoOemButton (1003)                    
  End                                      
End If

Message ("Waiting for Turret Station " & tool)

If Tool=1 Then                            'tool = 1

  Call SetModOutput (66,1)            'Reg D12
    Do
      If GetInput (67) = tool  Then          'Reg D13
        Call SetModOutput (66,0)         'Reset D12
        Exit Do
      End If
    Loop
End If


 
If Tool=2 Then                            'tool = 2

  Call SetModOutput (66,2)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=3 Then                            'tool = 3

  Call SetModOutput (66,3)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=4 Then                            'tool = 4

  Call SetModOutput (66,4)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If
 
 
Message ("Station " & tool & " OK")      'Status Msg      
SetCurrentTool( tool )

End
« Last Edit: September 12, 2008, 11:52:58 AM by fdos »

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #92 on: September 11, 2008, 11:26:17 AM »
Just glad it helped Wayne :)

Hood

Offline fdos

*
  •  326 326
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #93 on: September 11, 2008, 11:34:13 AM »
Well more macro's in the works at the moment.

I can't remember the allowed custom macro rules for mach, I just been working on Collet open and close macro's.   Ideally I'd like to use the more conventional M10,11.   But they seem to be reserved for something (Probing?)

Even replacing those with my own, the new ones seem to be ignored.   I was able to use M20,21 though !   Thats also normally an clamp/unclamp signal on many machines.   But I think for Indexers.

I don't really want to start using high number M codes for those that are very conventional.

Wayne....

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #94 on: September 11, 2008, 11:43:31 AM »
Wayne
 I used M13 and M14 when I had the Hydraulic chuck on, not sure why I chose them, maybe just next available not used M codes, or could have been what the original used, will have to look at the old manual and see.
Hood

Offline fdos

*
  •  326 326
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #95 on: September 11, 2008, 02:13:45 PM »
Here's the Clamp/UnClamp macro's just in case anyone could use them.

I think the Sleep() command takes it's Argument in milliseconds??

Wayne...

'M20 Collet Clamp Macro for Hardinge HXL-S and Cubloc CUSB36R
'11th September 2008



Call setmodoutput (16,0)         'deactivate Unclamp Valve just in case
sleep (200)                                'wait 0.2 secs
Call SetmodOutput (17,1)          'Cubloc P17 Actuate Valve
sleep(200)               
Call SetmodOutput (17,0)         'Deactuate Valve No need for coil to remain on


Message ("Collet/Chuck Clamped OK")      'OK Status Msg


 
'M21 Collet UnClamp Macro for Hardinge HXL-S and Cubloc CUSB36R
'11th September 2008


DoSpinStop()               'Spindle OFF


While Getoemdro(817) > 100         'Bypassed To S Value DRO (817) For bench testing.
'While Getoemdro(39) > 100         'oemdro(39) (Spindle true) for final setup.
  message ("Waiting for spindle to Slow")
Wend                  'Wait for spindle to slow to < 100 rpm

Call setmodputput (17.0)         'Deactivate Clamp valve just in case
sleep (200)
Call SetModOutput (16,1)          'Cubloc P16 high (Unclamp)
sleep(200)                       'wait 0.2 secs
Call setmodoutput (16,0)         'Deactuate Valve No need for coil to remain on
 
Message ("Collet/Chuck UnClamped OK")      'OK Status Msg


 
 
 

                                   
« Last Edit: September 11, 2008, 02:15:59 PM by fdos »

Offline fdos

*
  •  326 326
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #96 on: September 12, 2008, 11:44:40 AM »
More stuff here.   This time the Diagnostic/In progress version on my Cubloc code.

I'll update this as I make significant alterations to it.   But might come in handy to anyone starting out or struggling with the Cubloc PLC's.

Mostly in Cubloc basic.   Some ladder will be added later.

Also a pic of the cubloc study board just about fully loaded with every switch and Led used up to test the logic on the desk.   Everything has been connected to match the IO assignments on the CUSB36R PLC.

The code below has been updated here a fair bit.   BUT BE AWARE is has a lot of diagnostic code included.  e.g the Pendant stuff which enabled me to test the toolchange routine when not connected to Mach.  I ran out of inputs and had to use the Estop input for the 4th button!   This obviously is not staying like that as I have no use for the pendant on the real machine.

Wayne....



'Hardinge HXL-S PLC code for CUSB36R

Const Device = CB280
Set Display 2,0,1,50
Opencom 1,115200,3,80,80
Set Modbus 1,1,20

Cls
Wait 1500

Locate 3,0
Print "HARDINGE HXL-S"
Locate 1,1
Print "FDOS Design   2008"
Locate 0,3
Print "PLC Firmware   V0.08"
Csroff

Wait 1500
Cls
Csroff

Dim cl As String               'Clear Line
Dim spin As String            'Spindle Status (CW, CCW, OFF)            
Dim sro As Integer            'Spindle Override Pot (% FSD)
Dim fro As Integer            'Fedrate Override Pot (% FSD)

Dim station As Integer         'Decoded Turret Station #
Dim estop As Integer            'EStop Chain Status
Dim status_page As Integer      'Current Page (LCD Display)

Dim req_tool As Integer         'Requested Tool
Dim turret_encoder As Integer   'Encoder value (all 4 bits)
Dim pendant As Integer
Dim settle_time As Long


'*******************************************
'*              RELAY OUPUTS               *
'*******************************************

Usepin 4,Out,coolant          'Coolant
Usepin 5,Out,spindle_cw         'Spindle CW   
Usepin 6,Out,spindle_ccw      'Spindle CCW
Usepin 7,Out,spindle_lock       'Spindle Lock Disengage

Usepin 16,Out,collet_open      'collet open
Usepin 17,Out,collet_close      'collet close

Usepin 22,Out,tstock_fwd      'tailstock forward
Usepin 23,Out,tstock_ret      'tailstock retract

Usepin 40,Out,cush_ret         'air cushion retract
Usepin 41,Out,cush_eng         'air cushion engage
Usepin 42,Out,index            'Turret Up and Index

Usepin 43,Out,lube_pump         'Lube Pump

Usepin 44,Out,sys_enable      'System Enable

'*******************************************
'*             ANALOGUE INPUTS             *
'*******************************************

Input 24                      'Feedrate Override
Input 25                      'Spindle Override

'*******************************************
'*               'OPTO Inputs              *
'*******************************************

Usepin 10,In,turret_down      'turret down
Usepin 11,In,index_complete   'index complete
Usepin 12,In,spindle_locked   'spindle locked
Usepin 13,In,tstock_inuse      'tailstock in Use

Usepin 28,In,tur_enc1         'turret station 1
Usepin 29,In,tur_enc2         'turret station 2
Usepin 30,In,tur_enc3         'turret station 3
Usepin 31,In,tur_enc4         'turret station 4

Usepin 32,In,low_coolant      'low coolant switch
Usepin 33,In,low_collet         'low collet pressure
Usepin 34,In,low_air            'low air pressure

Usepin 35,In,emg_stop         'EMERGENCY STOP!

Usepin 36,In                  'Page Select

Usepin 37,In,pendant1         'spare
Usepin 38,In,pendant2         'spare
Usepin 39,In,pendant3         'spare

'*******************************************
'*             startup defaults            *
'*******************************************

cl = "                    "   '20 Spaces (clear line)
status_page = 0
settle_time = 250               'Air valve settle time in milliseconds

Set Ladder On
Wait 10                        'Allow time for ladder to start


'*******************************************
'*            Bootup Operations            *
'*******************************************

Do While low_air = 0            'check low air switch is closed before proceeding
   sys_enable = 0               'Open PLC estop relay
   Gosub error_title
   Gosub low_air_error
   Wait 1000
   Locate 0,0
      Print cl                  'Flash ERROR! msg 1 sec interval
   Wait 1000   
Loop

Cls
Csroff

Locate 2,0
   Print "Reseting Startup"
Locate 6,2
   Print "Defaults"

coolant = 0                     'coolant off
spindle_cw = 0                  'spindle cw off
spindle_ccw = 0               'spindle ccw off

Do While spindle_locked = 0   'read spindle locked switch
   spindle_lock = 1            'disengage spindle lock
Loop   

Wait settle_time
spindle_lock = 0   

cush_ret = 1                  'retract air cushion
Wait settle_time
cush_ret = 0

cush_eng = 1                  'engage air cushion
Wait settle_time
cush_eng = 0

Wait 1000

start:

'*******************************************
'*                 Main Loop               *
'*******************************************

Do

   
   Gosub scan_page
   
   _d(13) = station             'load current station # into d13
   req_tool = _D(12)          'read data register 12 for requested tool

   Gosub scan_pendant

   If req_tool > 0 Then
      Gosub index_turret
   End If

   _D(10) = Adin(0)             'Read ADC0 Feedrate overide load into D10
   fro = _D(10)/10.21
 
   _D(11) = Adin(1)            'Read ADC0 Spindle overide load into D11
   sro = _D(11)/10.21
   estop = In(35)

   Csroff                     'Cursor Off
 
Loop


'*******************************************
'*              Sub  Routines              *
'*******************************************

page0:

   Gosub decode_turret
   
   Locate 0,0
   Print "P", Dec status_page," (Turret Status)  "
   Locate 0,1
   Print "Enc 1-2-3-4 Req = ",Dec req_tool," "
   Locate 0,2
   Print "Act ",Dec tur_enc1,"-",Dec tur_enc2,"-",Dec tur_enc3,"-",Dec tur_enc4
   Locate 11,2

   If station = 0 Then
      Print " : Error!"
   Else
      Print " Stn = ",Dec station," "   
   End If

   Locate 0,3
   Print "Idx Cmp ",Dec In(11),"  Tur Dwn ",Dec In(10)

Return

page1:

   Locate 0,0
   Print "P",Dec status_page," (Warning Inputs)"
   Locate 0,1
   Print "ESTOP ",Dec In(35),"    Low Air ", Dec In(34)
   Locate 0,2
   Print "Low Collet Press ",Dec In(33)," "
   Locate 0,3

Print "Low Coolant ",Dec In(32),"       "

Return

page2:

   Locate 0,0
   Print "P",Dec status_page," (Analogue Inputs)"
   Locate 0,1
   Print "FRO ",Dp(fro,3),"%","    SRO ",Dp(sro,3),"%"
   Locate 0,2
   Print cl
   Locate 0,3
   Print cl

Return

page3:
   Gosub scan_pendant
   Locate 0,0
      Print "P",Dec status_page," (Blank)          "
   Locate 0,1
      Print "spindle locked ",Dec spindle_locked,"    "
   Locate 0,2
      Print "turret down ",Dec turret_down
   Locate 0,3
      Print "Index Complete ",Dec index_complete

Return



error_title:

   Locate 7,0
      Print "ERROR!"
Return

low_air_error:

   Locate 2,2
      Print "LOW AIR PRESSURE"
   Locate 2,3
      Print "SYSTEM INHIBITED"

Return

 
scan_page:

   If Keyinh(36,250)  Then
      status_page = status_page + 1
   Endif
   
   If status_page >3 Then
      status_page = 0
   Endif
   
   Select Case status_page
      Case 0
         Gosub page0
      Case 1
         Gosub page1
      Case 2
         Gosub page2
      Case 3
         Gosub page3
   End Select
   
Return

scan_pendant:                  'Temporary routine for testing toolchange via pendant            

pendant = (pendant1 * 8) + (pendant2 * 4) + (pendant3 * 2) + emg_stop   'Convert to Pseudo Binary

Select Case pendant
   Case &b1000
      req_tool = 1
   Case &b0100
      req_tool = 2
   Case &b0010
      req_tool = 3
   Case &b0001
      req_tool = 4
   Case Else
      req_tool = 0
End Select

Return


index_turret:

   If req_tool >4 Then
      Return
   Endif
   


   Cls
   Wait 50

   Locate 0,0
      Print "Toolchange Requested"

   Do

      If station = req_tool Then
         Exit Do
      Endif   
   
      Locate 0,1
         Print "Requested Station= ",Dec req_tool
      Locate 0,2
         Print "  Current Station= ",Dec station
         Locate 0,3
            Print "Idx Comp ",Dec index_complete," Tur Dwn ",Dec turret_down
      Csroff
   
      Do Until index_complete = 1
         index = 1
         Locate 0,3
            Print "Idx Comp ",Dec index_complete," Tur Dwn ",Dec turret_down
         Csroff
      Loop
   
      Do Until turret_down = 1
         index = 0
         Locate 0,3
            Print "Idx Comp ",Dec index_complete," Tur Dwn ",Dec turret_down
         Csroff
      Loop

      Gosub decode_turret
   
      If station = 0 Then
         Goto turret_failure
      Endif
   
Loop

Return


decode_turret:

   turret_encoder = (tur_enc1 * 8) + (tur_enc2 * 4) + (tur_enc3 * 2) + tur_enc4   'Convert to Pseudo Binary

   Select Case turret_encoder
      Case &b0111
         station = 1
      Case &b1011
         station = 2
      Case &b1101
         station = 3
      Case &b1110
         station = 4
      Case Else
         station = 0
   End Select

Return

turret_failure:

   Cls
   Gosub error_title
   Locate 1,2
      Print "Toolchange Failure"
   Csroff
   sys_enable = 0                        'Generate Estop

   Wait 5000

   Goto start                           'Temporary restart


Function status(raw As Byte)As String

   If raw = 1 Then
      status = "ON "
   Else
      status = "OFF"
   Endif

End Function




« Last Edit: September 13, 2008, 07:08:12 PM by fdos »

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #97 on: September 12, 2008, 01:26:13 PM »
Wayne
 I presume the Cubeloc is 5v I/O?
Hood

Offline fdos

*
  •  326 326
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #98 on: September 12, 2008, 01:38:41 PM »
Hood.

The Study board is.   The CUSB36R is 24v able via the onboard opto's.   

http://cubloc.com/product/03_02cusb36r.php

you can also get it in the UK for £100...


Wayne...
« Last Edit: September 12, 2008, 01:41:34 PM by fdos »

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Yet another Retrofit. Hardinge HXL-S
« Reply #99 on: September 12, 2008, 02:14:04 PM »
How does Mach communicate with Cubloc?
Looks like a nice package and at £100 its pretty good value.
Hood