Log in

View Full Version : Globe Motor


Team168
15-02-2003, 18:54
We have a globe motor set to a speed controller on the RC and we have two digital switches on the OI to control it. What do we set the PWM to in the Serout command?

Manoel
15-02-2003, 20:09
Here's my suggestion:



globe_motor VAR byte ' put this in the "declare variables" section

' Main Loop:

globe_motor = 127 + (127*switch_one) - (127*switch_two)


You gotta put the globe_motor in your serout, in whatever PWM output you want.

With this code, the motor will turn CW if switch_one is pressed, and CCW if switch_two is on. If both are pressed, nothing happens.

Hope I helped, feel free to ask any question. :)

Goya
16-02-2003, 00:05
Just a quick question -

Is PBASIC operand supportive? For example, would it work mathematically left to right, do exponents before subtraction, etc?

Manoel
16-02-2003, 11:50
It works from left to right, period.
For example:
3+2*6
In normal math, you would multiply 2 by 6 and then add 3, for a total of 15. In PBasic, you sum 2 to 3 and then multiply by 6, resulting in 30. You have to use parentheses if you want to give any operation priority over another.

Hope I was clear. :)