Тёмный

COMPREHENSIVE: PID CONTROLLER for DC MOTOR with Timer Interrupts and Anti-windup 

GeeKee CeeBee
Подписаться 2,1 тыс.
Просмотров 92 тыс.
50% 1

Опубликовано:

 

21 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 74   
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
IMPORTANT: If you find this video helpful then please leave a LIKE, SHARE and SUBSCRIBE to support me in making more videos like this. 👍 CODE and SCHEMATICS ARE AVAILABLE HERE geekeeceebee.com/PID%20Controller.html More videos: DC Motor Position Control: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--P-6bMbQh1E.html
@adrianrawlings2470
@adrianrawlings2470 3 года назад
Best explanation and demonstration of PID I've seen to date. Thank you.
@user-to9pf7ec7s
@user-to9pf7ec7s 2 года назад
Great vid, thanks! However the Interrupt service routine for the encoder could be much more simple: use this on one Hall sensor's pin: attachInterrupt(digitalPinToInterrupt(pin), ISR, mode), and the 'mode' should be 'RISING' And to get the direction in the 'interrupt service routine', you only have to check whether the other Hall sensor's pin is HIGH or LOW at that moment.
@VPannagS
@VPannagS 4 года назад
That helps alot... PINS/PID/Time Interrupts/some basic rotational mechanics stuff...
@boostedbuiltgarage
@boostedbuiltgarage 3 года назад
Thanks for taking the time to put this together, nice work. (I'll have to watch this a few times to get up to speed haha)
@sanjelly8
@sanjelly8 2 года назад
This is one of the best explanation for PID, I wish in the future that you add explanations comments to your code, this will be very helpful for Arduino bigenners like me, thanks allot
@GeeKeeCeeBee
@GeeKeeCeeBee 2 года назад
Thank you. Im glad my videos are helping.
@forgedabstract7288
@forgedabstract7288 3 года назад
OMG this LIFESAVER video! I have literally the same components as you
@GregerOlofsson
@GregerOlofsson 3 года назад
Thanks, this is a great base for my lathe motor controller I've had on the back burner for quite some time.
@supersuperintendant
@supersuperintendant 3 года назад
Thanks for sharing your considerable skill with the world.
@juanramirezjardua2082
@juanramirezjardua2082 3 года назад
Thanks, great video, clear explanation. I'll use your code in my project for a ros driver for controlling 4 dc motors that received the cmd_vel command.
@classtimeoff
@classtimeoff 3 года назад
you got my like and subscribe. thank you for the project.
@jaisanrj
@jaisanrj 3 года назад
Thanks for the explanation and demonstration
@sebaschtl9710
@sebaschtl9710 3 года назад
Thank you for your very good explanation. And thank you for not using a librarys : ) use ≠ understand
@foltranm
@foltranm 4 года назад
great video, man! thanks!
@hamedshamsikhani3345
@hamedshamsikhani3345 Год назад
Hello sir. Thank you for sharing this really helpful. I test my motor and the results are different. But very unclear result I have.
@jorgeroa6591
@jorgeroa6591 4 года назад
Thank you brother, good shit
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
Code and Schematic are available here geekeeceebee.com/PID%20Controller.html
@br2245
@br2245 3 года назад
Thanks , great lecture🙏🙏🙏
@davidforrest937
@davidforrest937 2 месяца назад
@29:53 Why do you advise serial printing inside an interrupt? And @13:57 Why do you use 900 if you are counting the 4 edges of the two pulse trains A & B Most encoder PPR specifications are as the pulses on one channel, to be read as a clock+dir pair on one edge of a clock signal. Counting on all 4 edges is more complicated, but quadruples the resolution. If you're using the 80RPM motor with spec'd at 900PPR and reading all 4 edges, the divisor should be 3600 counts/rev. Using 900 instead of 3600, you are probably getting only 25RPM when you call for 100RPM. At 100RPM it should take 0.6 sec to do a revolution or 1.6 rev/sec, not 2.4sec/rev or 0.4rev/sec like at 31:26.
@nissan2060
@nissan2060 4 года назад
@GeeKee Ceebee first off great informative video overall; thank you! I am uncertain about some things you explained though...at 10:45 when you're checking the status of the encoder pins to determine clockwise or counterclockwise direction, you're saying check if pinB is high and pinA is low to constitute an upcount and every other case is downcount...it makes sense for the portions of the signals that are clearly pinB high and pinA low...but what about right after that condition when the controller sees pinB high and pinA high - it would downcount (undo the upcount it just did)? What if the motor is idle or stalling with either conditions of pinA, pinB both low or one being high the other being low or both being high?
@seanmcdonald656
@seanmcdonald656 3 года назад
Thanks for the great video
@HaiderAli-xr9nm
@HaiderAli-xr9nm 3 года назад
The video was really helpful. I have one query: I want to track Theta, how can I put the values of the desired theta in code, I mean in formula or in array form please describe with a short overview example?
@chickenz4604
@chickenz4604 4 года назад
Very good
@yu-chiwu484
@yu-chiwu484 3 года назад
what is the ppr for the encoder. Here rising and falling conditions for pinA and pinB are considered. Therefore, is EncoderCount counted 4 times per pulse of pinA and pinB? Does that mean 4*ppr=900?
@jaimemartinezdiaz1004
@jaimemartinezdiaz1004 4 года назад
Cool vid
@cheredha
@cheredha 3 года назад
Thank you
@gul156
@gul156 4 года назад
Can you explain the RPM_d formula @ 26:00? Why are you using 5ms (0.005) and 50ms (0.05)? For sure I'm missing something.
@thaitoaninh1430
@thaitoaninh1430 3 года назад
great work thank u so much
@lindsaydempsey5683
@lindsaydempsey5683 3 года назад
Excellent video thank you. I have an application where I'm trying to on control a bypass around a supercharger using a drive by wire throttle body. The controlled parameter is supercharger discharge pressure, which is limited by bypassing an increasing amount of air around the supercharger as engine speed increases. I presume that I can have one PID loop for the pressure control, and a second PID loop that positions the throttle plate to the commanded position via PWM (throttle plate position feedback is via a potentiometer). I presume that is easily accomplished in the Arduino environment. Do you have any comments or helpful hints on that approach?
@kifahzaidan4505
@kifahzaidan4505 2 года назад
THANKS A LOT CAN YOU PLEASE POST VIDEO FOR THE (CONTROLLING OF DC MOTOR 'ACTUATOR ' PROGRAMABLE POSITION WITH MEMORY BUTTONS USING ARDUINO. BEST WISHES
@itsJeewantha
@itsJeewantha 3 года назад
Hi GeeKee, I'm going to use this with BLDC motor, Can I use the same or What I need to change? Great video btw.
@IchrisiI
@IchrisiI 3 года назад
awesome !!
@praveendhiman16
@praveendhiman16 2 года назад
Hi Can you please make video for torque and position control of dc motor
@GeeKeeCeeBee
@GeeKeeCeeBee 2 года назад
There's a position control video on my channel. Im planning on making a video on cascading loop controller for Torque, speed and position in the future
@marcelodossantoscoutinho4955
@marcelodossantoscoutinho4955 3 года назад
Do you think is it possible to model the motor mathematically? I mean, doing a open loop test for example? Then , it is possible to design the PID controller accordingly to the system control theory.
@GeeKeeCeeBee
@GeeKeeCeeBee 3 года назад
Absolutely! However, you would need several motor parameters such as Torque constant, inductance of the winding, friction, torque speed curve, etc to model the motor. I believe these can be obtain experimentally aswell. Using the state space representation, modelling the whole system with PID is fairly easy.
@chaitanyapatil7513
@chaitanyapatil7513 Месяц назад
hey did you make a hardware model of this?
@hashirwaqar6892
@hashirwaqar6892 Год назад
at 14:32 u said that 900 is the count/revolution, right? How did u get that value I'm a bit confused? Amazing video btw, thanks a lot!!
@Happymacer_P
@Happymacer_P 7 месяцев назад
Hiya I believe he is using a 900 counts per evolution encoder - ie it is made to cause 900 pulses on its output in one revolution. Number is supplied by the manufacturer.
@davidforrest937
@davidforrest937 2 месяца назад
I think he's using an "Encoder Metal Gearmotor 12V DC 80 RPM Gear Motor with Encoder for Arduino and 3D Printers" motor specified with 900PPR, but is counting 4 edges/pulse so is actually getting 3600 counts/rev.
@FilmRiggers
@FilmRiggers 3 года назад
You briefly touched on controlling position instead of speed at 33min. Please can you elaborate a bit more, I didn't quite understand
@GeeKeeCeeBee
@GeeKeeCeeBee 3 года назад
You would need to create a desired Theta ( desired angular position) trajectory. And the motor will basically track this desired trajectory. So the error becomes Theta desired minus Theta actual( motor angular position). Note that angular position could be in deg or radians, so proceed accordingly. Error = Theta_d - Theta After that tweak the gain values as needed. PI controller should be sufficient. Hope this is helpful :)
@fatimakaimous4926
@fatimakaimous4926 3 года назад
hi sir i want to ask u , how u found kp , ki and kd ? can u give me just the idea and thank u for the project
@sergeihanna8383
@sergeihanna8383 3 года назад
can I control both velocity and angle in the same time?
@bluebrim127
@bluebrim127 3 года назад
How can I choose an RPM - say I want to run my motor anywhere from 0-10 RPM and I'd like to choose a single RPM or vary that RPM over time. Where in the code can I adjust that
@abhishekbedake2669
@abhishekbedake2669 3 года назад
Where ur testing the pulse, which software...?
@user-to9pf7ec7s
@user-to9pf7ec7s 2 года назад
Great vid, I've a question: Whati is the benefit of usint the "time interrupt" instead of telling the program to enter into the PID loop when >50ms elpased from previous entry??? Thanks!
@GeeKeeCeeBee
@GeeKeeCeeBee 2 года назад
Advantage of timer interrupt is that Arduino is free to do other things while waiting for 50ms. Unlike in delay(50) command, arduino is stuck for 50ms
@user-to9pf7ec7s
@user-to9pf7ec7s 2 года назад
@@GeeKeeCeeBee I'm not talking about delay(50). But sg like this: if millis() > (PreviousLoopEntryTime + 50){ PreviousLoopEntryTime = millis() Preform the remaining of the loop }
@GeeKeeCeeBee
@GeeKeeCeeBee 2 года назад
I have not tried that logic but I don't see issues with your code. Also, millis() is based on Timer0 which is pre-configured to count clock pulses every 1ms. Either approach is fine imo.
@pulimisaireddy
@pulimisaireddy 4 года назад
can please help me to run the motor linearly not in the sine wave.
@MasonJarBoy
@MasonJarBoy 4 года назад
I am trying to control a DC motor using the writeMicroseconds as opposed to having a straight voltage put into like your motor driver function. Do you think this is viable?
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
I dont see an issue if you're simply trying to run the DC motor, however, if you're trying to implement tracking control on DC motor then it'll probably wont work. Reason is that the encoder and DC motor have to run on the same Timer clock. I believe writemicroseconds use a different clock which wont allow event synchronization. Hope that helps.
@marcelodossantoscoutinho4955
@marcelodossantoscoutinho4955 3 года назад
Hey sorry for asking, but are you sure the schematic is correct? After I removed the enable jump, the motor doesnt even start.
@GeeKeeCeeBee
@GeeKeeCeeBee 3 года назад
I pretty sure the schematic is correct. If you leave jumper in then motor should run at full speed (at max supply voltage). In your case, as jumper is removed I would suggest to check your PWM pin and value that your sending. If PWM value is zero then there's no voltage going to the motor.
@GennaroScarati
@GennaroScarati 4 года назад
My RPMs are wrong! Where does that 900 come from? How can I fix this problem? On my encoder I can read it gives 11 signals when rotating one circle. Thanks so much for helping me!
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
Mybad, I missed this topic in the video. Theta = EncoderCount/ CountPerRevolution. In my case, 900 comes from the combination of Encoder's count per revolution (CPR) and motor gear ratio. CPR may be different depending on your motor and encoder specifications. Check your gear ratio, if any, and Encoder CPR. Hope this helps.
@usmanriasat9834
@usmanriasat9834 3 года назад
@@GeeKeeCeeBee hi if my motor has 11 pulse per revolution (ppr) and gear reduction ratio is 1:34.02 how many counts per revolution (cpr) do i have?
@davidforrest937
@davidforrest937 2 месяца назад
@@usmanriasat9834 11 * 34.02 = 374 pulse per revolution, but since he's counting 4 edges per pulse, it is 11*34.02*4 = 1496 counts/rev.
@gabrielcucu9361
@gabrielcucu9361 2 года назад
what the pins would be for arduino nano ?
@David_94
@David_94 4 года назад
the timer interrupt is used to control the sampling interval?
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
Yes, that's correct
@marcelodossantoscoutinho4955
@marcelodossantoscoutinho4955 3 года назад
Where did you buy the motor and motor driver? Thanks
@GeeKeeCeeBee
@GeeKeeCeeBee 3 года назад
Everything was purchased from Amazon.com
@ashkanrezaveisi4600
@ashkanrezaveisi4600 4 года назад
Could you please put the circle photo in your channle Thankyou very much
@kionmahuermicio9860
@kionmahuermicio9860 3 года назад
Like por no usar la librería PID que te hace toda la chamba.
@AhmedTarek-si9hy
@AhmedTarek-si9hy 4 года назад
can you send me the code
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
Just added. See description
@ahmedgamal-uh6ik
@ahmedgamal-uh6ik 4 года назад
source code plz
@GeeKeeCeeBee
@GeeKeeCeeBee 4 года назад
Just added. See description
@sweetali4578
@sweetali4578 3 года назад
how to contact you
@NedSar85
@NedSar85 3 года назад
Hi, does anyone have a compilation error in the cli() function? it says to me that TCCR1A was not declared...
@NedSar85
@NedSar85 3 года назад
solved! was using another type or arduino... this works in arduino uno
Далее
DC motor PID speed control
15:29
Просмотров 235 тыс.
O’zim bilib ketvotudima😅
01:00
Просмотров 609 тыс.
How to split your drink
00:45
Просмотров 1,1 млн
Turn any DC Motor into a Servo Motor
25:24
Просмотров 288 тыс.
Arduino PID Controller - From Scratch!
29:51
Просмотров 55 тыс.
DC motor position control using PID
43:23
Просмотров 77 тыс.
PID Balance+Ball | full explanation & tuning
13:13
Просмотров 744 тыс.
How to control multiple  DC motors with encoders
9:19
Hardware Demo of a Digital PID Controller
2:58
Просмотров 988 тыс.
O’zim bilib ketvotudima😅
01:00
Просмотров 609 тыс.