Hello Guest it is April 19, 2024, 02:20:09 PM

Author Topic: M03 macro and changing pulleys  (Read 20166 times)

0 Members and 1 Guest are viewing this topic.

Re: M03 macro and changing pulleys
« Reply #30 on: April 13, 2011, 06:22:42 PM »
OK, I have a new problem. When I MDI m3s100 it goes through its gear change beautifully, and starts the spindle and runs at 100rpm. I then MDI m5 the spindle stops, I then MDI m3s1000 and the gear changes and the spindle spins to 1000rpm... so far so good, OK now the strange part. I then MDI m5 to stop the spindle then put m3s100 again, the gear changes to low gear like it should but it runs the spindle at max RPM. When I look at the "Spindle Speed" windows it shows 900 in the S ov and 100 in S, 900% Override. It seems to me that either the GetRPM() isn't working properly for me or I have another problem I'm not aware of. Here is a copy of my SpinSpeed macro and M3 macro.

Spinspeed:


Spin = GetRPM()

 If Spin < 901 Then
   SetPulley(1)
   Call LowGear
   End If

 If Spin > 900 Then
   SetPulley(2)
   Call HighGear
   End If


Sub LowGear
 
   DeActivateSignal(OUTPUT7)'HG=7 LG=8

   ActivateSignal(OUTPUT8)'Low Gear

   While IsActive(OEMTRIG2) = False'HG=1 LG=2
      Sleep(10)
   Wend
   
   If IsActive(OEMTRIG2) Then
   Message "Low gear input is active"
   End If
   
   Call SpinON

End Sub
 

Sub HighGear
 
   DeActivateSignal(OUTPUT8)'HG=7 LG=8

   ActivateSignal(OUTPUT7)'Low Gear

   While IsActive(OEMTRIG1) = False'HG=1 LG=2
      Sleep(10)
   Wend
     
   If IsActive(OEMTRIG1) Then
   Message "High gear input is active"
   End If
   
   Call SpinON

End Sub

Sub SpinON

   Sleep(5000)
   rpm = GetRPM()
   SetSpinSpeed( rpm )
   
End Sub   


M3:


SpinS = GetRPM()

 If SpinS < 901 Then
   Call LowGearON
   End If

 If SpinS > 900 Then
   Call HighGearON
   End If


Sub LowGearON

   While IsActive(OEMTRIG2) = False
      Sleep(10)
   Wend
   
   If IsActive(OEMTRIG2) Then
   Sleep(5000)
   Message "Spindle On"
   DeActivateSignal(OUTPUT2)'Spin Reverse
   ActivateSignal(OUTPUT1)'Spin Forward
   DoSpinCW()
   End If

End Sub


Sub HighGearON

   While IsActive(OEMTRIG1) = False
      Sleep(10)
   Wend
     
   If IsActive(OEMTRIG1) Then
   Sleep(5000)
   Message "Spindle On"
   DeActivateSignal(OUTPUT2)'Spin Reverse
   ActivateSignal(OUTPUT1)'Spin Forward
   DoSpinCW()
   End If

End Sub   



If anyone can see a problem in my code please let me know.

Thanks,

Aero
Re: M03 macro and changing pulleys
« Reply #31 on: April 14, 2011, 10:59:43 AM »
I was thinking that I might need to zero out a DRO at the beginning of my SpinSpeed macro. Any thoughts?

Thanks,

Aero

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M03 macro and changing pulleys
« Reply #32 on: April 14, 2011, 10:04:20 PM »
Exactly how are you using the programs. How are you calling them to work.

(;-) TP
Re: M03 macro and changing pulleys
« Reply #33 on: April 15, 2011, 10:13:54 AM »
Exactly how are you using the programs. How are you calling them to work.

(;-) TP

Not sure what you mean. I thought they are called up by using the M03 command. Please explain.

Thanks,

Aero

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M03 macro and changing pulleys
« Reply #34 on: April 15, 2011, 11:02:05 AM »
Isee where you have a program called SpinSpeed and then a portion of code in the M3 macro?

Where does the SpinSpeed program reside and what tiggers it? Is it in a macropump?

Can you explain the sequence of events to make it all take place.

