Saturday, August 1, 2020

Basics of Closed Loop Motor Controllers

DC motors are commonly used in electronics and automation fields with a vast range of industrial, educational and hobby applications. Within this blog article we are going to discuss about some basic concepts and devices related to one of my experimental and hobby project related to a Robotics and PCB designing. 

Post Content: This article will address following topics in order to get a basic understanding on some terms , devices and methods before we get in the closed loop Motor controller design part which I am giong to discuss in the next Blog article. You can skip reading this article if you already have an enough knowledge to understand the closed loop motor controlling concept .

* DC Motor Controller
* Open Loop vs. Closed Loop controlling
* Motor Encoder 
* Closed Loop Motor controller

 A DC Motor Controller


There are mainly two types of motor controllers as AC  motor controllers and DC motor controllers. In my case I am going to give you a small introduction to brushed DC motor controllers. As you know, a DC motor manufacturers issue a Voltage rating for every motor and we can operate it on or below that voltage rating to have a safe operation. 




Applying a constant voltage across the motor cause a approximately constant velocity of the motor shaft depending on the load on the motor shaft. However, in many applications, we need to achieve variable speeds. These speed commands may be issued by a microcontroller or a microprocessor according to the application through a standard communication protocol with low voltage signals.   





Some example of DC Brushed Motors. a) Hobby grade Gear motor b)Hobby grade Micro Gear Motor c) & d) Industrial grade Gear Motor.


The motor controller(Driver) comes to these applications as a linkage between main controller of the system and the motor. Job of a motor controller is to read speed and direction signals from the main controller which are in low voltages and use them to control the speed and direction of the motor by adjusting a higher or different voltage value and change the direction of the current flow.






Some examples of DC Brushed Motor Controllers. a) Hobby grade motor controller b)Hobby grade closed loop controller c) & d) Industrial grade DC Motor controllers.

 What is a closed Loop Motor controller?   

Basically every control system can be categorized in to two categories as Open loop control systems and Closed loop control systems. Since our intention is to understand a closed loop motor controlling, let's get the idea of a closed loop system.

 Closed Loop Vs Open Loop


Open Loop Control System:  Let's consider a system where an output is provided when an input is given to the controller unit. The first image shows an open loop system where the system outputs something only considering the input. Here the output is not measured and providing the output regardless of the output properties.


In most of the real world systems, output may vary by different amounts from the expected properties even if the controller issues a constant controlling signal due to real world situations. Let's say we are steadily applying a 12V to a DC motor attached to a toy car on the floor. Due to the constraints like the friction, car may not move with a constant speed. Therefore, we need to monitor the output and adjust control signal accordingly to achieve the desired output properties. That's why the closed loop systems are there to help us.



Closed Loop Control System :  As you see in the illustration, part of the output is fed back to the controller through a measuring element such as a sensor which can measure the certain property. The Control signal is adjusted by mixing feedback and input reference signals in an appropriate manner to issue the correction control signal to the process unit. 

Therefore, a system with a feedback from its own output, in order to automatically regulate the process to achieve a desired property is said to be a closed loop control system.

 Closed Loop Motor Controller

I think you got an idea about a general closed loop system. Let's get back in to our topic which is the closed loop motor controller. In most of real life applications with motors, there may be some fluctuations of the output due to friction between actuator contacts and also because of small changes in power supplies.

Therefore, we need to have a feedback in order to achieve a desired constant speed/specific speed profile/desired direction or desired position of the shaft.



In order to have it, we need to measure the output properties of the motor which can be the speed, direction or position while it is running. To measure them we need to use some kind of sensors. In our case we are considering only DC brushed motors. Wheel encoders are the most available monitoring element for measure above properties. Some manufacturers provide built-in magnetic type encoders specially for DC gear motors. Most of them have two outputs in order to monitor the direction as well, other than the revolutions count.  


As I mentioned in the motor controller part, the input commanding signals are issued by a controlling unit of the application. In the above illustration, you can see minimal components set of a closed loop motor controller with controlling signals, controlled voltage output and the feedback portion from the encoder counter readings. 

 Motor Encoder Explanation


Encoder is a sensor which can be used to measure amount of rotation of a shaft. Generally, a rotary encoder attached to the rear par of the motor shaft is used as the motor encoder. Purpose of having an encoder for a motor is to measure some properties of the rotation such as direction and amount of revolution.



Example of a magnetic encoder and an optical encoder.



There are two major types of rotary encoders available in the market as follows.

* Absolute Encoders: They Provide the current position of the shaft which can also used as  an angle transducer

* Incremental Encoders: Provide the continuous information about the motion of the shaft which can bes used to deduct speed and position. 


