Tagged: Autonomous Omni-wheel PWM PID
This topic has 2 replies, 2 voices, and was last updated 3 weeks, 4 days ago by Che Martin.
- AuthorPosts
- September 1, 2020 at 1:40 pm #8018
Che Martin
ParticipantGood 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,
CheSeptember 1, 2020 at 4:31 pm #8019SuperDroid
KeymasterThe 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.
November 26, 2020 at 10:04 am #8115Che Martin
ParticipantGood 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 - AuthorPosts
You must be logged in to reply to this topic.