Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Tj256 on October 26, 2010, 11:04:38 PM

Title: Possible to use encoders for limits?
Post by: Tj256 on October 26, 2010, 11:04:38 PM
I finally have my encoders showing up in the "settings" screen under encoder positions. The main reason I want to use encoders is for safety-- basically to shut down if I go out of limits or if my steppers get out of sync by too much.

Yes, I know there is supposedly a board to do this but seems silly to buy that to simply subtract 2 values and error if the result is higher than some threshold.

Ideally I'd love for the DRO to compare itself to the encoder positions and do just that.... kill the run if things don't match. If that isn't possible, I'd like to get limits working on the encoder position. Limits aren't useful to me if the motors aren't where mach thinks they are. I want the limits to be based on where they actually are... ie the encoder position.

I'm hoping this is possible?

Thanks in advance!
Title: Re: Possible to use encoders for limits?
Post by: Hood on October 27, 2010, 03:03:55 AM
It should be possible to do the compare either in a Brain or a Macropump but whether that will be fast enough will depend on the axis speeds you normally have. The update rate for Brains and Macropump is 10Hz at best. A plugin would likely make things much faster and I think that is what Ron Rogers board uses.
Title: Re: Possible to use encoders for limits?
Post by: Tj256 on October 27, 2010, 10:00:58 AM

I'm not familiar with "Brains" or "Macropumps" but I think you're referring to the VB Script capabilities of MachIII. 10 hz is just fine, as this is only supposed to catch the tool just before it careens through the table. I'm using a MaxNC15 with steppers so things aren't running terribly fast. Albeit much faster than it used to with the stock controller ;-)

I want to add 2 features. One is the "auto shutoff" if the motors bind, and the other is homing with auto shutoff again if the motors bind. I have worries that if a limit switch broke I'd crash my machine.

I am still new at all this, but these features seem like they should have been stock on my machine! On day 1 my machine crashed out of the box when I hit "home". I figured with those encoders, the machine would have been smart enough to shut itself down.
Title: Re: Possible to use encoders for limits?
Post by: ger21 on October 27, 2010, 11:37:39 AM
Why not just use Softlimits?

A macropump is a VB script that runs 10 times /second.

The commercial board used to do it this way, before they wrote a plugin to do it. What they did was pause the machine if it was out of position.
Title: Re: Possible to use encoders for limits?
Post by: Tj256 on October 27, 2010, 12:28:03 PM
I'll be using softlimits for sure. Softlimits use what the main DRO claims is the current position but not the actual position as reported by the encoders. So if for some reason my steppers hiccup, it is still possible for my machine to go out of limits.

I'm basically looking to do softlimits with the encoders, which I don't think is possible without writing a plugin/brain/script. I could be wrong though.

The brain would basically say "if (Encoders - Main DRO) > small limit then PAUSE"

My fear is that a bit gets worn down during the run, and then the x or y motor stalls and the actual cutting position is not where the machine thinks it is.

This seems like a feature everyone would want! I don't want to stare at the machine for hours on end, and would like the confidence of being able to walk away knowing it will stop if things get wacky.

I've got a MaxNC15 that used to be CL, but the CL idea seems silly to me on steppers. It does seem useful however for detecting an error and stopping a run. To do this, I've hooked up my steppers to the geckodrive as usual and the encoders to a second parallel port. So far it looks like this is going to work. I just have to write a brain. That sounds funny :)
Title: Re: Possible to use encoders for limits?
Post by: Hood on October 27, 2010, 02:36:20 PM
Possibly a macropump with something like this in it would work

If GetOemDRO (29)<0 Or GetOemDRO(29)>100 Then
End If

You may have issues though when homing so may have to have it look at a user LED before it will act, your user LED would have to be operated via the RefAll buttons, you would need to add VB in it to switch the LED off, let it home, zero the X encoder DRO then switch it back on, maybe something like this

DoButton( 24 )
DoButton( 23 )
DoButton( 22 )
DoButton( 25 )

If it was needed then the macropump code would need to be something like

If GetUserLED(1111) And (GetOemDRO (29)<0 Or GetOemDRO(29)>100 )Then
End If

Obviously you would need to add the other axis into the VB and alter the values for the < and > to suit.