Processing absolute type encoder data is bit complex compared to processing of incremental encoder data. Within this article, we are consider only about the incremental type encoders. If you would like to know more information about rotary encoders, use the following link.  


How do a magnetic encoder and an optical encoder works.(both are incremental type encoders).


[More Information About Rotary Encoders](https://en.wikipedia.org/wiki/Rotary_encoder)

Normally, an Incremental encoder gives one or more channels of outputs having a square shaped pulses or ticks as the motor is running. Let's take a look at what are those output signals and how they get triggered.

Incremental encoders also have different technologies. Optical encoders and Magnetic encoders are the common types used in many applications. Among these two types majority of DC motors are having built-in Magnetic Encoders. 

Example of a two channel output encoder with the motion of the shaft.


Above animation shows how these magnetic encoders in a motor gets its readings using two magnetic sensor heads. The rotating circle represents a disk with a special ferromagnetic pattern as illustrated which is rigidly attached to the shaft of the motor. A and B represent the two outputs from sensors.

 Using Encoders to Detect the Direction of Rotation


Motor shaft rotating direction can be either clockwise or anti-clockwise. We can use two outputs from an incremental encoder to easily detect this direction. The following illustration will show you cleary the process of detection.
 

How to find the rotating direction of the motor using encoder readings .

As you see in the above image and in the animation, output pulse trains of two channels are not in the same phase at a certain time instance. If we read both the channels from a processing unit, we can find which channel gives the HIGH state of the pulse train before the other channel. This is same as finding which channel gives the state transition before the other one. Signal rising from LOW to HIGH or A signal falling from HIGH to LOW is called as a state transition. 

In the above illustration, if the motor shaft rotates in to the clockwise direction, its channel A leads the channel B at a certain time instance. Vice versa counter clockwise rotation will gives a leading output for channel B. This channel reading part can be implemented in a processing unit of the motor controller to achieve a better closed motor controlling.
 

 Put Them All Together

I hope now you have a basic idea on DC motors, motor controllers and closed loop control systems. Now it is time to conclude the article with reviewing the big picture. Just applying a constant or variable voltage supply to a motor without monitoring output will not give the expected movement in many real world motor applications due to practical restraints like friction. 

Using feedback information from an encoder, we can achieve smoother movement profiles from a motor because if the output is not at the desired level we can adjust it accordingly.  Rotary encoders are the easiest and best way to get this feedback from motors. Closed loop motor drivers have following advantages over open loop ones.  

Advantages of Closed Loop Motor controlling

* A constant torque or constant speed can be achieved against a variable load
* Higher accuracy with fine controlling ability
* Higher dynamic response
* Advanced smoothing and speed profiles can be implemented
* Easiness in integration with upper level of any application



 My Closed loop Motor controller design( Challenger )


With this basic introduction to the Closed loop motor controlling, let's move on to my next article which is a robotics related project on designing a closed loop motor controller for development applications.

 If you have any question or need to clarify something related to the content of this article, please do not hesitate to put a comment below or contact me in that matter. 

Friday, June 19, 2020

The Moon Illusion

We are going to discuss two really interesting phenomena for anyone curious about the Moon within this blog article!             
It's obvious that you normally tend to take a look at the moon when you just walk outside in a beautiful night, especially if there's a full moon. While you enjoying this gorgeous view, have you ever noticed that, this same moon is appearing in different sizes in different days or different positions of the night sky?

If your answer is yes and you are still keen to know the real science behind this phenomena, then you are just about to find out in a simplified manner. We can break this problem in to two cases. One case is something really happening in the physical space and the other case is something happening inside your brain which can be understood with some hypothetical(simplified) explanations.

1. Super Moon

A super moon is a full moon or a new moon which is having a slightly lager disk than the usual apparent size of the full moon you see from the Earth, happening due to the nature of the orbit of the moon around the earth. This moon's orbit around the Earth is not a perfect cycle. It is an elliptical one having an average distance of 382,000km to the Earth. Scientists of NASA explain that the Earth, sun and all the other planets are exerting different gravitational pulling and pushing forces on the moon which give us the opportunity to have this elliptical orbit.

When the moon is at its Apogee position and it also at its full phase or a new moon, then this is called as a Micro-moon or a Mini-moon which may not be so familiar for you. In a similar but opposite manner, brightness will be reduced by 30 percent and disk size will be smaller than 14 percent than usual of a micro moon.

Because of the elliptical orbit of the moon, it shows an oscillating nature in the distance to the Earth as the above graph with the time. As you can see, full moons are in dots and the new moons are illustrated in x makers. In the year 2020, you can see that there are two full moons having the closest distance to the Earth. Those were two super moons on 9th of March and 7th of April which you may have already watched from your own eyes.    

 Is it the only reason?


In the above section we discussed about one reason for moon to be appeared in different size than usual. However, it is not the only reason and super moons are not really show a huge size increment for human eyes. Anyway, at the super moon, you cannot catch a considerable apparent size increment of the moon but, its brightness increment will be very noticeable and really beautiful. 

There is another reason which the image processing inside human brain makes us to believe that "Whoa! Moon is HUGE today!". This is called as the Moon Illusion and in this article we are going to discuss the reasons behind it. 

2. The Moon Illusion


This is an optical illusion which causes the moon to be appeared larger near the horizon than it appears in the higher sky(let's say in the zenith). Many of you might have experienced this thing around a full moon day. Unlike in the super moon situation, this can happen regardless the distance to the moon from Earth.
As in the above image, you see the moon larger near the horizon and it appears in usual size when it is away from horizon. That is the moon illusion and the real reason is still debated by scientists and several reasonable hypotheses are emerged to describe it fairly. Here we are going to discuss the two most reasonable explanations as follows.
* Apparent distance hypothesis
* Relative size hypothesis.  

2.1 Apparent Distance Hypothesis


This theory purposes that the horizon moon seems larger than the moon at the zenith (right above our head) because it looks farther away. Does that make no sense to you?? Let's say in your daily experience, an object overhead, like a bird or an aircraft flying by, appears closer and therefore larger than the same bird or aircraft near the horizon because it really is closer. Our brain built to think that objects near the horizon are (usually) more distant than those are above us because they appear to lie behind and beyond foreground objects. So the same image processing thing is happening inside our brain when we look at the moon.

The same distance and size relationship deduction process happening inside our brain, cannot be used to very far object to us such as moon, sun or other celestial bodies because even if they appear from the horizon or zenith, there won't be a considerable distance difference from us. 


However, our brain tries to apply the same processing to build the distance-size relationship when we look at the moon and it thinks horizon moon is farther away than the zenith moon and it try to compensate the size of the moon by itself. Therefore, our brain makes us to believe the actual size of the moon at the horizon is larger than zenith moon even if the retinal image is same size.

The background of the moon at the time we are looking at it also affect this size judging process inside our brain. Following image illustrates that effect. Most of us see the top Moon, seemingly located in the distance based upon the convergence of the railroad tracks, as larger than the bottom Moon. Yet they are identical. This is called as the Ponzo Illusion.

Now you see how marvelous is our brain. It can lie about what we see from our own eyes...Well that's why it's called as an illusion.

2.2 Relative Size Hypothesis


This is the next best explanation for the moon illusion, which says that, the perceived size of an object by the human brain is not only depending on the retinal image size, but also on the sizes of the surrounding objects which are in the immediate vicinity of our target object. So this effect is named as the Ebbinghaus illusion Do not get confused with the above definition. Let's take a look in to this in a simple manner.

This image is an illustration of the Ebbinghaus illusion. Which orange color circle is the bigger one from two flower kind of patterns? The correct answer is; they are same in size. But, with the sizes of surrounding blue circles, many of you may see the right side orange circle is bigger.    

This animation also shows the same effect more clearly with more steps. You may see the size of the orange color circle is decreasing when the surrounding circles are getting bigger. This means that, when the visual extent is smaller, a certain focused object may have perceived larger than the real size by our brain. 

When we apply this to our scenario which is the moon in the horizon (which represents the smaller visual extent), can be represented as the right side pattern with smaller surrounding circles. Then the moon in the zenith (a larger visual extent) can be represented as the left pattern with larger surrounding circles. Therefore, we see the moon in the horizon larger because there the surrounding vicinity is smaller than the wide sky. Now I think you have a clear idea on why the horizon moon appears bigger than the zenith moon.     
   
In this blog post we discussed two phenomena which cause the moon to be appeared in different sizes in the night sky. I hope you got a clear idea in both of them...Is that all????? Nope.

 How does the Moon Appear Big in Photographs? 


Now all the way I told that the big moon is just an illusion happening inside our brain. Then why the hell we see the moon very huge in some photographs just like the header image of this article and the following image?? 

This photo is a real one taken in Greece with a digital camera. Actually the moon can be captured with this kind of huge size in to photograph with a considerably good telephoto lens kit. But you need to move very far from the targeted objects. In above image you need to go far away from the building with the camera. Then zoom the building and the moon as the size you want with good details and take the shot.


That's all I have to share with you guys about the Moon Illusion. Feel free to ask any further details or something not clear to you regarding the content of the article.






The Featured Post

A Deep Dive into Deep Packet Inspection

This blog post aims to unfold the details of DPI, exploring its definition, methods, applications, modern technologies, and the challenges i...