Thread: speed change
View Single Post
  #2   Spotlight this post!  
Unread 24-01-2002, 17:24
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is online now
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,644
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
Faster != Possible

If you want to make the motor go faster, you are out of luck.

If you want to make it go slower, you just have to reduce the distance away from 127 to make the voltage to the motor less.

Code below (untested off the top of my head so it may have bugs, but I think it is good to go). Also, I have resigned myself to the fact that pbasic has a certain order of operations and that that order is not the order you and I normally use. Some folks use parenthesis to try to fix this problem. The intent is to make matters clear to the reader, but in fact, in the case of pbasic, they make matters UNCLEAR, so I use them as little as I can. I am much happier this way. You should try it. It is okay... ...really.

Pbasic Zen Master,

Joe J.



MotorPWM Var Byte
ScaleNum CON 4
ScaleDen CON 4
'Total scalefactor = ScaleNum / 2^ScaleDen
'Example above Scalefactor = 0.25 or 25%

'Set MotorPWM as usual

if MotorPWM < 127 ScaleReverse
ForwardScale:
MotorPWM = MotorPWM - 127 * ScaleNum >> ScaleDen + 127 MAX 254
goto ScaleDone
ScaleReverse:
MotorPWM = 127 - (127 - MotorPWM * ScaleNum >> ScaleDen MAX 127)
ScaleDone:

'continue coding...

'if you want to have an adustable "gas" you can replace ScaleNum with a variable (p1_wheel for example) Joe J