Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Globe Motor (http://www.chiefdelphi.com/forums/showthread.php?t=17980)

Team168 15-02-2003 18:54

Globe Motor
 
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:

Code:


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. :)


All times are GMT -5. The time now is 06:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi