France
Asked — Edited
Resolved Resolved by Rich!

How To Gradually Increase And Lower The Value Of Pwm

Hello, I would like to gradually increase and lower the value of PWM. Does anyone know how to do? thank you


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

United Kingdom
#1  

You could script it quite easily.


$pwm_target = 100 # Set for target speed
$pwm_start = 0 # Set for start speed
PWM(D0,$pwm_start)

:loop
IF(GetPWM(D0) < $pwm_target)
  PWM(D0,$pwm_start)
  $pwm_start= $pwm_start + 5 # Change 5 to required amount for speed of increase
ELSE
  Halt() # PWM at required level, stop script.
ENDIF
Sleep(10) # Change sleep to suit speed.
GOTO(loop)

Apologies if the code is a bit messy and not explained too well I'm strapped for time but it should give an idea (hopefully)

#2  

Ok, I understand how the code works. Now it's clear. Thanks;)

PRO
Synthiam
#3  

Or you can servospeed() command. It applies to PWM as well

for example



ServoSpeed(d0, 4)

PWM(d0, 5)

Sleep(3000) 

PWM(d0, 90)


United Kingdom
#4  

Even I learn something new from time to time, I did not know ServoSpeed() applied to PWM too, that's much easier:)