**The Power of Motor Encoders**
In this article, we will explore the world of motor encoders and how they can revolutionize your next project.
**What is a Motor Encoder?**
A motor encoder is a device that attaches to a motor shaft and provides feedback about its position, speed, and direction. It works by detecting the movement of a magnet or other metal object attached to the motor shaft and sending signals to a microcontroller or other control system.
**The Benefits of Motor Encoders**
Motor encoders offer several benefits over traditional methods of motor control. They provide high precision positioning, accurate speed measurement, and can even help correct for motor misalignment. This makes them ideal for applications where precise control is critical, such as in robotics, CNC machines, and 3D printing.
**Types of Motor Encoders**
There are several types of motor encoders available, each with its own strengths and weaknesses. Some common types include:
* **Magnetic Encoders**: These use a magnet attached to the motor shaft to detect movement.
* **Capacitive Encoders**: These use capacitors to detect changes in capacitance as the motor moves.
* **Hall Effect Encoders**: These use Hall effect sensors to detect changes in magnetic field strength.
**Real-World Applications**
Motor encoders have a wide range of applications, from robotics and CNC machines to 3D printing and industrial automation. They can be used to control motors with high precision, correct for motor misalignment, and even provide feedback about the position and speed of the motor.
**A Case Study: Using a Motor Encoder in a Robotics Project**
In this example, we will explore how a motor encoder was used to improve the accuracy and stability of a robotics project. By attaching an encoder to the motor shaft, the robot's movement became more precise and consistent, allowing for more accurate control and navigation.
**Conclusion**
Motor encoders are powerful tools that can revolutionize your next project by providing high precision positioning, accurate speed measurement, and correcting for motor misalignment. Whether you're working on a robotics project, CNC machine, or 3D printer, motor encoders can help take your project to the next level.
**Support This Show**
If this article has inspired you to use motor encoders in your next project, please consider supporting this show on Patreon to keep it going. Don't forget to like, share, subscribe, and hit the notification bell. Stay creative and we will see you next time!
WEBVTTKind: captionsLanguage: enNow this knob interface is quite satisfyingto play around with, but not yet perfect.Because the truth is; this is only a mockup, inspired by the open source project smartknob whose first video hit YouTube almost2 years ago.Now back then I was fascinated how satisfyingto use this demo looked and thus I immediatelychecked out the schematic of the project.And to my delight I was familiar with almostall hardware used there.Except of course one; and that was the magneticencoder that I of course also had to use herefor my mock up demo.And yes; such a magnetic encoder is similarto such a rotary encoder which I already usedin tons of previous projects before.However there are some rather big differenceswhich can not only transform any motor intoan awesome input device; but also makes itpossible to convert for example a powerfulBLDC motor into a kind of stepper motor.So in this video I will tell you all aboutsuch motor encoders and why you should definitelyconsider using them in your next project.Let's get startedThis video is sponsored by Solo Motor Controllerswho sent me one of their motor controllerboards for this video.And I got to say not only the hardware qualityis amazing; but also the software side.Meaning that after hooking up my motor withencoder about which I will talk about later;it all in all took me maybe around 15 minutesto get it all up and running with amazingprecision.And best of; the controller also functionswith minimal external components and evencomes with Arduino and Raspberry Pi support.If that sounds interesting to you then clickthe link below to check out their productsand YouTube channel.Now first off; I think it is best to takeapart such a common rotary encoder to geta basic idea of what is going on.Inside we can find a round pad with an interestingmetal pattern on it, that is of course conductivewhile the black stuff is non conductive.And on the other side we got 2 metals pinsthat sweep across this round pad and in thisencoder example they are called Clock andData; but often times they are simply calledpin A and B.And what happens is that as soon as you applypower to this thing and start spinning forexample clockwise, one of the pins will firstlytouch the metal, complete the circuit andthus get pulled down low to GND; before theother pin does the exact same thing.Afterwards these connections get interruptedand the pins get once again pulled up to thesupply voltage.This process repeats for every metal jag onthis pad meaning that at the end we get avoltage signal like this on the oscilloscope.Here every voltage pulse not only tells usthat movement took place, but by looking atwhich signal A or B came first; we can alsotell in what direction the encoder got turned.You see for the clockwise direction we triedout, it is B before A; but when we turn counterclockwiseit becomes A before B;This has to do with the layout of this patternand it is maybe not that easy to grasp withsuch a purely mechanical encoder.But If we for example compare it to an opticalencoder, that also uses a similar patternthrough which lights shines through, thenwe can easily see that one light sensor detectslight and thus triggers before the other oneand thus depending in which direction we rotate,we once again get these different voltagesignals.And that is basically always the main functionalprinciple of every encoder.The only addition you sometimes see is a thirdpin labeled X which stands for index.And this one creates a voltage pulse whenone complete rotation of the encoder is done.So with this knowledge in mind; we could mechanicallyconnect this encoder to a motor shaft andturn it, in order to find out in what directionit spins and what position the shaft takes.But there are two problems here with the firstone being that not every motor comes witha shaft on the front and back; I mean theone I want to use for my smart knob mock-upcomes with no shaft sticking out.And the second problem is the resolution ofthis encoder which completes one rotationin 20 increments.That equals a resolution of 360 degrees dividedby 20, so 18 degrees per step.That means we would have to turn our motorquite often to get anywhere on the LCD userinterface and of course when it comes to positioningtasks later on, then 18 degrees is reallyimprecise.But don't worry because there are dozens ofencoders available out there and one of themost popular ones seems to be this board basedaround the AS5600 IC which according to itsdatasheet is a magnetic rotary position sensor.What it can do is determining the positionof a magnet on top of it which therefore needsto have its north and south pole on one sideand that is normally not the case with moregeneric magnets.But thankfully the board came with such amagnet and thus by securing it onto the motorshaft so that the magnet can perfectly rotate,hooking up wires to the board, securing iton top of the magnet with bolts and hookingeverything up to a microcontroller; it wastime for some testing.Now I am using some I2C example code hereto spit out the raw angle values through theserial monitor and as you can see this setupseems to work perfectly fine.This time we got a resolution of 12 bit aka4096 steps which in theory equals 0.088 degreesper step which is a huge difference to before.The only problem with such magnetic encodersthough is that good positioning of the magneton top of the 4 integrated hall effect sensorsis crucial and sometimes you can have problemsif there are stray electromagnetic fieldsaround you.But that is not really a problem when it comesto using such a motor with encoder as an inputfor an awesome mock up project which I mightimprove in the future, not sure yet.But for now let's close this chapter and moveon to other motors to which we would liketo add encoders to precisely control theirposition.And I know what you are thinking: “Don'twe already have stepper motors if we wantprecise positioning?”.And yes; by hooking them up to dedicated steppermotor drivers, it is super simple to let themgo in one specific way and then another andthen another and so.I mean that is the reason why they are beingused in for example almost every 3D printer.And if you want to know more about them, thendefinitely check out my previous basics videoabout them.But anyway; stepper motors are not alwaysthe best choice.For example when building a small robot, itmakes more sense to use cheap and small DCmotors.Here you can see though that even when usingtwo identical ones, the robot will still leantowards one side when going straight becauseno two motors are exactly the same.In such a case, adding encoders and controllingthe motors in correlation to those could easilysolve this problem.Or let's say you want to do positioning likea stepper motor; but with a more powerfuland fast BLDC motor.Once again adding an Encoder could do justthat and luckily for me I got this AMT102one lying around which apparently uses somekind of capacitive technology.So I am not entirely sure how exactly it works;but after attaching this encoder to my dualshaft motor and having a look at the A andB pin on the oscilloscope; it seems to spitout the voltage signal we are all familiarwith and this time with a resolution of 2048aka 0.176 degrees per step, very nice.So to get this motor encoder setup completelyfunctional, I firstly added a 3D printed enclosureto it all and then unpacked my Solo Uno motordriver.Such a driver by the way is mandatory becauseBLDC motors are not really easy to control;like for example a DC motor.And since this one can handle up to 58V and100A and comes with an encoder input, it shouldwork just fine with my motor setup.All I had to do was hooking up the encoderand motor wires like the user manual describesit, connect power and hook it all up to mycomputer.With the given motion terminal software; themotor then got identified, the encoder testedand all I pretty much had to do was fine adjustingthe P and I values for the PID control.At the end I could then select a torque orspeed mode for which the encoder is alreadyuseful to obviously measure the exact speedof the motor.But then we of course also got the positioningmode where I can simply select a desired positionand the motor moves there fast and powerful.Of course we can fine adjust lots of settingshere to go for example slower, with less powerand much much more.And overall it is awesome to see that suchprecise positioning tasks are this way prettyeasy to do with every motor type out there.With that being said you should now be familiarwith motors encoders and maybe got inspiredto use them in your next project.If so consider supporting this show on Patreonto keep it going.Don't forget to like, share, subscribe andhit the notification bell.Stay creative and I will see you next time.