Programmable Limit Switch

I have the need to make a couple programmable limit switches based on position in an RMC75.

I came up with putting the following in a program that will run continuously on a second task. Is this the best way or is there something better?

AT_HIGH_PT := _Axis[0].StatusBits.InPos AND (ABS(_Axis[0].ActPos-UpperPos) <= _Axis[0].InPosTolerance); AT_LOW_PT := _Axis[0].StatusBits.InPos AND (ABS(_Axis[0].ActPos-LowerPos) <= _Axis[0].InPosTolerance);

In general, that is a very good way to do it. In fact, I just suggested that general method to a customer yesterday. I am curious about the expressions comparing UpperPos and LowerPos. If they are the same as the command position, then all you should need to look at it the InPos status bit.

So I think what you are saying is that I could just do this:

AT_HIGH_PT := _Axis[0].StatusBits.InPos AND (_Axis[0].CmdPos = UpperPos); AT_LOW_PT := _Axis[0].StatusBits.InPos AND (_Axis[0].CmdPos = LowerPos);
I can’t just use StatusBits.InPos by itself as that doesn’t tell me which specific position that I’m at, just that I’m at any commanded position.

Yep, if UpperPos and LowerPos are used as the requested position in a motion command, then those expressions should work just fine. Otherwise, you should use a range like you did initially, since floating point positions are rarely identical unless purposely made identical.

Use Norm’s first method.
The second method is overkill
BTW, the in position bit will clear by itself if the error is greater than the in position tolerance.