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: kzbin.info/www/bejne/Y4GQZ5WDl7abZ6c
@adrianrawlings24703 жыл бұрын
Best explanation and demonstration of PID I've seen to date. Thank you.
@GeeKeeCeeBee4 жыл бұрын
Code and Schematic are available here geekeeceebee.com/PID%20Controller.html
@user-to9pf7ec7s3 жыл бұрын
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.
@boostedbuiltgarage3 жыл бұрын
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)
@sanjelly82 жыл бұрын
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
@GeeKeeCeeBee2 жыл бұрын
Thank you. Im glad my videos are helping.
@VPannagS4 жыл бұрын
That helps alot... PINS/PID/Time Interrupts/some basic rotational mechanics stuff...
@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.
@supersuperintendant3 жыл бұрын
Thanks for sharing your considerable skill with the world.
@GregerOlofsson3 жыл бұрын
Thanks, this is a great base for my lathe motor controller I've had on the back burner for quite some time.
@forgedabstract72884 жыл бұрын
OMG this LIFESAVER video! I have literally the same components as you
@juanramirezjardua20824 жыл бұрын
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.
@HaiderAli-xr9nm3 жыл бұрын
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?
@sebaschtl97103 жыл бұрын
Thank you for your very good explanation. And thank you for not using a librarys : ) use ≠ understand
@nissan20604 жыл бұрын
@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?
@classtimeoff4 жыл бұрын
you got my like and subscribe. thank you for the project.
@jaisanrj3 жыл бұрын
Thanks for the explanation and demonstration
@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_P8 ай бұрын
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.
@davidforrest9374 ай бұрын
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.
@yu-chiwu4843 жыл бұрын
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?
@lindsaydempsey56833 жыл бұрын
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?
@gul1564 жыл бұрын
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.
@seanmcdonald6563 жыл бұрын
Thanks for the great video
@foltranm4 жыл бұрын
great video, man! thanks!
@praveendhiman162 жыл бұрын
Hi Can you please make video for torque and position control of dc motor
@GeeKeeCeeBee2 жыл бұрын
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
@itsJeewantha3 жыл бұрын
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.
@br22453 жыл бұрын
Thanks , great lecture🙏🙏🙏
@chickenz46044 жыл бұрын
Very good
@cheredha3 жыл бұрын
Thank you
@user-to9pf7ec7s3 жыл бұрын
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!
@GeeKeeCeeBee3 жыл бұрын
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-to9pf7ec7s3 жыл бұрын
@@GeeKeeCeeBee I'm not talking about delay(50). But sg like this: if millis() > (PreviousLoopEntryTime + 50){ PreviousLoopEntryTime = millis() Preform the remaining of the loop }
@GeeKeeCeeBee3 жыл бұрын
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.
@kifahzaidan45052 жыл бұрын
THANKS A LOT CAN YOU PLEASE POST VIDEO FOR THE (CONTROLLING OF DC MOTOR 'ACTUATOR ' PROGRAMABLE POSITION WITH MEMORY BUTTONS USING ARDUINO. BEST WISHES
@davidforrest9374 ай бұрын
@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.
@jorgeroa65914 жыл бұрын
Thank you brother, good shit
@IchrisiI3 жыл бұрын
awesome !!
@marcelodossantoscoutinho49553 жыл бұрын
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.
@GeeKeeCeeBee3 жыл бұрын
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.
@chaitanyapatil75132 ай бұрын
hey did you make a hardware model of this?
@abhishekbedake26693 жыл бұрын
Where ur testing the pulse, which software...?
@fatimakaimous49263 жыл бұрын
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
@jaimemartinezdiaz10044 жыл бұрын
Cool vid
@thaitoaninh14303 жыл бұрын
great work thank u so much
@bluebrim1273 жыл бұрын
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
@sergeihanna83834 жыл бұрын
can I control both velocity and angle in the same time?
@FilmRiggers4 жыл бұрын
You briefly touched on controlling position instead of speed at 33min. Please can you elaborate a bit more, I didn't quite understand
@GeeKeeCeeBee4 жыл бұрын
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 :)
@GennaroScarati4 жыл бұрын
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!
@GeeKeeCeeBee4 жыл бұрын
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.
@usmanriasat98343 жыл бұрын
@@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?
@davidforrest9374 ай бұрын
@@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.
@gabrielcucu93612 жыл бұрын
what the pins would be for arduino nano ?
@marcelodossantoscoutinho49553 жыл бұрын
Where did you buy the motor and motor driver? Thanks
@GeeKeeCeeBee3 жыл бұрын
Everything was purchased from Amazon.com
@MasonJarBoy4 жыл бұрын
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?
@GeeKeeCeeBee4 жыл бұрын
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.
@marcelodossantoscoutinho49553 жыл бұрын
Hey sorry for asking, but are you sure the schematic is correct? After I removed the enable jump, the motor doesnt even start.
@GeeKeeCeeBee3 жыл бұрын
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.
@pulimisaireddy4 жыл бұрын
can please help me to run the motor linearly not in the sine wave.
@David_944 жыл бұрын
the timer interrupt is used to control the sampling interval?
@GeeKeeCeeBee4 жыл бұрын
Yes, that's correct
@ashkanrezaveisi46004 жыл бұрын
Could you please put the circle photo in your channle Thankyou very much
@sweetali45783 жыл бұрын
how to contact you
@kionmahuermicio98603 жыл бұрын
Like por no usar la librería PID que te hace toda la chamba.
@AhmedTarek-si9hy4 жыл бұрын
can you send me the code
@GeeKeeCeeBee4 жыл бұрын
Just added. See description
@ahmedgamal-uh6ik4 жыл бұрын
source code plz
@GeeKeeCeeBee4 жыл бұрын
Just added. See description
@NedSar853 жыл бұрын
Hi, does anyone have a compilation error in the cli() function? it says to me that TCCR1A was not declared...
@NedSar853 жыл бұрын
solved! was using another type or arduino... this works in arduino uno
@vilsondasrapadura734227 күн бұрын
@@NedSar85 oh them im screwed, what type of arduino where you using? im using a esp 12e and i have the same error