Hello Guest it is April 23, 2024, 08:33:00 AM

Author Topic: Spindle speed  (Read 4339 times)

0 Members and 1 Guest are viewing this topic.

Spindle speed
« on: April 19, 2011, 12:26:08 PM »
Hello all, I have this INFO in another post that is mixed with other questions, so I decided to start a fresh thread with just one question. I have set-up my M3 macro along with my SpindleSpeed macro to get my spindle and gear changer working. A little history, I have VFD and automatic gear changer for high gear and low gear that uses two OUTPUTS, I also have two INPUTS that come on when the gear is in high or low position. So this means I have two pulleys, pulley 1 = 0-900 RPM and pulley 2= 901-5000 RPM. I'm still trying to get the RPM tuned in, but that is something I'm sure I can get tuned. I had to put all my gear change code in the SpindleSpeed macro, along with changing the pulleys. I will post the two macros at the end of this post.

Everything is working great except one part. I MDI M03S100, the macros run and change to low gear, and spin the spindle to 100RPM. I then MDI M05 and the spindle stops. I then MDI M03S1000 and the macros run and change to high gear, and spin the spindle to 1000RPM. I MDI m05 and the spindle stops. Now comes the problem, I then MDI M03S100 again and the macros run, they change the gear to low, but instead of running the spindle at 100RPM it runs the spindle at full speed(10v). Since the macros set the pulley to #1 it runs the spindle at 900RPM instead of 100RPM. I then MDI M05 and the spindle stops. I then MDI M03S1000 and the spindle runs at full speed(10v), which in pulley #2 makes the spindle run at 5000RPM instead of 1000RPM. I can MDI M05 and the spindle turns off but, I have to shut Mach3 down and restart it to get it not to run at the max speed.

I'm think that some DRO isn't being updated. I added a DRO to my screen to monitor, OEMDRO#817, and when I run through the above sequence I can see that the spindle speed I set is being set in OEMDRO 817.

If anyone has any idea why this might be happening please let me know.

Thanks,

Aero



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
      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  




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)'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




M5 Macro:

DoSpinStop()
DeactivateSignal(OUTPUT7)'High Gear OUTPUT
DeactivateSignal(OUTPUT8)'Low Gear OUTPUT
DeactivateSignal(OUTPUT1)'Spin CW OUTPUT
DeactivateSignal(OUTPUT2)'Spin CCW OUTPUT


Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Spindle speed
« Reply #1 on: April 20, 2011, 08:24:22 AM »
I would HIGHLY recommend that you MERGE your M3 and SpindleSpeed macro into ONE single M3 (and repeat it in a M4 if you use that as well), macro, I think they are not synching up correclty as seperate..........   

Also, Set you Pulley by talking to the Pulley DRO directly, don't do it over the setpulley() call.
See Wiki under OEM DROs for the Pulley number OEM number.

another option, would be to move your gear changing code, to a "Brain", and have it do all your gear changing logic based on, your Spindle Speed, and Pulley Number DRO.

scott
fun times
Re: Spindle speed
« Reply #2 on: April 20, 2011, 10:55:58 AM »
Thank you for the reply Poppabear.

I would HIGHLY recommend that you MERGE your M3 and SpindleSpeed macro into ONE single M3 (and repeat it in a M4 if you use that as well), macro, I think they are not synching up correclty as seperate..........   

Also, Set you Pulley by talking to the Pulley DRO directly, don't do it over the setpulley() call.
See Wiki under OEM DROs for the Pulley number OEM number.

I tried running the whole thing in the M3 macro but couldn't get it to change the pulleys.

I tried this and could never get it to work right.

M3 Macro:

Spin = GetRPM()

If Spin < 911 Then
   SetOemDRO(56,1)
   Call LowGear
   End If
   

If Spin > 910 Then
   SetOemDRO(56,2)
   Call HighGear
   End If
   

Sub LowGear
   ActivateSignal(OUTPUT8)'Low Gear (OUTPUT)
   Sleep (50)
   
   Do Until IsActive(OEMTRIG2)'Low Gear Switch (INPUT)
   Loop
   
   If IsActive(OEMTRIG2) Then
   Call SpinSpindle
   End If
End Sub

Sub HighGear
   ActivateSignal(OUTPUT7)'High Gear (OUTPUT)
   Sleep (50)
   
   Do Until IsActive(OEMTRIG1)'High Gear Switch (INPUT)
   Loop
   
   If IsActive(OEMTRIG1) Then
   Call SpinSpindle
   End If
End Sub


Sub SpinSpindle

   DoSpinCW()

End Sub

Exit Sub


There are a few variations to the above that I have tried but none could change the pulley#, as soon as I put the change pulley code in the SpindleSpeed it worked.


This is my original thread, it has everything I have tried, well almost everything. http://www.machsupport.com/forum/index.php/topic,17654.0.html

These macros run great, I just think I need to clear a var. that is storing the last RPM from the spindle.

I can try the Brain suggestion, but I need to read up on how to do it.


Thanks again,

Aero

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Spindle speed
« Reply #3 on: April 20, 2011, 11:49:06 AM »
In that case, I would make a custom Macro i.e. M800 or what ever.......
this would be your "M3" in a way, inside that macro, to start your spindle cw, "DoSpinCW()"
(there is also DoSpinCCW(), and DoSpinStop(). now basically since your using the direct VB spindle controls,
you are not in the OEM M3 (or M4) funcs....    do also your spindle speed/gear change stuff in this macro as well.

OR

move all your M3 code, into your spindle speed code, since the spindle speed is called by it at the OEM level

scott
« Last Edit: April 20, 2011, 11:54:16 AM by poppabear »
fun times
Re: Spindle speed
« Reply #4 on: April 20, 2011, 02:13:11 PM »
OK I will try the moving everything to the SpindleSpeed macro. Do I leave the M3 macro blank?


Thanks,

Aero