Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
2  
Out of curiosity, what language are you using? RobotC, LabVIEW, NXT-G? –  nhinkle May 7 '12 at 3:45
2  
@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 at 8:35

1 Answer 1

By "smoother limit", if you mean "when it gets closer to the limit, it will softly land there by slowing down" then: I recommend using PID control where the response (how fast the motor is moving to the limit) is controlled proportional to the error (how far away from the limit you are).

Wikipedia has a good intro to PID control: http://en.wikipedia.org/wiki/PID_controller

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.