Tagged: Autonomous Omni-wheel PWM PID
This topic has 3 replies, 3 voices, and was last updated 2 years, 2 months ago by aayushkm52.
- AuthorPosts
- September 1, 2020 at 1:40 pm #8018Che MartinParticipant
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,
CheSeptember 1, 2020 at 4:31 pm #8019SuperDroidKeymasterThe 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 MartinParticipantGood 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,
CheSeptember 3, 2022 at 3:51 am #9519aayushkm52ParticipantIf your wheels have encoders, the usual approach is to use a PID loop to drive the wheels at the specific speed you want, rather than PWMing the motors. That way the PID will make the wheels turn at that speed on different surfaces and angles, and overcome the inertia when it is stopped. It’s smoother and more precise. The cmd_vel message says “I want this many m/s linear and this many rad/sec rotation” and the control node driving your motor converts those to wheel speeds and sends the desired wheel speeds as targets to the PID loop.
- AuthorPosts
You must be logged in to reply to this topic.