# NXC Saturation algorithm for limiting motors?

What is a good algorithm in NXC for control saturation? I want to make sure my motors don't turn past a certain angle, or they will break the model. I could do something like:

if (angle > 45) {angle = 45;)


But that would be a hard limit. I'm looking for a smoother limit.

• Out of curiosity, what language are you using? RobotC, LabVIEW, NXT-G? – nhinkle May 7 '12 at 3:45
• @nhinkle, I don't mean to be patronising, but it does say NXC in the title. (N ot e X actly C) (not a very helpful site, but this'll do) – ACarter Jun 4 '12 at 17:30
• @ACarter whoops... totally missed that somehow. I guess my mind translated it to nxt somehow. – nhinkle Jun 4 '12 at 20:31
• what do you mean by "smoother limit"? do you mean what kpt said, that the motor slows down before reaching the angle limit? – Nate Koppenhaver Jun 9 '12 at 2:41
• Yes, I mean the motor slows down. The line of code I suggested would be to slow because of inertia of the model. – Antonvh Aug 8 '14 at 8:35