When I first encountered PID, I struggled to understand how gains affect the system. Usually, I used to vary gains randomly, which never provided good results. If you have similar problems, this video is for you. After completing this video, you will understand PID gains better. You will be able to tune PID in a few steps. The code is available on: www.steppeschool.com/products/communities/steppeschool-miscellaneous www.patreon.com/user?u=80399744
I figured that diff gain also increases response speed to perturbations of the motor speed, so that it may be possible to reduce the P gain... In your demo, it seems that you are showing the response from an uncontrolled state to a controlled state, rather than response to a perturbation of the load? Or? But, I'm just some old guy, who never did learn the mathematics part, more of a "hands-on" and conceptual driver.... 😀
Nice! I am building a self balancing robot using a BO gear dc motor, l298n motor driver, arduino uno and mpu6050. I am stuck in a part. I dont know how to convert the output of the pid controller into pwm value of 0 to 255. It would be great if you could help me with this.
Hello, I personally do not use Arduino on my projects, but what you can do is scale the output of the PID to fit the PWM value range. For that, you can identify scale gain by dividing the maximum of the PWM range(in your case, 255) by the maximum value of the PID output (you have to identify it). Then, when the PWM duty cycle value is needed, you multiply this gain by the output of the PID to obtain the PWM duty cycle value.
@@steppeschool3629 thanks man for your reply. This is the main problem I am facing that how to find the maximum value of PID . I am not getting this on UA-cam or the internet.
As I showed here ua-cam.com/video/Ioa6haiVveE/v-deo.html You have to set a maximum value for the PID output and I-gain output. You can identify these values manually. Once you set them, defining the scale to get the PWM value will be straightforward.
I thought you had already tuned PID and are looking for how to scale the PID output to the PWM duty cycle value. In that case, start with P-gain. Slowly increase the P-gain, and manually tilt your robot(maybe 10-15 degrees). At some point, it should oscillate. You can use that value for setting the max PID value(maybe 3 times this value might be the max value). Then, you can tune other gains, as pointed out in the video. There are no standard rules. You can manually try different values to find the best value for your case.
When I first encountered PID, I struggled to understand how gains affect the system. Usually, I used to vary gains randomly, which never provided good results. If you have similar problems, this video is for you. After completing this video, you will understand PID gains better. You will be able to tune PID in a few steps.
The code is available on:
www.steppeschool.com/products/communities/steppeschool-miscellaneous
www.patreon.com/user?u=80399744
Great explanation!
I figured that diff gain also increases response speed to perturbations of the motor speed, so that it may be possible to reduce the P gain... In your demo, it seems that you are showing the response from an uncontrolled state to a controlled state, rather than response to a perturbation of the load? Or?
But, I'm just some old guy, who never did learn the mathematics part, more of a "hands-on" and conceptual driver.... 😀
Thanks for teaching. it was great. I would like to ask you a question, could you tell me how often do you run PID controller function?
Hi, I run every 1 ms. In other words, at 1 kHz frequency.
Thank you so much @@steppeschool3629
You teach very well.🌸 Please prepare a sample project for the MODBUS-RTU network.
Thanks a lot! Noted👌
Must enable SWV trace in the debugger settings first
Nice!
I am building a self balancing robot using a BO gear dc motor, l298n motor driver, arduino uno and mpu6050. I am stuck in a part. I dont know how to convert the output of the pid controller into pwm value of 0 to 255. It would be great if you could help me with this.
Hello,
I personally do not use Arduino on my projects, but what you can do is scale the output of the PID to fit the PWM value range. For that, you can identify scale gain by dividing the maximum of the PWM range(in your case, 255) by the maximum value of the PID output (you have to identify it). Then, when the PWM duty cycle value is needed, you multiply this gain by the output of the PID to obtain the PWM duty cycle value.
@@steppeschool3629 thanks man for your reply.
This is the main problem I am facing that how to find the maximum value of PID . I am not getting this on UA-cam or the internet.
As I showed here ua-cam.com/video/Ioa6haiVveE/v-deo.html
You have to set a maximum value for the PID output and I-gain output. You can identify these values manually. Once you set them, defining the scale to get the PWM value will be straightforward.
@@steppeschool3629 In the given video how did you find your max pid value?
I thought you had already tuned PID and are looking for how to scale the PID output to the PWM duty cycle value. In that case, start with P-gain. Slowly increase the P-gain, and manually tilt your robot(maybe 10-15 degrees). At some point, it should oscillate. You can use that value for setting the max PID value(maybe 3 times this value might be the max value). Then, you can tune other gains, as pointed out in the video.
There are no standard rules. You can manually try different values to find the best value for your case.
🙏🙏🙏