Arduino PID Control System (Ball and Beam)

preview_player
Показать описание
This is a ball-and-beam control system I designed and 3D printed to learn about PID control.

I've posted the CAD and code for this project on my Github page here:

The control electronics consist of an Arduino Uno, a CNC shield, and a TMC2209 stepper motor driver. The TMC2209 motor driver allows the stepper motor to operate very quietly by interpolating step signals into 1/256 microstepping.

The distance sensor I used is an HC-SR04 ultrasonic distance sensor. This sensor typically provides rather noisy data, so I used a moving average to act as a low-pass filter and attenuate the high frequencies. I also added some simple outlier rejection to remove the occasional erroneous measurement.

I used a 12-bit AS5600 absolute magnetic encoder on the stepper motor to track the position of the motor. These sensors operate on the Hall effect and use I2C protocol to communicate with microcontrollers. I designed and printed a housing that attaches to the back of a NEMA-17 stepper motor and holds the encoder board in the correct location relative to the magnet. The encoder magnet is diametrically magnetized and is attached to the back of the motor shaft.

I originally planned to use a ping pong ball as the rolling element of the system, but the distance sensor was not able to reliably provide clean data. I think the reflected sound from the sphere was too small in this case. That's why I made the cart with a large acoustically reflective surface.

To set the PID target position, I mapped the output of a 10k potentiometer to the position along the beam.
Рекомендации по теме
Комментарии
Автор

A beautifully simple and effective demonstration of PID control, my congratulations from Italy

matt
Автор

I wish that my teacher had something like this to explain the working of PID controls. We have used just a book (which was by the way a great one), seeing the system in real life is much more interesting. Great work, maybe I will build one for myself.

robvanscheijndel
Автор

This is nicely designed, I was thinking of doing something similar.

One significant modification I was thinking about was replacing the ultrasonic sensor with something more reliable. What if instead of the wooden rails, you used metal rods instead, with a metal ball. Then measure the resistance across the rails. As long as the rails are electrically isolated (and it would appear they would be in your model), the ball would act as a potentiometer. Greater resistance = greater distance. It'd be interesting to see how that would work. It would also remove your friction issues.

RNGHatesM
Автор

I see a lot of these on Utube now. There must be an open source project somewhere because they all look the same. This isn't a difficult PID control project. It is just first order so has little chance of becoming unstable, no matter what you do. A more interesting PID demo I have seen is balancing a vertical pole, with the error signal coming from an angle sensor at the base.

williamogilvie
Автор

That's amazing to watch it, but we missed the sweet voice over!

tahirkamboh
Автор

inject a sine wave instead of the pot. Awesome work.

scottrasmus
Автор

Nice project, good work. Hope you enjoyed it continue to do more!

georgekerwood
Автор

Congratulations Great project.thank you for sharing so amazing PID controller

marializianichols
Автор

Amazing work. It will be awesome to have a wave machine on wheels on this

vineshgda
Автор

Hi, @ivprojects8143! Why did you need an encoder for this project? Was the stepper motor skipping steps and so you needed the AS5600 to compensate for that? Thanks in advance!

HenriqueFerrolho
Автор

Do you have this project documented somewhere for other people to replicate and learn? Open source? This is a good learning project for PID control.

charlessun
Автор

Could be used as a controller for hydrofoil wing. Looks like ultrasound distance is the 'set point' for the PID.

kurtdobson
Автор

Impressive! Can you tell which pid equation is implemented here, since there are quite a few of them for some reason like parallel form, etc. Do Ki and Kd terms have time related physical meaning in your code or are "just numbers" correctly chosen? Would like to see some educational material from you, thank you!

papanyanz
Автор

That's pretty cool! Are you an engineering student by chance?

gabedarrett
Автор

Which part of the motor drive should I connect HC-SR04 to?

I'm also curious about the details of the changing PID target position of with potentiometer knob

gloomyday
Автор

Cool and smooth 👍🏼 Built as a demo or is there a future use for it?

TheRealStructurer
Автор

Nice project, PID constants are not tuned optimally though - it oscillates around the target

DerClaudius
Автор

Congrats it is a great video, just a question, can i use another magnetic encoder?

yisusdeastora
Автор

I tried to build this project but didn't find a circuit diagram and used library. Specially HC_SR04 creates problems.

Singh_Malkiat
Автор

Awesome work. How long would you say you spent tuning this?

Rich
join shbcf.ru