Sign up at ELECTRONOOBS.io: electronoobs.io/ Follow me on FACEBOOK for more: facebook.com/Electronoobs help me on Patreon: www.patreon.com/ELECTRONOOBS
Hey man, your code looks like the I and D terms are 0, because you're converting/truncating a double to integer. From your site: int kp = 2, ki = 0.01, kd = 0.02;
4 роки тому
MUY BUEN VIDEO AMIGO... PUEDEN VER LA MIA ua-cam.com/video/VQamz6D0LwY/v-deo.html ///// ua-cam.com/video/0OEZiJNIVvw/v-deo.html
A better solution for controling brushed motors with PID is using PD + minimum value. DC motors tend to stall at low pwm values because of the friction and cogging of the motor. You set your pwm frecuency and measure the minimum pwm value you need for the motor to just start moving. Take note of the value you need so that its just before that. Then just set the P and D values accordingly and that will give you a much more responsive and linear system as you dont have I lag and will even easily do really low speeds without stalling (if it stalls, raise your minimum value) your final values shoud me [0, - 255] and the corresponding negative values. Be sure to add the case for 0 so that if wont keep it at when 0
Old industrial drives used tacho with encoders, so the tacho allowed precise control of speed and the encoder allowed the position precision. There is old school machines with incredible precision, with DC servo motors with permanent magnets as field.
Oooh, will definitely try that. I just finished my implementation of a PID control software, and hacked an RC servo tro try it out with. PI works wonderfully with a PC fan, but PID gave me a heck of a lot of trouble with the servo. Especially a D over 1.0 ist making everything just shake and rattle, by generally amplifying the sensor noise
@@nrdesign1991 PID doesnt work for everything, first you need to understand the system you are working with, in other words its response curve. PID assumes a linear system but friction and other physics things cause things not to be linear at all. I dont think this would apply to an rc servo as it has its own pid inside, this is mainly for motors being controled with pwn with a mosfet. As motors are inductive loads, the higher the frequency the more exponential the response so that why the minimum value, to ofset the pid to the point where the friction, cogging and exponential response stop stalling the motor. PC fans are capasitive most of the times, they usually have a capasitor at the input to filter the noise generated by the switching. You should try either making a linear aproximation or an exponential curve (pass the output of the pid to a exponential function and use the function to set the pwm) Also as with with inductive loads, lowering the frequency reduces the reactance, so the lower the frequency the more lineal the response will be, for both inductive or capasitive loads. The only downside of lowering the frequency is coil whine or vibrations, but that depends on the motor or whatever you are powering so give it a try.
@@laharl2k 1) I hacked the servo so I'm left with the H bridge, motor and potentiometer for my own control (also the gears, naturally). I've already implemented the minimum PWM, but havent had good results yet (either too shaky control, or creep). Some of it is to blame on mechanical play of the gears, too. 2) the PC fan is a model with tach output and PWM input, so the only "capacity" is the kinetic energy of the spinning fan. It runs extremely well and comes up to the desired speed when tuned properly, even under load.
@@nrdesign1991 1) i would check the original controller's frequency and duty cycle as a reference and also check whether it had hysteresis or not. I guess they should to avoid oscilation. My guess if your fequency is too high, try something like 50-500hz 2) yeah but i bet you cant go below 20% duty cycle. I thought you were doing pwm to the power line. PWM pc fans usually follow the intel standard which says that fans should turn off below 20%. Not that it would matter a lot for a fan but if you want anything below you will have to switch the power directly, i dont think the circuitry has any problem with that, mostly for compatibility with older motherboards.
absolutely a great educational video. I've built some thing similar to this board but I use it to raise and lower my radio control plane's flaps. I did that just because I enjoy using micro controllers such as audrino. Please keep up the good work.
Btw - homing. You can measure the encoder output correlation to amount of PID output. I've made a routine which is activated if PID output is full (e.g. +127 or -127) and measures time since last encoder change. If it does not change for the specified time, the motor hit a "wall" (virtual endstop). Then I would move the axes into the opposing side and measure the number of steps taken - again employing the routine to verify if I've hit the wall. Like that you can get: a) sensorless homing b) information about the full axes range (real data, not calculated) c) verify, if the expected length is really available or your carriage has some problems Needs just a few lines of code and works like a charm ;)
such a great project. If only there were more hours in the day it would be so much fun to do something similar. I have so many ½ finished projects laying around just waiting for the time to get to them...I need to stop watching your videos as they are always so creative I want to add another one to list of things to try.
Esse é um dos vídeos mais esperados por mim pena não ter em espanhol, espero muito ver logo a CNC pronta com todos os eixos e uma versão em espanhol, patreon e like, like sempre, ótimo vídeo, like.
Nice video. Animations are just awsome. Just one question. How could you design an H-brigde using high-power MOSFETs for a huge current-consuming motor?
In theory, it should be possible to (very roughly) count the rotations of a brushed DC motor by monitoring the current going through it. Granularity would depend on the number of magnetic poles, but a computer could interpolate values in between to get a fairly-accurate position. Three points define a curve...
Actually, with trinamic stepper controllers you can detect lost steps and home the cnc and keep working, it’s not the best but it does the job. The prusa i3 has this feature
if the reason not using stepper because of "prices". ive been through this dc motor need gear for hold torque, need separate mcu to monitor the encoder in high speed, surely wearout in long use. short answer is, if the reason is price there is lot of used/second hand stepper that way cheaper than brushed with encoder and gearbox
Is there an off the shelf equivalent to the stepper controller for using a large DC or AC motor with an encoder, and if necessary a electromagnetic brake? I mean a complete boxed controller, like the ones available for Steppers in CNC kits. Connect motor, power supply and and connect dir pulse enable to the breakout. I have several large 1 to 3hp motors that come with pre attached encoders and gear box, in either DC or 3 phase.AC . I'm thinking about making a large format cnc table, and to use one of these guys for a 12 foot long Y axis. I have all the rail and timing belt stuff needed to go with this, from a automation project a friend built years ago with ISA card automation hardware. It seems someone ought to make a modern controller that could drop in next to the typical stepper controllers that all talk to a breakout board and standard software and save the trouble of doing special circuits and coding
How do fast machines step 1 step at a time when their encoders define the step size? Do they just go full on, then wait for an encoder pulse, then turn off? What about inertia? (I'm currently making a 3d printer and looking for ideas.)
Hello! That's great video. May I give you idea for next video? It will be nice to see PWM DC motor speed control with PID regulator. WIth soft start, stuck rotor protection, current protection function and etc.
hi. i love your projects. and the way you do your code. make good explanations so that in experienced like me can follow. my question. how do i change from dc motor to stepper to make it closed loop drive. and how do i use encoder for position rather than a pot. i want to use this to drive the lead screw on my metal lathe. will be very great full if you can help and explain how the code change.
My question, would it not be possible to caunt steps and direction simply by reading what direction H bridge is switched to, and how many steps are taken?
hi nice video, maybe later you can milling with your CNC prototype and this motor system the problem is the G code interface for vectors of images, thanks for share
can you please help me figure out how to change the steps in the code so it doesn't go as far when turning the pot? thank you for any help you can give
Hi whats up? i was woundering about how microcontroler(arduino ) undrestand g-code which sent to it from pc . For example when i press the top arrow of my keybord in computer it goes one step toward and vice versa.
Hi Electronoob, we are just starting now a Clay 3D printer project, I run the FabLab TU and I want the students to have access to diy printers and we’ll build them ourselves. Ideally I would like to use these encoded dc motors but i’m struggling to understand how to integrate them with Marlin and with the signals sent by , Let’s say, Ramps 1.4 (or a Treetech 32bits board) This project is going to be open source. Could you help us?
Wouldn't replacing the pot in a hobby servo with a linear potentiometer achieve more or less the same thing, but with greater accuracy? Or perhaps an LVDT?
you'd have to not only change the potentiometer to a rotary encoder but also make the drive circuit changed to be continuous rotation modded and you'd have to remove the cog that prevents continuous rotation. You also are forced to use PWM so lose control of the switching speed of the individual mosfets so you lost speed control fine tuning and power control fine tuning.
How did you program the arduino, so that it can read the optical sensor and watching at the same time the endstop? Would be interest cause multitasking is, i think, not possible with the arduino.
As usual, excellent. A question : when reversing direction is backlash (the slack in the gears) an issue for accuracy on this? It could be allowed for in coding though.
@@XTronical Yes, if there is a gearbox, you are right. And those encoders, seems to me, they have few pulses per revolution. However, mine was and is only a theorical speech. But let's suppose the screw pitch is 4 mm and the encoder has 32 sectors. If we consider both fronts, rising and falling, pulses become 64. 4/64=0,0625 mm if I am not wrong. (And if the encoder has a qudrature output, giving two signals, it is possible to multiply pulses by four.) For that kind of machine and if we consider torsions, low rigidity etc. in my opinion, is not bad.
Hi Andrei, I have learnt a lot from your videos. I need your suggestion. As I am an Instrumentation Engineer I was able to make one IoT product which I want to put in Market as a product and star selling it. So, I want to know can can I rely on Wemos Esp8266 boards or there any high quality and high performance esp8266 boards that I need to use for making that IoT products and selling to customers. Kindly reply in this regard. My best wishes for you always.
Depends on how they are manufactured. Cheap ones sometimes have directional brushes that will permanently damage the motor if reversed. Some brushes just wear in one direction, so don't like reversals after that. Some have well designed brushes that work well in either direction and don't wear abnormally from a dominant direction.
Sir could you make a complete tutorial on how can we make a close loop cnc like this one because. I've tried using 3 different Arduino for 3 axis but if one axis is stopped the other 2 continue to make which completely distroy the design
they have a built in potentiometer that can only turn a few times which is different from a rotational encoder which can turn infinite times. So you would have to change things
it's not working, i tried this...when i rotate the pot it starts rotating and when i rotate it a bit more it stops and if it starts again after rotating further, when i press the limit switch the motor still runs
Удержания позиции? Я как раз сейчас строю ЧПУ станок с DC моторами: когда мотор в уже заданной позиции, то он в режиме "торможения", если он вдруг сдвинется, то мы это увидим и вернём в ранее заданную позицию. Но это маловероятно из-за использования редукторов в таких моторах.
Sign up at ELECTRONOOBS.io: electronoobs.io/
Follow me on FACEBOOK for more: facebook.com/Electronoobs
help me on Patreon: www.patreon.com/ELECTRONOOBS
more of this type of project please
Hey man, your code looks like the I and D terms are 0, because you're converting/truncating a double to integer. From your site:
int kp = 2, ki = 0.01, kd = 0.02;
MUY BUEN VIDEO AMIGO...
PUEDEN VER LA MIA ua-cam.com/video/VQamz6D0LwY/v-deo.html ///// ua-cam.com/video/0OEZiJNIVvw/v-deo.html
A better solution for controling brushed motors with PID is using PD + minimum value. DC motors tend to stall at low pwm values because of the friction and cogging of the motor. You set your pwm frecuency and measure the minimum pwm value you need for the motor to just start moving. Take note of the value you need so that its just before that. Then just set the P and D values accordingly and that will give you a much more responsive and linear system as you dont have I lag and will even easily do really low speeds without stalling (if it stalls, raise your minimum value)
your final values shoud me [0, - 255] and the corresponding negative values. Be sure to add the case for 0 so that if wont keep it at when 0
Old industrial drives used tacho with encoders, so the tacho allowed precise control of speed and the encoder allowed the position precision.
There is old school machines with incredible precision, with DC servo motors with permanent magnets as field.
Oooh, will definitely try that. I just finished my implementation of a PID control software, and hacked an RC servo tro try it out with. PI works wonderfully with a PC fan, but PID gave me a heck of a lot of trouble with the servo. Especially a D over 1.0 ist making everything just shake and rattle, by generally amplifying the sensor noise
@@nrdesign1991
PID doesnt work for everything, first you need to understand the system you are working with, in other words its response curve. PID assumes a linear system but friction and other physics things cause things not to be linear at all.
I dont think this would apply to an rc servo as it has its own pid inside, this is mainly for motors being controled with pwn with a mosfet. As motors are inductive loads, the higher the frequency the more exponential the response so that why the minimum value, to ofset the pid to the point where the friction, cogging and exponential response stop stalling the motor.
PC fans are capasitive most of the times, they usually have a capasitor at the input to filter the noise generated by the switching.
You should try either making a linear aproximation or an exponential curve (pass the output of the pid to a exponential function and use the function to set the pwm)
Also as with with inductive loads, lowering the frequency reduces the reactance, so the lower the frequency the more lineal the response will be, for both inductive or capasitive loads.
The only downside of lowering the frequency is coil whine or vibrations, but that depends on the motor or whatever you are powering so give it a try.
@@laharl2k 1) I hacked the servo so I'm left with the H bridge, motor and potentiometer for my own control (also the gears, naturally). I've already implemented the minimum PWM, but havent had good results yet (either too shaky control, or creep). Some of it is to blame on mechanical play of the gears, too.
2) the PC fan is a model with tach output and PWM input, so the only "capacity" is the kinetic energy of the spinning fan. It runs extremely well and comes up to the desired speed when tuned properly, even under load.
@@nrdesign1991
1) i would check the original controller's frequency and duty cycle as a reference and also check whether it had hysteresis or not. I guess they should to avoid oscilation.
My guess if your fequency is too high, try something like 50-500hz
2) yeah but i bet you cant go below 20% duty cycle. I thought you were doing pwm to the power line. PWM pc fans usually follow the intel standard which says that fans should turn off below 20%.
Not that it would matter a lot for a fan but if you want anything below you will have to switch the power directly, i dont think the circuitry has any problem with that, mostly for compatibility with older motherboards.
I think there may be competition between electronoobs and great Scott 😂😂😂😂
Give Homofaciens a try. He made an extensive series about servos, positional encoding and closed-loop control
Or may b collaboration
@@nrdesign1991 Also
DroneBot Workshop
He is realy the largest Teacher in such Branches since the birth of the Arduino board !
There is no competition. Electronoobs is far far better than Great Scott!
you always make quality content. Thanks for all deep detail of the project. You do proper study before making a single video.
Thanks keep it up
absolutely a great educational video. I've built some thing similar to this board but I use it to raise and lower my radio control plane's flaps. I did that just because I enjoy using micro controllers such as audrino. Please keep up the good work.
Pretty interesting project, dude! Really well done! 😃
Este foi o único código para arduino que funcionou perfeitamente no meu motor com encoder, parabéns!
Awesome, amazing...
Well explained
Your tutorials are easily understandable.
Btw - homing. You can measure the encoder output correlation to amount of PID output. I've made a routine which is activated if PID output is full (e.g. +127 or -127) and measures time since last encoder change. If it does not change for the specified time, the motor hit a "wall" (virtual endstop). Then I would move the axes into the opposing side and measure the number of steps taken - again employing the routine to verify if I've hit the wall. Like that you can get:
a) sensorless homing
b) information about the full axes range (real data, not calculated)
c) verify, if the expected length is really available or your carriage has some problems
Needs just a few lines of code and works like a charm ;)
Thanks for the tips. Do you share your code somewhere? Have a good day!
@@ELECTRONOOBS I think it's still available on misan's github, let me check...
@@ELECTRONOOBS It's part of the attiny85 part in github.com/sanchosk/dcservo, derived from github.com/misan/dcservo
I Can't ignore your video...so interesting nd knowledgeable 👍
Your videos are so fascinating to watch 😊 everytime i learn something interesting! Thank you for that and keep up the good work man! Love your videos
such a great project. If only there were more hours in the day it would be so much fun to do something similar. I have so many ½ finished projects laying around just waiting for the time to get to them...I need to stop watching your videos as they are always so creative I want to add another one to list of things to try.
Esse é um dos vídeos mais esperados por mim pena não ter em espanhol, espero muito ver logo a CNC pronta com todos os eixos e uma versão em espanhol, patreon e like, like sempre, ótimo vídeo, like.
If your interpolator has rotational velocity output, you could use some feed forward to eliminate some of the lag.
You are my GOD! Thanks for the effort and teaching!
awesome ,thanks for the awesome video,maybe in the future we can see some more of that code and acceleration and precise control of pid?
very complex but well explained video, nice job
Excellent project 👍
Nice control. It's sort of a power steering circuit. Could this be made to use "STEP" and "DIRECTION" like a commercial controller instead of the pot?
Nice video. Animations are just awsome. Just one question. How could you design an H-brigde using high-power MOSFETs for a huge current-consuming motor?
In theory, it should be possible to (very roughly) count the rotations of a brushed DC motor by monitoring the current going through it. Granularity would depend on the number of magnetic poles, but a computer could interpolate values in between to get a fairly-accurate position. Three points define a curve...
oh man, I hope to see that CNC from you a long time ago. Any chances that you might finish it?
what about using a proximity sensor on the CNC head for example, any idea if that has drawbacks/advantages?
Actually, with trinamic stepper controllers you can detect lost steps and home the cnc and keep working, it’s not the best but it does the job. The prusa i3 has this feature
if the reason not using stepper because of "prices". ive been through this dc motor need gear for hold torque, need separate mcu to monitor the encoder in high speed, surely wearout in long use.
short answer is, if the reason is price there is lot of used/second hand stepper that way cheaper than brushed with encoder and gearbox
Is there an off the shelf equivalent to the stepper controller for using a large DC or AC motor with an encoder, and if necessary a electromagnetic brake?
I mean a complete boxed controller, like the ones available for Steppers in CNC kits. Connect motor, power supply and and connect dir pulse enable to the breakout.
I have several large 1 to 3hp motors that come with pre attached encoders and gear box, in either DC or 3 phase.AC . I'm thinking about making a large format cnc table, and to use one of these guys for a 12 foot long Y axis. I have all the rail and timing belt stuff needed to go with this, from a automation project a friend built years ago with ISA card automation hardware. It seems someone ought to make a modern controller that could drop in next to the typical stepper controllers that all talk to a breakout board and standard software and save the trouble of doing special circuits and coding
Great video as always 😘😍😘
How do fast machines step 1 step at a time when their encoders define the step size? Do they just go full on, then wait for an encoder pulse, then turn off? What about inertia?
(I'm currently making a 3d printer and looking for ideas.)
Sir can you please make a complete tutorial on controlling 3axis using g
-code and pid system please
You are doing great work
Very nice as always
Hello!
That's great video. May I give you idea for next video? It will be nice to see PWM DC motor speed control with PID regulator. WIth soft start, stuck rotor protection, current protection function and etc.
hi. i love your projects. and the way you do your code. make good explanations so that in experienced like me can follow. my question. how do i change from dc motor to stepper to make it closed loop drive. and how do i use encoder for position rather than a pot. i want to use this to drive the lead screw on my metal lathe. will be very great full if you can help and explain how the code change.
Another great video✌️
Super amazing video bro 😀👍👍
My question, would it not be possible to caunt steps and direction simply by reading what direction H bridge is switched to, and how many steps are taken?
hi nice video, maybe later you can milling with your CNC prototype and this motor system the problem is the G code interface for vectors of images, thanks for share
can you please help me figure out how to change the steps in the code so it doesn't go as far when turning the pot? thank you for any help you can give
Do you by chance have a tutorial for 3 motors?
Thanks for your awesome content.
If you don't mind can u please tell which software do you use to make the animated video?😊
After effects
@@ELECTRONOOBS thank you so much once again MR. electronoobs
Great video once again :)
nice job your friend from morocco
I was waiting for your video... :)
thanks for sharing your knowledge
Hi whats up?
i was woundering about how microcontroler(arduino ) undrestand g-code which sent to it from pc .
For example when i press the top arrow of my keybord in computer it goes one step toward and vice versa.
Printers use brushed dc motors with some sort of a long strip inside to know the precise location
Geart job as usual 👍👍
Hi Electronoob,
we are just starting now a Clay 3D printer project, I run the FabLab TU and I want the students to have access to diy printers and we’ll build them ourselves.
Ideally I would like to use these encoded dc motors but i’m struggling to understand how to integrate them with Marlin and with the signals sent by ,
Let’s say, Ramps 1.4 (or a Treetech 32bits board)
This project is going to be open source. Could you help us?
A source of optical encoders is (was) the old roller ball mouse. Not that common anymore but you may have one left over.
What about the wheels on modern mice?
Sir but how we are going to send the g-code to the machine
What is meter in the right side at the time of 9:16 ? Waiting for Ur replay
Is a power supply
@@ELECTRONOOBS send me the buying link of power supply
Great video, thanks :)
Sir is this precise enough for a 3d printer?
I dont have enough money to buy those stepper motors
cool editing
very informative. thank you.
Wouldn't replacing the pot in a hobby servo with a linear potentiometer achieve more or less the same thing, but with greater accuracy? Or perhaps an LVDT?
you'd have to not only change the potentiometer to a rotary encoder but also make the drive circuit changed to be continuous rotation modded and you'd have to remove the cog that prevents continuous rotation. You also are forced to use PWM so lose control of the switching speed of the individual mosfets so you lost speed control fine tuning and power control fine tuning.
great job thanks for sharing
Hola Electronoobs, porfa, haz este tutorial en español, ya que me interesa mucho saber del tema.
Gracias
can you modify this to keep constant rpm ?
How did you program the arduino, so that it can read the optical sensor and watching at the same time the endstop? Would be interest cause multitasking is, i think, not possible with the arduino.
Use interupts...
Can we use servo motor 😇😇😇😇😇😇😇
As usual, excellent. A question : when reversing direction is backlash (the slack in the gears) an issue for accuracy on this? It could be allowed for in coding though.
Since he uses encoders, If he placed encodes on the screw instead of the motor, the backlash would be automatically avoided backlash.
@@giovannibianchessi1578 wouldn't that reduce the resolution a lot?
@@XTronical Yes, if there is a gearbox, you are right. And those encoders, seems to me, they have few pulses per revolution.
However, mine was and is only a theorical speech.
But let's suppose the screw pitch is 4 mm and the encoder has 32 sectors. If we consider both fronts, rising and falling, pulses become 64.
4/64=0,0625 mm if I am not wrong.
(And if the encoder has a qudrature output, giving two signals, it is possible to multiply pulses by four.)
For that kind of machine and if we consider torsions, low rigidity etc. in my opinion, is not bad.
can i use mouse mechanical scroll as encoder ??
Is PID controller used in this project??
Hi Andrei,
I have learnt a lot from your videos. I need your suggestion.
As I am an Instrumentation Engineer I was able to make one IoT product which I want to put in Market as a product and star selling it. So, I want to know can
can I rely on Wemos Esp8266 boards or there any high quality and high performance esp8266 boards that I need to use for making that IoT products and selling to customers.
Kindly reply in this regard.
My best wishes for you always.
You are amazing!!
When is your podcast?
Great channel
Don't brushed motors tend to deteriorate fast if you spin them in the wrong direction too much?
Depends on how they are manufactured. Cheap ones sometimes have directional brushes that will permanently damage the motor if reversed. Some brushes just wear in one direction, so don't like reversals after that. Some have well designed brushes that work well in either direction and don't wear abnormally from a dominant direction.
Req injection molding micro sir tanks
Sir could you make a complete tutorial on how can we make a close loop cnc like this one because. I've tried using 3 different Arduino for 3 axis but if one axis is stopped the other 2 continue to make which completely distroy the design
that's just a code issue. If one axis stops, the arduino main loop should stop all operations and send you an email or something
How to use potentiometer as distance controller....
Couldnt you use a servo motor for this? Has build in rotational encoder?
they have a built in potentiometer that can only turn a few times which is different from a rotational encoder which can turn infinite times. So you would have to change things
@@artbyrobot1 ah fair enough thanks
hi do you have a drawing of proteus?
it's not working, i tried this...when i rotate the pot it starts rotating and when i rotate it a bit more it stops and if it starts again after rotating further, when i press the limit switch the motor still runs
Bro please start making tutorials on stm8 and stm32
link for 3d files is broken
Super 👍
homemade toys use stepper motors. cnc machines very rarely use stepper motors and and if, exclusively as closed loops...
not true. all desktop cnc 3d printers us stepper motors
@@artbyrobot1 yes. which are all toys...
professional cnc equipment NEVER use open loop...
hi bro i want help for my project please help me
а как насчет удержания
Удержания позиции? Я как раз сейчас строю ЧПУ станок с DC моторами: когда мотор в уже заданной позиции, то он в режиме "торможения", если он вдруг сдвинется, то мы это увидим и вернём в ранее заданную позицию. Но это маловероятно из-за использования редукторов в таких моторах.
@@gb614erg спасибо
int kp = 2, ki = 0.01, kd = 0.02;
❤❤
How to make useless box.
I am very happy that, sir you reacted on my comment. Please make a video on that topic.
used in printers
Next video: Odrive
odriverobotics.com/
QEI is best
First
Why I see banana in some of your videos
Do it with brushless lol
good idea, but it is a toy
Your up and down tones in your voice and speech pattern is enough to give me an epileptic seizure.
I learned nothing.