Hello Guest it is June 18, 2019, 01:45:57 AM

Author Topic: Spindle button and M3 and M4  (Read 4979 times)

0 Members and 1 Guest are viewing this topic.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Spindle button and M3 and M4
« Reply #10 on: September 15, 2016, 08:39:16 AM »
You could remove the dependency on hard coded pins by using the CW and CCW Leds.

Offline Davek0974

*
  •  2,539 2,539
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #11 on: September 15, 2016, 08:46:08 AM »
How about OEMLed(11) ?
My list shows "Spindle CCW/CW if either is requested"
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Spindle button and M3 and M4
« Reply #12 on: September 15, 2016, 08:49:29 AM »
You need both LEDs to detect for ON just as you've used both outputs

Spindle rotating CW LED,   164
Spindle rotating CCW LED,   165

Offline Davek0974

*
  •  2,539 2,539
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #13 on: September 15, 2016, 08:58:42 AM »
Fair enough then :)

If GetOEMLed(164) or GetOEMLed(165) then
  DoSpinStop()
else
  If GetVar(1601)=0 then
    DoSpinCW()
  Else
    DoSpinCCW()
  End If
End if

Seems better.
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,539 2,539
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #14 on: September 15, 2016, 09:05:33 AM »
Will this work?
Brings all the code into the spindle-toggle button so no messing with M4/M5 etc

If GetOEMLed(164) Then          'was running forwards
  SetVar(1601,0)
  DoSpinStop()
ElseIf GetOEMLed(165) Then      'was running reverse
  SetVar(1601,0)
  DoSpinStop()
Else                                         'was not running
  If GetVar(1601)=0 Then
    DoSpinCW()
  Else
    DoSpinCCW()
  End If
End If
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Spindle button and M3 and M4
« Reply #15 on: September 15, 2016, 09:32:43 AM »
Looks good - just a typo - you've set 1601 to 0 in both

Here's one for you though - what happens when you start Mach and hit the spindle button for the first time i.e. when it's off?

Offline Davek0974

*
  •  2,539 2,539
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #16 on: September 15, 2016, 09:39:43 AM »
OK, sorted the typo...

Spindle start by toggle from first go, hmmm?

Are the #vars saved when Mach is closed?

If yes then it would start in the same rotation as left the day before - good or bad, I don't know.

If no then it would start forwards the first time as the #var would be zero, I guess we can add a reset macro to the INIT line that sets the #var however we want for the first time?

Depends if it's an issue or not i guess :)

Code: [Select]
If GetOEMLed(164) Then          'was running forwards
  SetVar(1601,0)
  DoSpinStop()
ElseIf GetOEMLed(165) Then      'was running reverse
  SetVar(1601,1)
  DoSpinStop()
Else                                         'was not running
  If GetVar(1601)=0 Then
    DoSpinCW()
  Else
    DoSpinCCW()
  End If
End If
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Spindle button and M3 and M4
« Reply #17 on: September 15, 2016, 10:14:40 AM »
We'll make a programatist of you yet Dave  ;D

500-600 are persistent (they're saved in the xml) so you're good to go.
« Last Edit: September 15, 2016, 10:23:29 AM by stirling »

Offline Davek0974

*
  •  2,539 2,539
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #18 on: September 15, 2016, 10:29:11 AM »
Ha, simple stuff i can handle, I do Visual Basic programming at work sometimes so this is pretty much the same.

Good to know about the 500-600, now if only there was a list of variables or a way of finding free ones ???

:)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Spindle button and M3 and M4
« Reply #19 on: September 15, 2016, 04:09:16 PM »
Hi , thx for help need to study all that and try , will let you know if it will work, I thought that somebody had that issue so there exist bulletproof solution and I only could not find it, also interesting info on destroying variables (BASIC) :)