Hello I need to write code for a speed control but the speed control need to Accelerating and Decelerating at the same speed like stair one step at the time up end one step down at the time.
example: code (this work from 0 to 100% of Rc Radio)
gosub RcInput 'Read Rc Input
if (Throttle > ThrottleMin) and (Throttle < ThrottleMax) then
MotorSpeed = ((Throttle - ThrottleMin) * 100 / 83)
endif
if (CurrentStep < MotorSpeed) and (MotorSpeed < 101) Then
IF (CurrentStep * 2 < MotorSpeed) Then
CurrentStep = CurrentStep + 1
EndIF
IF (CurrentStep * 2 > MotorSpeed) Then
CurrentStep = CurrentStep - 1
EndIF
endif
if (CurrentStep > MotorSpeed) and (MotorSpeed >0) then
while (CurrentStep * 2 < MotorSpeed)
CurrentStep = CurrentStep + 1
wend
while (CurrentStep * 2 > MotorSpeed)
if (RPM => RunIdel) then CurrentStep = CurrentStep - 1
wend
endif
If (CurrentStepl < CurrentStep) And (CurrentStep < 101) Then
GoSub GetRPM
IF (RPM < MaxRPM) Then
while (CurrentStepl < CurrentStep)
CurrentStepl = CurrentStepl + 1
MotorDC = (50 / 100 * CurrentStepl + StartPoint)
Pause 100
wend
endif
EndIf
if (RPM >= RunIdel) Then
while (CurrentStepl > CurrentStep)
CurrentStepl = CurrentStepl - 1
MotorDC = (50 / 100 * CurrentStepl + StartPoint)
Pause 100
wend
endif
Bookmarks