(;-) TP
« Last Edit: April 15, 2011, 11:03:51 AM by BR549 »
Re: M03 macro and changing pulleys
« Reply #35 on: April 15, 2011, 11:12:20 AM »
I had that same problem, I was fighting to get the SetPulley() to work in M3 macro, but wouldn't work... once I put it in the SpinSpeed macro it worked great. I'm guessing that the SpinSpeed macro and the M3 macro run at the same time, or the Spinspeed macro runs first then the M3 macro, since I got it to change gears before it ran the M3 macro. But my question is that something is being set when I put the spindle at a higher speed then try to go to a lower speed, the lower speed is overran by the high speed I programed.


Aero
« Last Edit: April 15, 2011, 11:14:15 AM by Aeroshade »
Re: M03 macro and changing pulleys
« Reply #36 on: April 15, 2011, 11:16:16 AM »
Add: The SpindleSpeed macro is located in the macro folder of Mach3. Sorry I have been calling it SpinSpeed macro I should have called it SpindleSpeed macro, sorry or the confusion :)

Aero

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M03 macro and changing pulleys
« Reply #37 on: April 15, 2011, 12:17:36 PM »
I still need the sequence of events that make it all work to test it.

(;-) TP
Re: M03 macro and changing pulleys
« Reply #38 on: April 15, 2011, 04:46:40 PM »
Not sure what you are asking, but here is a better picture of what the M3 and SpindleSpeed macro are doing.



SpindleSpeed MACRO:

Spin = GetRPM()

 If Spin < 901 Then
   SetPulley(1)
   Call LowGear
   End If

 If Spin > 900 Then
   SetPulley(2)
   Call HighGear
   End If


Sub LowGear
 
   DeActivateSignal(OUTPUT7) 'High gear OUTPUT off

   ActivateSignal(OUTPUT8) 'Low Gear OUTPUT on

   While IsActive(OEMTRIG2) = False 'Checks to make sure Low gear INPUT is active
      Sleep(10)
   Wend
   
   If IsActive(OEMTRIG2) Then
   Message "Low gear input is active"
   End If
   
   Call SpinON

End Sub
 

Sub HighGear
 
   DeActivateSignal(OUTPUT8) 'Low gear OUTPUT off

   ActivateSignal(OUTPUT7) 'High Gear OUTPUT on

   While IsActive(OEMTRIG1) = False 'Checks to make sure High gear INPUT is active
      Sleep(10)
   Wend
     
   If IsActive(OEMTRIG1) Then
   Message "High gear input is active"
   End If
   
   Call SpinON

End Sub

Sub SpinON

   Sleep(5000)
   rpm = GetRPM() 'this is what was in the SpindleSpeed macro
   SetSpinSpeed( rpm ) 'this is what was in the SpindleSpeed macro
   
End Sub   


M3 MACRO:


SpinS = GetRPM()

 If SpinS < 901 Then
   Call LowGearON
   End If

 If SpinS > 900 Then
   Call HighGearON
   End If


Sub LowGearON

   While IsActive(OEMTRIG2) = False 'Makes sure Low gear INPUT is active
      Sleep(10)
   Wend
   
   If IsActive(OEMTRIG2) Then
   Sleep(5000)
   Message "Spindle On"
   DeActivateSignal(OUTPUT2) 'Turns off Spindle reverse (CCW) OUTPUT
   ActivateSignal(OUTPUT1) 'Turns on Spindle forward (CW) OUTPUT
   DoSpinCW() 'this is what was in the M3 macro
   End If

End Sub


Sub HighGearON

   While IsActive(OEMTRIG1) = False 'Makes sure High gear INPUT is active
      Sleep(10)
   Wend
     
   If IsActive(OEMTRIG1) Then
   Sleep(5000)
   Message "Spindle On"
   DeActivateSignal(OUTPUT2) 'Turns off Spindle reverse (CCW) OUTPUT
   ActivateSignal(OUTPUT1) 'Turns on Spindle forward (CW) OUTPUT
   DoSpinCW() 'this is what was in the M3 macro
   End If

End Sub



Thanks for the help,

Aero
« Last Edit: April 15, 2011, 04:48:28 PM by Aeroshade »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M03 macro and changing pulleys
« Reply #39 on: April 15, 2011, 06:04:47 PM »
It looks like you are calling a macro from inside of a macro. NOT a recomended practice in Mach3. Only in the very latest version is there "some "support to do this.

I would suggest combining all the code in the M3 macro and getting it sorted out there (;-) I can see where it would require a bit MORE timing controll but should work fine from the M3.

(;-) TP