Hello Guest it is August 20, 2019, 05:29:16 PM

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

0 Members and 1 Guest are viewing this topic.

Spindle button and M3 and M4
« on: September 15, 2016, 03:22:44 AM »
Hi guys,

I have CNC lathe , was running some G code yesterday, then wanted to pause spindle and feed in order to remove chips from tool safely, so I pressed feed hold button and spindle button.

When I wanted to proceed with execution of my G code program I pressed spindle button and cycle start button and thing is that I found out that spindle starts to rotate in M3 or CW mode/ direction ,
thing is that in program before stop it was command to use M4 or CCW , so it never crossed my mind that if I stop spindle that it will continue to execute g code program but with wrong RPM direction.

Today I went to find what is behind spindle button and it is function for spindle CW and reset THC height.

Now question is how to make that when I want to stop execution of g code and want to remove chips in safe way to proceed with g code but with spindle rotation which is programed by G code, did not tried yet but probably I can make same button below existing one that will give command to rotate spindel in CCW dirction,

Is it possible to make that by pressing only one button, somehow to program continue with correct RPM direction?

Yesterday was wondering how from some point my boring bar was producing chips like it was to aggressive cut, and was really surprised when I figured out that stopping spindle in the middle of program was thing that made problems , not depth of cut, luckily tool was not destroyed.
Hope somebody have some example how to solve this or what is normal procedure.

This is my machine and tool whit which I had problems (I thought that cuts to deep , first it was removing 0.1 mm of material then changed to 0.05 mm and after that I was, there is something wrong here LOL)
https://www.youtube.com/watch?v=8iJwtRoWx3o

Thanks in advance :)

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #1 on: September 15, 2016, 04:33:48 AM »
Could possibly be done with a #var - every time the M3 or M4 is called it will store a value representing the last called direction in the variable, when you press spindle toggle manually, it would read that variable and call the correct direction.

I can see issues here but thats where i would probably start ;)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Spindle button and M3 and M4
« Reply #2 on: September 15, 2016, 04:59:46 AM »
Could possibly be done with a #var - every time the M3 or M4 is called it will store a value representing the last called direction in the variable, when you press spindle toggle manually, it would read that variable and call the correct direction.

I can see issues here but thats where i would probably start ;)
Hi

I read couple of time what you wrote and I do not not how to implement that, I mean where to use #var.

From my experience when some data need to be saved and read it only worked saving them in file otherwise every time I enter in macro variable is not remebered. Probbly I could use saving in file information but was hoping that there exist something simpler of what I am not aware of. Thank for your help. I assume somebody had this kind of problems already.

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #3 on: September 15, 2016, 05:32:53 AM »
If done correctly, Mach will remember the variable for the current session.

I would need to test it out but possibly put the variable in M3,M4 macros or there may well be a better place.

It will need some testing but I'm sure this can be done.
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 #4 on: September 15, 2016, 06:16:17 AM »
From my experience when some data need to be saved and read it only worked saving them in file otherwise every time I enter in macro variable is not remebered. Probbly I could use saving in file information but was hoping that there exist something simpler of what I am not aware of. Thank for your help. I assume somebody had this kind of problems already.

BASIC variables are destroyed between macro runs (except in the macropump) but GCODE vars are not. That's why Dave is suggesting you use a gcode var to maintain state between calls. Look up setVar and getVar().

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #5 on: September 15, 2016, 06:27:44 AM »
This is quite an interesting issue, never thought about until now. ;)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #6 on: September 15, 2016, 06:40:31 AM »
I would start here....

First, get a safe backup copy of your entire Mach3 folder.

Next edit your M3 macro - its in the macro folder of the same name as the profile you are running.

Add, after the DoSpinCW() line...
SetVar(1601, 0)

Save the file

Edit the M4 file, same location,

Add after the DoSpinCCW() line
SetVar(1601,1)

Save the file

Edit your spindle button text.

Comment out the DoSpinCw() line by placing a ' at the start.

Then add...
 
If GetVar(1601)=0 then
DoSpinCW()
Else
DoSpinCCW()
End If

Save the button text.

Try that, I think it will work, with the usual disclaimers of course :)

This is all presuming that #var 1601 is a free variable and not used elsewhere, hard to tell with Mach ;)
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 #7 on: September 15, 2016, 07:16:44 AM »
Close Dave but that means your spindle button has no way of turning OFF your spindle - but you're getting there  ;)
« Last Edit: September 15, 2016, 07:46:33 AM by stirling »

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #8 on: September 15, 2016, 07:43:14 AM »
Ah, bugger, nobody mentioned turning it off :)

Ok, more thought......
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Spindle button and M3 and M4
« Reply #9 on: September 15, 2016, 08:03:09 AM »
I  can't see a better way so I would offer up

If IsOutputActive(OUTPUTcw) or IsOutputActive(OUTPUTccw) then
  DoSpinStop()
else
  If GetVar(1601)=0 then
    DoSpinCW()
  Else
    DoSpinCCW()
  End If
End if

Where cw and ccw are the port numbers assigned to M4 & M5 in ports & pins.
« Last Edit: September 15, 2016, 08:05:31 AM by Davek0974 »
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives