This topic has 2 replies, 2 voices, and was last updated 3 weeks, 4 days ago by Che Martin.

  • Author
    Posts
  • #8018
     Che Martin
    Participant

    Good Morning All,

    I have the Omni-wheel Vector robot and I am working on making it autonomous. I used the wheel speed in m/s to get a PID output. My question is how do I convert the PID output to a PWM for my Analogwrite command? My PWM range is -225, 255.

    Regards,
    Che

    #8019
     SuperDroid
    Keymaster

    The analogWrite() command takes values from 0 to 255. You need to take the absolute value (or magnitude) of your pid output, scale it to 0-255, and set the direction pin output for that motor high or low depending on the sign.

    #8115
     Che Martin
    Participant

    Good Morning,

    Thank you for your reply. I have been trying to do the scaling but the issue is that that PWM to Speed is not a fully linear relationship. For instance a PWM of 60, 80, 100, produces a wheel speed of .08, .12 and .16 m/s respectively but as I go higher example a PWM of 120,140 and 160, the respective speeds in m/s is .18, .19, 20. My calculation for the wheel speed from encoder ticks is ((current encoder reading – last encoder reading)/1990{ticks per rotation})* 2pi(wheel radius). Any idea on how to get map wheel speed to PWM given that its non-linear?

    Regards,
    Che

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Login Register

©2020 SDRobots.com | All rights reserved.

Log in with your credentials

or    

Forgot your details?

Create Account