View Full Version : Output voltage in PBASIC

01-31-2002, 02:24 PM
How does the output voltage in PBASIC work?

I know 0-255 in PBASIC means a voltage from 0 to +5V, but how does the motor go backwards then? That'd require negative voltage...

From what I've seen, I think
127 means 0V
> 127V means forward
< 127V means backward

Is that right? If that's right, what provides more power? 0 or 126V?


hi neg power no power hi pos power


low neg pwr hi neg pwr no power low pos pwr hi pos power

Hope this wasn't too confusing :)



Joe Johnson
01-31-2002, 02:53 PM
The analog inputs have a 0-5V range (0-255).

The PWM outputs range from 0-254 (not 255! see other messages).

The Victors map 0 to -Vbatt, 127 to 0 V, and 254 to +Vbatt.

They have an H-bridge that puts the proper voltage to the motor leads.

Actually, they don't really have the ability to put 6V to the motor, they just put 12V to the motor for 50% of the time.

It is a very clever thing really, but for our purposes, you can imagine that you have a variable output voltage.

Hope this helps.

Joe J.

01-31-2002, 08:29 PM

01-31-2002, 09:01 PM
Dr. Joe,

What is exactly that thing you said, about providing 12V 50% of the time instead of 6V? How does it work?

Joe Johnson
01-31-2002, 09:32 PM
The problem is that high current transistors really don't like being half on. They are much happier being all the way on or all the way off (happier being defined in this case as cooler).

So... ...what is an engineer with a high current applciation to do? Well, as it turns out, transistors can be very fast at changing from on to off (and off to on). So... what they do is turn the full voltage on for only a percentage of the time.

Basically, if they want half the voltage, they turn the motor on for half the time. If they want 75% of the voltage, they turn the motor on for three fourths of the time. Assuming that the on/off frequency is fast compared to the reaction time of the motor, the current gets sort of averaged and the motor more or less behaves like it is driven continuously by the reduced voltage.

One way of thinking about it would be to have a hammer that could hit somthing with a force of 10 lbs. If you wanted to accelerate a 10 lbs block at .5g's I could hit the mass with 10 lbs for half the time. The mass would begin to acclerate with each hit. The mass of the block would smooth out the velocity (sort of, if I didn't look at it TOO closely) and assuming that my hit frequency was fast enough, I could pretend that I had a 5 lbs. hammer hitting the block continuously.

The mass is playing the role of the motor. The hammer is the voltage. The velocity is the current.

Don't know if this helped but I tried...

Joe J.

Ian W.
01-31-2002, 09:37 PM
I found the concept easy to understand. Basically, the motor gets full power for amount of time per cycle, and the inertia and momentum of the motor will make the motor keep spinning until the next chunk of full power is applied (like, nano-seconds after). That's how I visualized it, although I'm not sure how much help that is to anyone else, seeing as Joe defined it pretty well too. I guess my description is the "Super-Layman's-Terms" :D

01-31-2002, 09:49 PM
I think I got it, correct me if I'm wrong:

it's much more on/off/on/off (...) , with each on or off being a very small interval, than a very large on and an equally large off.


Thanks for your help,

Ian W.
01-31-2002, 09:50 PM
Exactly correct. :)