Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Kently on April 21, 2009, 02:15:24 PM

Title: Racking Detection with Encoders
Post by: Kently on April 21, 2009, 02:15:24 PM
On the CNC I am building I have a two motor y-axis moving a gantry. The motors will be slaved in Mach. I want to keep from racking the gantry if one motor stalls. I would like to install an encoder on each motor. I realize Mach does not support closed loop, but is it possible to have Mach detect when one encoder count is different from the other by more than a predefined number of counts and then have Mach issue an e-stop? If so, how?

Thanks in advance,
Kent
Title: Re: Racking Detection with Encoders
Post by: Hood on April 21, 2009, 02:44:37 PM
You could do that by putting the encoders into Mach and write a macropump to compare, it would probably have to be low count encoders for best results. I am not great with VB so dont ask me how to write the macropump ;)
Hood
Title: Re: Racking Detection with Encoders
Post by: BClemens on April 21, 2009, 03:53:24 PM
How about feeding back the slaved servo encoder signal to a missing pulse detector or a phase locked loop. When the slave servo motor stopped or slowed down and the pulses no longer were in phase, the circuit would E-stop the master signal from Mach 3 to the driver servo motor. That would be exclusive of Mach 3 but would ultimately control the estop. That shouldn't be too tough to come up with on a small circuit board or pref board pin to pin. Possibly use the master encoder signal to sync the driver and the PLL, and the slaved encoder signal to initiate an estop through the PLL as the detected sync frequency. The LM 566 is a dedicated phase locked loop chip that can be configured for various pulse frequency spans with discreet components and outputs a fault signal when the phases are out of sync.

Or as Hood is saying - a macropump. There are a couple of guys here that know that stuff!

Bill C.
Title: Re: Racking Detection with Encoders
Post by: Hood on April 21, 2009, 03:56:50 PM
Bill
 would it be possible to set an error value before it sent out a trip signal? If so then that would be a good solution as you could even put the signal into Input 1 in Mach and Mach would fault.
Hood
Title: Re: Racking Detection with Encoders
Post by: Kently on April 21, 2009, 04:10:25 PM
How about feeding back the slaved servo encoder signal to a missing pulse detector or a phase locked loop. When the slave servo motor stopped or slowed down and the pulses no longer were in phase, the circuit would E-stop the master signal from Mach 3 to the driver servo motor. That would be exclusive of Mach 3 but would ultimately control the estop. That shouldn't be too tough to come up with on a small circuit board or pref board pin to pin. Possibly use the master encoder signal to sync the driver and the PLL, and the slaved encoder signal to initiate an estop through the PLL as the detected sync frequency. The LM 566 is a dedicated phase locked loop chip that can be configured for various pulse frequency spans with discreet components and outputs a fault signal when the phases are out of sync.

Or as Hood is saying - a macropump. There are a couple of guys here that know that stuff!

Bill C.

I thought of designing a simple counter circuit for each encoder that could be reset at the start of a run and then have a digital comparator generate an e-stop if the counts differ by a given amount. I have not started using Mach yet as I am stilll in the process of building the machine. I do not know what signal would be used to signify the "start of a run", but I assume there is something available. Worst case would be to reset on power up. However, I'd really prefer to do this in Mach and not have to add another circuit to the mix.
Title: Re: Racking Detection with Encoders
Post by: BClemens on April 21, 2009, 04:16:23 PM
I would have to brush up on configuring the LM 566 but I believe the best way would be - if not one for one at any speed, the system would fault and output a signal. That-is: if the signals were not identical, the PLL would fault since in this application both servo motors must be totally in phase with each-other.

 But, I'll have a look at the 566 chip data sheet.

Bill C.
Title: Re: Racking Detection with Encoders
Post by: BClemens on April 21, 2009, 04:23:04 PM
How about feeding back the slaved servo encoder signal to a missing pulse detector or a phase locked loop. When the slave servo motor stopped or slowed down and the pulses no longer were in phase, the circuit would E-stop the master signal from Mach 3 to the driver servo motor. That would be exclusive of Mach 3 but would ultimately control the estop. That shouldn't be too tough to come up with on a small circuit board or pref board pin to pin. Possibly use the master encoder signal to sync the driver and the PLL, and the slaved encoder signal to initiate an estop through the PLL as the detected sync frequency. The LM 566 is a dedicated phase locked loop chip that can be configured for various pulse frequency spans with discreet components and outputs a fault signal when the phases are out of sync.

Or as Hood is saying - a macropump. There are a couple of guys here that know that stuff!

Bill C.

I thought of designing a simple counter circuit for each encoder that could be reset at the start of a run and then have a digital comparator generate an e-stop if the counts differ by a given amount. I have not started using Mach yet as I am stilll in the process of building the machine. I do not know what signal would be used to signify the "start of a run", but I assume there is something available. Worst case would be to reset on power up. However, I'd really prefer to do this in Mach and not have to add another circuit to the mix.

I agree with you: less circuitry = less problems. I was thinking more toward an analog circuit so that there would be no start or stop signal to contend with but digital is very much do-able as well. But -  the macropump program within Mach 3 is probably the much more sensible way to go....

Bill C.
Title: Re: Racking Detection with Encoders
Post by: ostie01 on April 21, 2009, 04:29:54 PM
I'm not sure that the LM556 is a good choice, it work with resistor and capacitor which will vary with change of temperature and other factor. It will produce a pulse but not always at the desired rate.

If you want precision, you should got with crystal base generator or directly with the output of a parallel output.
Title: Re: Racking Detection with Encoders
Post by: BClemens on April 21, 2009, 07:10:19 PM
Wrong chip? Analog will never do today anyhow! Let's program a computer to do the job...makes sense to me. Even PIC chips will soon be old fashioned! But joy is being able to compare analog which I grew up with to digital which I learned as it developed. I enjoy both. Now everything is digital....probably a good thing!

Just placing stumbling blocks of thought in here....

Thanks,
Bill C.
Title: Re: Racking Detection with Encoders
Post by: Kently on April 21, 2009, 10:11:20 PM
Where can I learn about a macropump and the macro language? Sorry for asking such a newb question. I would really appreciate it if someone could post a snipit of code that is a starting point for this problem, such as reading an encoder input, and then describe, or point me to documentation, regarding installing it as a macropump. I'd much prefer this route, assuming it is feasible, as opposed to developing a circuit to do this.
Title: Re: Racking Detection with Encoders
Post by: Hood on April 22, 2009, 03:12:16 AM
As I said I know very little about VB but maybe something like this would be a start. PoppaBear (Scott Schaefer) is probably the guy to give you a help with VB.

A=GetOemDRO(29)
B=GetOemDRO(30)


If ((A+B)/2)<10Then
 DoOemButton(1003)
  MsgBox("Encoders Differ")
If ((A+B)/2)>10 Then
  DoOemButton(1003)
  MsgBox("Encoders Differ")
End If
End If


I have not tested it so its probably full of syntax errors but it may get you started.
There is a list of OEM codes at the top of the forum, it contains all of the codes for buttons, LEDs and DROs.
The macropump can be anabled on General Config page and you will need to save the VB to your macro folder for the profile you are using, you name it macropump.m1s

Hood
Title: Re: Racking Detection with Encoders
Post by: BClemens on April 22, 2009, 05:17:52 AM
Hood, You're a wealth of good info....up to date too!

Kently,   Top menus:   'Support' - 'Tutorial Videos' - 'ArtSoft VideoTutorials' - 'Introduction to MacroPumps'  is a good place to start.....

Bill C.
Title: Re: Racking Detection with Encoders
Post by: Hood on April 22, 2009, 05:26:09 AM
Looking at what I posted above I can see right away that there would be a problem as whenever the Encoders were out of sync by the amount set (10 in this case) it would be impossible to do anything as the Stop would constantly be getting pressed. A means of disableing the code in the macropump would be needed, easy enough I would think if you made it that a User LED was needed along with the above code to be true, that way you could have a button switching the LED on and off.
 Actually it may just be as easy to do this in a Brain, the benefit is Brains are a bit faster than the macropump and no syntax to get wrong :D.

Hood
Title: Re: Racking Detection with Encoders
Post by: Hood on April 22, 2009, 05:28:49 AM
oh and my formula is all to cock as well LOL, thats what I get for typing 10 mins after I wake up. You would need to compare the DROS and if out by a set amount then fault out.

Hood
Title: Re: Racking Detection with Encoders
Post by: Kently on April 22, 2009, 01:25:35 PM
Thanks to all for posting ideas. Perhaps I asked this question too soon in my learning curve. I realize when such basic questions are asked that it can be frustrating for others, especially when many things can be answered by documentation that is available. So I need to bone up on writing macros and brains and will then hopefully ask more detailed questions or actually solve it myself. Based on the feedback, it does appear that Mach will handle doing this in software which was really the basic question I wanted answered. I had hoped that this had been done before and someone could point me to a post or have the "easy" answer. I would have thought this would have been solved before. Some have gone to great lengths to mechanically eliminate the possibility of racking.

Thanks again to all!
Kent