Hello Guest it is March 28, 2024, 12:53:40 PM

Author Topic: SystemWaitFor(INDEX) ...will it work?  (Read 14508 times)

0 Members and 1 Guest are viewing this topic.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #10 on: November 13, 2012, 11:54:14 AM »
It appears that the OLD machine ramped the spindle down to a stop. The Drive has a setting for ramp up/down values. Have you tried adjusting the stop side to ramp down faster.

Modern machine bring the spindle to dead stop THEN creep the spindle over to the index point and CAN provide an offset to align the dawgs. 

IF you ramp the spindle to a stop  what is the slowest you can reliably move(creep) the spindle from a dead stop? 

(;-) TP

Offline Sweep

*
  •  150 150
    • View Profile
    • pollz.co.uk
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #11 on: November 13, 2012, 02:29:37 PM »
My problem isn't the ramping down of the speed or disengaging the relay at 60rpm, it is that I can't figure out the VBscript to look for the index, or Input2, pulse and then disengage the relay. Every time I try it it either doesn't see the index or doesn't hold the next line of the program until the spindle has stopped.
An extract of what the program currently looks like is shown below in black with what I think should be used for the spindle alignment in RED. I have put a Sleep 25 as a tunable deceleration figure but it will probably be better to move the sensor to exactly the position I need it.
So, is the code any good or a recipe for disaster?

x = GetUserDRO(1200)
y = GetUserDRO(1201)
z = GetUserDRO(1202)
Code "G00 G53 Z" & z
While IsMoving ()    'pause to allow Z axis to move to change position
Sleep 100
Wend

Code "M3 S60" 'spindle run at minimum speed
Sleep 5000 'allow spindle speed to stabilise
While Not IsActive(INPUT2) 'look for spindle proximity switch
Sleep 500
Wend
If IsActive(INPUT2) Then
              Sleep 25 'alter figure to tune deceleration
              Code "M5" 'stop spindle
End If

Code "G00 G53 X" & x & "Y" & y
While IsMoving ()   'pause to allow XY axis to move to change position
Sleep 100
Wend

Slot1 = GetUserDRO(1101)
Slot2 = GetUserDRO(1102)
Slot3 = GetUserDRO(1103)
Slot4 = GetUserDRO(1104)
Slot5 = GetUserDRO(1105)
Slot6 = GetUserDRO(1106)
« Last Edit: November 13, 2012, 02:31:59 PM by Sweep »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #12 on: November 13, 2012, 03:08:52 PM »
With you line of thinking there are several things working against you .

1 CB is incredibly slow reacting to inputs it can ONLY read the line 10 times per sec in a perfect world. Could be that Mach3 never sees the input before the event is over. Depends on the dwell of the event at 60rpm(;-).

2 you are assuming that mach3 KNOWs when the spindle has stopped and can proceeed. ARE you looking for rpms of the spindle to determine that?

Has the light come on yet?

(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #13 on: November 13, 2012, 04:46:01 PM »
SO thinking about this you need to get to the driver level operations to control the stopping of the spindle. The driver ops operate at kernal freq and are very fast to react.

SO if you use a phantom axis say C and set up the home with your output from the sensor.

WHen you need to TC stop spindle

Refhome C it rotates until it sees the trip then stops. You will have to adjust the trip position so it stops where you want.


 Use the DIR pins to run a relay(DPDT) to turn ON the motor to home then as the sensor trips it reverses the dir pin (turns off ) the motor and resets the HOME switch so that C axis Rehome is completed and it clears the function.  Feed the relay(motorside) through a resistor to set the voltage level for the spindle to get 50 rpm or so. The slower you can run the better and more accurate the stop point.  I would also set the stop side ramp to be more agressive. TO help stop the spindle.



That would be one way to garranty that the sensor is seen and the operation be an auto function.

Just a thought, (;-) TP
« Last Edit: November 13, 2012, 04:58:30 PM by BR549 »

Offline Sweep

*
  •  150 150
    • View Profile
    • pollz.co.uk
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #14 on: November 13, 2012, 05:10:14 PM »
Hi TP,

I have had a tweak of my DC controller and can drop the speed down to 20rpm. I then measured the arc of detection of the spindle proximity switch and got about 13 degrees.
Considering 20rpm/60 = 0.33r/s or 3sec/rev, and 360/13 = 27, then 3/27 = 0.11seconds the switch is active. Is that sufficient for a reliable trigger?
I suppose we could also set a timer cycle at the same time so if it doesn't detect in, say, 5 revs bail out of the toolchange program and call an alarm.

To comment on your last post. The spindle is controlled by PWM and will run a steady 20rpm now I have tweaked the pot, but currently I don't have a seperate relay to reverse the spindle. I only have to get close, however, as don't forget the spindle will centre when the pnematic ram operates if it is +/- 20 degrees or so from perfect alignment

...Sweep

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #15 on: November 13, 2012, 05:33:30 PM »
well at a perfect 10 hz that is .1 sec detection time. I think it best to IF isactive then SetUserLed(on) so once it gets seen and it sets the led on you no longer rely on the sensor to drive the function. It only has to be seen one time out of many.



After that I would add a safety line that IF the index is not seen in say 2 sec then assume the spindle has stopped and good  to go.

Just remember somewhere along the line as the TC function ends to turn OFF the LED(;-)

Offline Sweep

*
  •  150 150
    • View Profile
    • pollz.co.uk
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #16 on: November 13, 2012, 05:39:32 PM »
Just had a bit of an experiment with your C axis suggestion which seemed quite neat. Unfortunatley because Mach is sending a PWM signal to the relay, as it thinks it is driving a motor, there isn't enough continuous current to open the relay. My LED relay tell-tale light illuminates dimly but the relay doesn't engage.

...Sweep

Offline Sweep

*
  •  150 150
    • View Profile
    • pollz.co.uk
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #17 on: November 13, 2012, 05:41:05 PM »
I will have to close down now as it's 10:40pm over here and my eyes are getting tired.
Thanks for your help TC and goodnight.

...Sweep

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #18 on: November 13, 2012, 06:00:53 PM »
YOU would USE the Dir PIN to switch the relay it is 5v or 3v. When the Refhome is called the axis is sent in a specific direction to the home switch. SO it has to set the DIR pin one way or the other.  Once it trips then the DIR pin reverses.

I am working on a CB version as well and may even try a brain version   HOPEFULLY somewhere we find the secret handshake to make it work for you.

Question for tomorrow WHat drives your spindle drive  PWM, +10v,step dir, ???

There is always tomorrow, (;-) TP
« Last Edit: November 13, 2012, 06:03:26 PM by BR549 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: SystemWaitFor(INDEX) ...will it work?
« Reply #19 on: November 14, 2012, 10:16:43 AM »
When You get a chance see IF this Button code can see the index signal . Notice that we did NOT jump out to the GCode anywhere so should be stable.

It sets the spindle speed to 20 then turns ON the spindle and watches for the index signal. IF it does not see it in about 5 secs it errors out and stops spindle with message.

If it sees it then it stops the spindle with message .

SetOemDro(817,20)
SetUserDRO(2001,0)
DoSpinCW()

Do While Not Isactive(index) And GetUserDro(2001)<6
SetUserDro(2001,(GetUSerDro(2001)+1))
Sleep(1000)
If GetUSerDro(2001) >5 Then
DoSpinStop()
Message"Spindle Detect Timeout"
End
End If
Loop

SetUserLEd(2000,1)
While Ismoving()
Wend

DoSpinStop()
Message"Ready For Tool Change"


End