another option would be (since your talking about a following error kind of thing), to run in brians.
Encoder (on z axis) x (factor to tune it to the axis) = v0
abs (v0-z absolute coordinate DRO), compare if greater than some value, then E-Stop
** Use the formulas and compare statements in brians for the above.