|
Ben Fleskes wrote:
>
> The program looks for input from the message buttons on the infrared remote.
> Message 1 decreases speed, Message 2 sets the speed to 0, and Message 3
> increases the speeed. On problem I have is that when I give it message 2, the
> variable 'speed' goes to zero but the motor doesn't stop. Anyone know what I'm
> doing wrong? Anyone have suggestions for refining the code. Perhaps a better
> speed control algorithem. Thanks to Dave B(for NCQ) and Mark Overmars (for the
> tutorial)
>
> Thanks for any advice, hints, feedback or suggestions
>
> Here is the code: (please excuse me if it is not appropriate to post it here)
>
> int speed , __speed;
>
> task run_motor()
> {
> while (true)
> {
> __speed = speed;
>
> if (__speed > 0) {SetPower(OUT_A,speed);OnFwd(OUT_A);}
> if (__speed < 0) {SetPower(OUT_A,-speed);OnRev(OUT_A);}
> }
> }
you never check if your speed is 0 in this task - IMO, you need to add:
if (__speed == 0) {Off(OUT_A)};
(I'm guessing here, since I haven't really done any NCQ myself yet. :/
Dan
|
|
Message has 1 Reply:
Message is in Reply To:
84 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|