Avayan's Roboticus Projecteria

July 30, 2010

Slow, Mixed and Fast Decay Modes. Why Do We Need To Complicate Things?

Filed under: Uncategorized — Avayan @ 1:24 am

If you are driving inductive loads, whereas it is a brushed or brushless DC motor, stepper motor, solenoid or a relay, you must have experienced a little bit of a problem in the form of an unwanted current flowing in the unwanted direction. If you did not take this fact of the laws of physics into account, chances are you  have had the only once enjoyable experiencing of smoking your transistor. Whether it was a bipolar transistor or a FET, if a mechanism to overcome this generated current was not put in place, said transistor will not last long. But why does this happen?

Lets take a quick look at what is happening with our inductor.

It is a known law of physics that inductors will not tolerate abrupt changes in current either when they are being charged or when they discharge. This is in essence because as you apply a voltage and a current starts to flow through the conducting element, a magnetic field is generated. The magnetic field at the same time generates a current that fights the incoming current, making the incoming current needing to fight its way into the inductor. Either way, and at the end of this charging ordeal, we can see that the energy that went into the inductor will be maintained in the form of a magnetic field. OK, enough with the basics.

 

Case A of our picture shows a current happily flowing into our inductor. I say happily because in essence nothing stops this flow. As soon as the FET is energized, the current starts to flow until the inductor saturates. But what happens when the FET is disabled? This will eventually happen, right? This may be fine except that all the energy stored inside the inductor will now want to get out of its cage, plus the current can not change abruptly so whatever was going in, must continue going out. As a result the inductor is now the source and the FET the load. But the FET is off!!! This angry current, as portrayed on case B, will not care too much about its path not being present. A path will be made, one way or the other! And as it is often the case, the voltage goes up in such a way that the FET is damaged.

We need to provide a way for this current to find a safe path which not encompasses the destruction of our transistor switch. And the solution often comes in the form of what is called a free wheeling diode. Notice the diode is placed such that while the FET is on, it can not conduct (its voltage from anode to cathode is negative). It is only when the FET is OFF, that the inductor operating as a source makes the voltage across the diode positive, hence making it conduct. In this case, the FET sees no current flow and no negative voltage.

But why do we need to bother about this when dealing with H Bridges? The previous example shows a simple single FET driver. Are H Bridges subjected to the same problems? Yes and No! In essence the problem still exist because inductive loads will still try to conduct through a disabled FET when said switch gets disabled. So an H Bridge would suffer the same fate as the single transistor driver if an alternate path is not provided. However, the H Bridge has enough alternate paths, and this is where current recirculation or decay modes come into play. Lets take a look at the H Bridge quickly.

 

On an H Bridge you only enable as much as two FETs at any given time. It is completely forbidden to enable the two FETs on the same side, as this would lead to Shoot Through (a short circuit from power supply to ground). If you enable the hi side FET on the left side (AH), and the low side FET on the right side (BL), then the current flows from left to right. If the inductive load was say a DC motor, then the motor would spin in one direction, say clockwise. If on the other hand, you enable the high side FET on the right side (BH), and the low side FET on the left side (AL), then the current would flow from right to left. This has the desirable effect of turning the motor in the opposite direction, in this case counterclockwise.

Unfortunatelly, all is good only if we never disable those FET’s. Because as soon as you do, then the current will try to keep on flowing on the same direction, which should result in flames right? Not necessarily… What if we add freewheeling diodes to save the day? Four of them should do, right? As it turns out, we do not need them! Like I said before, there is already more than plenty alternate routes and all we have to do is use the very same FETs we already have and their associated internal body diodes. This has a few advantages:

  1. Since extra diodes are not needed (and as long as the body diodes are used only for very brief periods of time) we can save on component cost
  2. The FETs are considerably much more efficient than diodes anyway, so we can decrease the amount of power loss in the form of heat.

But how does this work? The first thing we must understand is that Shoot Through must be avoided at all times. So, if we are going to use some or all of the unused FETs on the system, it is imperative that we do not turn them ON while the previously active FETs are still ON. Confused? If AH is ON, we can not let it be ON, while AL is ON, and so forth.

Fast Decay Mode

 

In Fast Decay Mode we use the opposing FETs to offer an alternate path for the current to flow through. Notice that it looks identical to the polarization in which we allowed for the current to flow in the opposing direction. However, it is very important we remember current does not tolerate abrupt changes. Hence, long before the current can flow in the opposite direction, it must decay to zero. Then, it can start flowing as we saw before.

Fast Decay Mode is called as such because this is the fastest the current will die to zero. Notice you are basically placing a voltage source plus two voltage drops (there is a voltage drop across each FET given by the current multiplied by the FET RDSon) across the inductance. Since the inductance voltage can only be as large as the voltage source, the new voltage we are applying to the inductor is larger and as such will fight considerably hard for the already existing current to die out.

Below my two H Bridge drawings I am showing a possible way in which we can disable/enable the FETs. Remember Shoot Through is forbidden, so we must disable one FET before we enable the other one. It must be a break before make kind of deal. The speed at which the FETs are turned ON and OFF is in the nanoseconds range. Often, anywhere in the vecinity of 100 to 200 nano seconds. You may be asking, how about the current during these 200 nano seconds? Can it damage my already disabled FET? Luckily, FETs are intrinsically built with a body diode which will easily carry this current through this brief period of time. Anything longer than the 200 nano seconds, and all bets are off. You could of course design the body diodes to be large and powerful, but what’s the point? Shortly after we will be enabling a way better path which is the opposing FET!

A very important distinction to be made is between asynchronous and synchronouse current recirculation. If diodes are used (and there are reasons, such as improved thermal release, in which we will want to use external diodes instead of the FETs, a good example being the DRV8811), then the current recirculation is said to be asynchronous. This is because you are not controlling the occurrence of the alternate path creation. It will happen, but you do not control when this happens. If on the other hand, the H Bridge control logic has to take care of enabling and disabling FETs in order to promote an alternate path, then the current recirculation is synchronous. Just an important note, as both are still commonly used today!

Slow Decay Mode

In Slow Decay mode we use the FETs on the same H Bridge segment. Per example you can use either both high side FETs or both low side FETs. The typical convention is to use the low side FETs.

The idea behind this method is that current is allowed to decrease through zero as the inductor recirculates the current through a resistive path. Notice that as both low side FETs are enabled, the current is basically dissipating a voltage across the two FET’s RDSon. It is called slow decay because although current eventually decays to zero, it takes longer than fast decay mode. This makes sense as we are not applying a voltage opposing the current, which would definitely be the fastest we could fight the existing current.

How slow the decay mode is depends on the motor inductance and the FETs RDSon. The smaller the RDSon, the longer it will take for the current to decay to zero.

When it comes to DC motors, however, there is a very interesting effect while using this decay mode. While on fast decay mode the DC motor rotor coasts down in speed, with slow decay mode the rotor stops very quickly. This is because as can be seen by the above picture, you are shorting the DC motor terminals. This in essence implies the BACK EMF voltage source inside the motor to be shorted. And if there is no BACK EMF, there can be no speed. One is directly tied to the other. We call this phenomenon braking the DC motor or the collapse of the Back EMF. Braking is vital when you want to stop your motor very fast and possibly obtain a particular position. With coasting, this would not be possible, so be aware that selecting slow decay or fast decay with DC motors is not a trivial endeavor.

I like to point out, when I discuss slow and fast decay mode, that the names “slow” and “fast” are pertinent to current, not to DC motor speed. They imply a direct relationship with how fast the current decays through the winding. However, when it comes to how fast the DC motor speed decays, it is the total opposite. Kind of annoying, but I guess one thing leads to the other. So be careful not to think that fast decay will stop the motor very fast, because it is actually the opposite.

Mixed Decay Mode

There is one third of current decay which we call Mixed Decay Mode because it is actually a mixture of Slow and Fast Decay modes. By definition, you inccur in Mixed Decay if through the entire current decay cycle a percentage of it is slow and the remaining percentage is fast. Why do we need this feature? In DC motors it is pretty much unused, but when it comes to steppers, specially while microstepping, Mixed Decay is a must!

This may be a little bit advanced, but what happens is that as you are trying to synthesize a sine wave across your stepper motor winding, drawing said wave shape will become harder at some points in time. Per example, when you are charging the winding (angles of 0 to 90), it is very easy to superimpose the waveshape of a sine wave. But when you are discharging the winding (angles of 90 to 180), then the motor inductance will dictate whether you can discharge fast enough or not. If the motor inductance is too high, chances are you will not be able to superimpose the correct sine wave shape and deformation occurs. This is because the decay mode is too slow!

So a solution would be to use fast decay. This will definitely solve the problem, but another problem occurs. Fast decay mode has the side effect of high current ripple. Remember the current is swinging considerably more than on slow decay mode. This poses a few unwanted problems such as EMI magnitude increasing (larger current peaks are of course gives a stronger radiation) and more audible noise, depending on the current chopping frequency.

So what we need is an in between. Some decay rate that is not too fast or too slow. Mixed Decay mode gives us that. Some devices will allow you to control the exact rate of the mixed decay mode. The DRV8811 is a good example. Other devices, such as the DRV8824 and DRV8825,  just give you a fixed rate of mixed decay mode. For most applications, this is enough.

April 19, 2010

Avayan’s CNC Electronics Overview

Filed under: CNC,Motion Control — Tags: , — Avayan @ 12:28 am

My electronics are ready to go. Everything except one board is of my design, and I am proud to report that as of today it is all working.

The parallel port board is the only thing I bought. It is a C10 breakout board from CNC4PC. You can find more information on the board here: http://www.cnc4pc.com/Store/osc/product_info.php?cPath=33&products_id=45.

On the lower left you can see my AE-PWR1 Dual DC Switching regulator converter board. I use this board to convert from 24V to 3.3V and 5V. As it turns out, the C10 requires 5V. But my stepper drivers use an MSP430 microcontroller, so they require 3.3V. The AE-PWR1 worked beautifully to get me the rails I needed. Could I have used conventional linear regulators such as the 7805? Sure! But I had the AE-PWR1 ready to go, so why not? Plus this is way more efficient and will get less hot than the linear counterpart.

At the center left you can see my new AE-PWRPlane. http://www.avayanelectronics.com/Products/AE-PWRPlane/ae-pwrplane.html. This little board allowed me to easily route the 24V from the power supply to the switching regulator and three stepper driver boards. Since it is a dual plane, it also allowed me to route the 3.3V from the switcher output into the three stepper drivers as well as the opto coupler board. I could have used the output terminals on the AE-PWR1. Either would have worked perfectly.

At the top you can see the three stepper drivers. These I have not released into the public yet as I need to validate the design a little bit more. However, they consist of two DRV8828 single H Bridge drivers from TI and an MSP430F1612 microcontroller. The firmware will allow up to 512 microsteps to be generated by using the on board dual DAC channels. This however, is too much resolution even for this project, so I am using way less than that.

The last board is the one I am least proud of as it is an ugly protutype but it works perfectly well and since I do not see myself building more of this, it will have to do. This is a conversion board I needed to place in between the C10 parallel board and the microcontrollers. It consists of a series of optocouplers which I use to convert from 5V to 3.3V. So in essence, they are level shifters. Yes, ideally I should use level shifters but the optocouplers offer the advantage of isolating the stepper drivers from the PC. So if something happens (and I hope it does not), then the PC should be safe.

November 12, 2009

Yet another DC Motor Controller

Filed under: Motion Control — Tags: , , — Avayan @ 7:20 pm

I don’t know why, but a few weeks ago I felt like improving my AE-DC1 DC motor controller. At least the results were pleasing. The AE-DualDC3A module is considerably easier to use than its predecessor. It is just a little bit larger, but has twice the capability!

One of the reasons why the DC1 was giving me a few headaches every now and then was its lack of connectors. Having terminal pads perfect for soldering can be very annoying when you need to move the controller from one place to another, or when you want to change the load.

It was also not appealing at all for me to solder every board into my test bench only to desolder it a few minutes later so that I could ship it to the new customer. I myself would not like to receive a NEW item just to find out that it is in reality used! With terminal blocks, I was able to get rid of all these problems.

Another aspect I changed was the need for a SENSE resistor. On the DC1, the SENSE resistor selects the maximum current the motor will see. However, the current regulation on the DRV8800 is not like the current regulation you see on a stepper. So having the H Bridge disable at say 1.0 amps and for 1.5 ms really does not buy that much. And DC motors only use whatever current their loading requests in the form of torque, so limiting the current did not seem like a necessity.

By removing the SENSE resistors and tying the SENSE pin directly to GND, the DRV8800 will now provide up to 3A of current before reaching ITrip. That should be plenty! I really do not intend to run extremely small motors with these drivers and I do not foresee too many customers needing such a requirement. Buf if they do, there is always the AE-DC1 as an option.

The AE-DualDC3A seems like a good deal! We’ll see how well it does out there. In the mean time, feel free to check this little video I put together detailing some of the functionings of my latest DC motor controller:

September 4, 2009

Cobotrox I in Action

Filed under: Robotics — Avayan @ 12:00 am

Like I explained on my previous post, I was finally able to take my old electric wheel chair platform and remote control it by using a very simple decoder that takes RC PWM signals and generates DC Motor PWM signals. For this project I used an MSP430 to sample 2 RC PWM signals, decode them both and generate 2 ENABLE PWM signals that were fed into my Dual DC Motor controller with up to 30A capability.

I also used another recent design, my AE-MDL-PWR1. This is a dual DC/DC power converter. The idea is to take the 24V from the battery and efficiently generate 5V and 3V needed for the different electronic blocks such as the micro controllers and the FM receiver. A block diagram below depicts the basic wiring for this simple implementation.

wheelchairdiagramblock

But nothing better than actually seeing the project in action. The video can be enjoyed below. Next step, starting to add some intelligence and cool gadgets such as shaft encoders, sonar range sensors and a camera!

Wheel Chair Robotics – Adding Remote Control Functionality

Filed under: Motion Control,Robotics — Tags: , — Avayan @ 12:00 am

A great deal of the robots out there are basically just giagantic remote control contraptions. Some people will argue there is little roboticism about that, but I think remotely operated mechanisms do qualify as robots. After all, imagine a machine capable of extend our human capabilities such as grabbing and seeing, but on places where we just can’t go, like heavily toxic environments or just plain inacessible locations. Nothing better than a remotely controlled robot for these tasks!

I have finally been able to add remote control capabilities to my wheel chair robot project. I have named this robot Cobotrox I. The name Cobotrox goes to about 10 years ago. One day as I was teching my microprocessor interfacing course at the University of Puerto Rico, I needed to provide the class with a password. Our of nowhere I came with c0b0tr0x, so I decided to use the word on future projects. Here we go!

How do we add remote control to a robot? You can either buy every remote control component or you can make it yourself. I opted for a combination of both realms. I bought the transmission part and decided to build the decoding section. The transmitter and receiver are considerably cheap nowadays. You can buy fancy FM RC radios for about $150 new. These have more channels than you will most likely need.

The decoding I have been making for about 10 years with microcontrollers. I have done this project over and over with HC11, AVR’s and now MSP430 microcontrollers. It is very possible I even tried PICs at some point in time, but I am not a PIC lover so I don’t think that went too far. But I am certain a great deal of PICs can easily tackle this application. 80C51′s, ARMs, you name it. If it is a processor, it can do it!

What needs to be done? You need to read the RC PWM coming out of your RC receiver. The previous tutorial should explain how this PWM works. This is vital to understand because the RC PWM contains both direction and speed information. Well, in reality the RC PWM contains position, but we can decode this position to whatever we want to do with it!

The idea is to measure the RC PWM pulse and determine whether the length in time is greater, equal or lesser than 1.5 ms. If it is larger than 1.5 ms, we move the motor forward. If it is less, we move the motor backwards. Once direction is determined, then the magnitude of the speed control PWM is determined as a factor of how much larger than 1.5 ms or how much smaller than 1.5 ms, the pulse is. We do this on a continuous basis and achieve speed control of our DC motors.

Do not be mistaken. You can use this signal to control speed of stepper motors, enable/disable loads such as water pumps, solenoids, lamps, etc, or whatever else you can think of! The information is there; it is all now a matter of doing something with it.

Below I present a flowchart that summarizes what I explained below. If you want to see code, I certainly have the MSP430 code ready to be posted. I may have the AVR code in assembly, somewhere in my backups. I doubt I will ever find the HC11 code, but it is pretty much useless anyway, unless you are getting your flux capacitor busy and need to reconstruct this functionality 10 years ago.

RC PWM to DC Motor PWM Flow Chart

August 29, 2009

Understanding PWM

Filed under: Motion Control,Robotics — Tags: , , , — Avayan @ 9:29 pm

PWM stands for Pulse Width Modulation and it basically means precisely that. You have a pulse, and if you can change the width of the pulse without changing the frequency, then you have modulated its width. Lets first take a look at what a pulse is, because for motion control purposes, it is very important to understand this very simple concept.

PWM Basics

A pulse is an electric signal whose presence is not indefinitely long. A pulse has a beginning an and end and the time from beginning to end can be measured. In essence everything is a pulse since everything has a beginning and an end, but lets assume that these pulses have a finite length in time which is considerably lower than other measurements. Per example, when you turn your computer on and then OFF in a matter of three hours, the pulse of energy that the computer consumed is 3 hours long. The pulses we will concern ourselves with are considerably shorter than this. In fact, they are way shorter than a second.

That being said, a pulse has a finite length in time and that is what we called its TIME ON. How long was the electrical signal present. Once the electric signal is removed and until the signal is applied again, is called the TIME OFF. If the electric signal changes to ON and OFF with continuous and equal intervals of TIME ON and TIME OFF, we say the pulse is periodic and its period is equal to the amount of time the electric signal was present (TIME ON) plus the amount of time the electric signal was not present (TIME OFF).

NOTE: Most of the time when we deal with PWM, we want the PERIOD to remain constant.

Another electrical measurement you may have heard about is the frequency. Frequency is how many times, on a per second basis, something happens. In other words, how many times did the pulse went ON and OFF on any given second. Taking the inverse of the PERIOD gives us the frequency. Frequency is vital understand as the system receiving the PWM signal will most likely be tolerant of a particular frequency. Slower or faster frequencies may not work or simply have undesired results as we shall see later.

We are now ready to fully understand what PWM is. A pulse is generated on a continuous basis, but we change the amount of time the electric signal was ON. Notice that if the PERIOD remains constant any change in TIME ON must also result in a change of TIME OFF. This is very important as well, as it gives us the measurement of Duty Cycle (DC%), which is the percentage of how much time was the electric signal versus how long it was OFF. The rule of thumb is that as the amount of TIME ON increases so does the DC%.

RC PWM 

Most people are familiar with the way in which professional remote control toys (such as cars, airplanes, helicopters, boats and now robots) are controlled through a signal referred to as PWM. I like to call this RC PWM as it is very different to the PWM signal used to control DC Motor speed. It is very important that we understand the difference as most remote control robot projects will in fact use both forms of PWM. We often use a radio transmitter which sends an RC PWM signal to an RC Receiver. The receiver decomposes the received signal into a series of RC PWM signals, one per channel. If your RC system is 5 channels, you will get 5 PWM outputs. Each one of these RC PWM signals controls the position of one RC Servo.

Transmitter Receiver

 

Here is why I like to make the distinction between RC PWM and other forms of PWM. The RC PWM signal is only meaningful to RC based systems and it basically contains position information. The width of the pulse only offers position information. We can of course utilize this information to control whatever we want (intensity of lights, DC motor speed, rate of rotation of a stepper motor, etc.) I have done a lot of stuff with the RC PWM signal, but bottom line is that this signal can only be used to send information. We will see later, that when controlling a DC motor, it is amount of energy what we need, and not information. But let see what kind of information we are talking about.

Servo RC PWM

RC Servos has been designed to accept the RC PWM signal which is nothing more than a periodic pulse with a width of anything between 1.0 ms and 2.0 ms. Some systems with more resolution will have allow for pulses in the range of 0.5 ms to 2.5 ms. However, 1 ms to 2 ms is pretty much standard. The idea behind this position protocol is that 1.5 ms commands the servo to go to the center position. A 1.0 ms pulse commands the motor to attempt to reach its leftmost position and 2.0 ms to its rightmost position. Any pulse measuring in between 1.0 ms and 2.0 ms is decoded as a position in between leftmost and rightmost. Since the remote control is analog, practically any position can be attained.

It is very easy to generate an RC PWM signal using a micro controller or any other digital contraption. When this is done, the positions available are dependent on the timer resolution. Per example, it is possible that a pulse can only have 256 steps between 1 ms and 2 ms pulse width. Even then, 256 positions are more than enough for any fair control application. The motor itself is not as precise as to be adversely affected by this lack of infinite resolution.

DC Motor Speed Control PWM

The user may feel that the RC PWM signal may be an awesome resource to control the speed of a DC motor. And this is of course true, except that the RC PWM signal itself is pretty much useless as a direct means of controlling the DC motor speed. What needs to be done is to have an intermediate circuit to decode the position information (RC Pulse width) and generate a speed magnitude signal. In other words, if the input pulse is 1 ms, move the DC motor on reverse at maximum speed, if 1.5 ms wide stop the DC motor and if 2.0 ms, move the DC motor forward at maximum speed. Any other pulse width is then decoded to partial speed on the corresponding direction.

But how do we control speed on a DC motor? There are many ways as I have depicted before on this blog, but my favorite is with an H Bridge. As it may confuse the reader, an H Bridge utilizes PWM, as well, in order to control DC motor speed!!! However, the PWM we use to control the speed is totally different than the RC PWM signal we had been discussing previously.

Like I explained previously, the RC Servo signal encodes position on the pulse width. Notice the important aspect of the RC PWM is the TIME ON and how long this is. Any TIME ON with widths between 1.0 ms and 2.0 ms are useful. TIME OFF and Duty Cycle are of no concern. This is not true about DC Speed Control.

As it turns out, on an H Bridge, the Duty Cycle will be directly proportional to the resulting voltage applied into the load. And on a DC Motor, voltage applied is directly proportional to motor speed.

The best way to see this is to realize that with an H Bridge, TIME ON actually means the motor is ON, whereas TIME OFF actually means the motor is OFF. So imagine you are applying 12V to  your H Bridge, but the H Bridge is ON only half of the time. In other words, the motor is ON for 1 ms and then OFF for another 1 ms. To the eyes of the motor, this is pretty much identical to having 6V instead.

On the figure below I am trying to portray how speed varies by changing PWM Duty Cycle. The H Bridge is chopping the amount of time the motor is receiving energy. By varying Duty Cycle, we have an infinite amount of voltages to apply to the motor, which then results in an infinite DC motor speeds ranging from stopped to running at full speed.

Speed vs PWM DC%

 

I demonstrate this concept on my DC Motor Basics Part I blog. Feel free to check the video and notice how the motor speed instantaneously changes as the PWM DC% is modified. For that experiment I used my AE-MDL-DC1 and an MSP430 micro controller to supply a synthesized 32 KHz 8 bit PWM signal.

Connecting the AE-MDL-STPR1 Bipolar Stepper Motor Controller

Filed under: Motion Control — Tags: — Avayan @ 1:15 am

If you have acquired or built one of my bipolar stepper motor drivers with up to 2.5A current capability and internal microstepping indexer, you could be asking, “How do I get this little guy started?” That is indeed a very nice question and although I tried to make the module as easy to use as possible, the levels of flexibility do add some minor complexity to it. 

AE MDL STPR1 Connections

Figure 1

 
The quickest way to wire the board for operation with your own micro controller (MSP430, AVR, Arduino variety, 80C51, Basic Stamp, Propeller, PIC, etc) can be seen on FIGURE 1.
Header connector J3 accepts all the control signals you will need to deal with as well as low voltage power source, VDD. VDD is often 3.3V but it can go as high as 5V. From my microcontroller, I am driving DIR, ENABLE and STEP. I often ignore FAULT as I am assuming that everything is going to work. If there is a fault, however, this signal is available for your usage.

Notice I have directly connected to VDD, the SLEEPn, USM1 and USM0 signals as there is no need to control this with my microcontroller. However, if your application requires low power mode in order to preserve battery power, then I recommend you drive nSLEEP with your microcontroller.

Luckily, there is an easier way to set these three signals (nSLEEP, USM1 and USM0). I knew some people would use these drivers with their own PC CNC router (small form factor, of course) and all they would need are the DIRECTION, STEP and ENABLE signals. In this case, there are jumpers which can be placed so that the three signals question can be tied to VDD or GND depending on what you want to do.

 

AE MDL STPR1 Typical Jumper Configuration

AE MDL STPR1 Typical Jumper Configuration

Figure 2

Figure 2 shows the typical jumper allocation I would expect to see on most setups. However, flexibility is there if you want something different. USMx will choose degrees of microstepping. A small table on the back of the board shows the different combinations. Unfortunately, I messed the silk screen so that both cells contain UM1. It should read UM1 and then UM0 (center cell is UM0). I will certainly fix this on my next revision.

SLEEP pretty much has to be jumpered to VDD. Jumpering SLEEP to GND renders the board useless as the device will be disabled. It just made the layout and assembly processes easier.

SRn has to be tied to GND if you do not have the external Schotky diodes. The back of the board contains the footprint where some MBRS360 could be soldered into. I do not sell the boards with these diodes as they are not 100% needed. If you want to run at very large currents, then the diodes are recommended as they take some of the heat away from the packaging. If external diodes are to be used, then jumper SRn to VDD.

Final Connections

Last two things to take care of are connecting the bipolar stepper motor to the J1 connector. This is no biggie, really. If your motor is a four wire connector, it is a matter of just plugging it in. Direction of rotation will be affected by which wires end up being A+/A- and B+/B-. Reversing the wire polarity should do.

In the same fashion, connecting power on J2 is equally easy. However, do note that connecting reversed power will instantly destroy the driver part, so make sure proper polarity is observed.

August 22, 2009

DC Motor Control Basics

Filed under: Motion Control — Avayan @ 6:33 pm

You have a DC Motor you want to control it. But how? And what does DC Motor control means? Pretty much when we are talking about DC motor control, there are 4 aspects we need to get our minds busy with:

  1.  Direction of rotation
  2. Motor Speed
  3. Motor Torque
  4. Motor Start and Stop

Direction of Rotation

A DC Motor has two wires. We can call them the positive terminal and the negative terminal, although these are pretty much arbitrary names (unlike a battery where these polarities are vital and not to be mixed!). On a motor, we say that when the + wire is connected to + terminal on a power source, and the – wire is connected to the – terminal source on the same power source, the motor rotates clockwise (if you are looking towards the motor shaft). If you reverse the wire polarities so that each wire is connected to the opposing power supply terminal, then the motor rotates counter clockwise. Notice this is just an arbitrary selection and that some motor manufacturers could easily choose the opposing convention. As long as you know what rotation you get with one polarity, you can always connect in such a fashion that you get the direction that you want on a per polarity basis.

DC Motor Rotation vs Polarity

DC Motor Rotation vs Polarity

Facts:
  • DC Motor rotation has nothing to do with the voltage magnitude or the current magnitude flowing through the motor.
  • DC Motor rotation does have to do with the voltage polarity and the direction of the current flow.

DC Motor Speed

Whereas the voltage polarity controls DC motor rotation, voltage magnitude controls motor speed. Think of the voltage applied as a facilitator for the strengthening of the magnetic field. In other words, the higher the voltage, the quicker will the magnetic field become strong. Remember that a DC motor has an electromagnet and a series of permanent magnets. The applied voltage generates a magnetic field on the electromagnet portion. This electromagnet field is made to oppose the permanent magnet field. If the electromagnet field is very strong, then both magnetic entities will try to repel each other from one side, as well as atract each other from the other side. The stronger the induced magnetic field, the quicker will this separation/attaction will try to take place. As a result, motor speed is directly proportional to applied voltage.

Motor Speed Curve

Motor Speed Curve

 One aspect to have in mind is that the motor speed is not entirely lineal. Each motor will have their own voltage/speed curve. One thing I can guarantee from each motor is that at very low voltages, the motor will simply not move. This is because the magnetic field strength is not enough to overcome friction. Once friction is overcome, motor speed will start to increase as voltage increase.

The following video shows the concept of speed control and offers some ideas on how this can be achieved.

 

 Motor Torque

In the previous segment I kind of described speed as having to do with the strength of the magnetic field, but this is in reality misleading. Speed has to do with how fast the magnetic field is built and the attraction/repel forces are installed into the two magnetic structures. Motor strength, on the other hand, has to do with magnetic field strength. The stronger the electromagnet attracts the permanent magnet, the more force is exerted on the motor load.

Per example, imagine a motor trying to lift 10 pounds of weight. This is a force that when multiplied by a distance (how much from the ground we are lifting the load) results in WORK. This WORK when exerted through a predetermined amount of time (for how long we are lifting the weight) gives us power. But whatever power came in, must come out as energy can not be created or destroyed. So that you know, the power that we are supplying to the motor is computed by

P = IV

Where P is power, I is motor current and V is motor voltage

Hence, if the voltage (motor speed) is maintained constant, how much load we are moving must come from the current. As you increase load (or torque requirements) current must also increase.

Motor Loading

Motor Loading

One aspect about DC motors which we must not forget is that loading or increase of torque can not be infinite as there is a point in which the motor simply can not move. When this happens, we call this loading “Stalling Torque”. At the same time this is the maximum amount of current the motor will see, and it is refer to Stalling Current. Stalling deserves a full chapter as this is a very important scenario that will define a great deal of the controller to be used. I promise I will later write a post on stalling and its intricacies.

Motor Start and Stop

You are already well versed on how to control the motor speed, the motor torque and the motor direction of rotation. But this is all fine and dandy as long as the motor is actually moving. How about starting it and stopping it? Are these trivial matters? Can we just ignore them or should we be careful about these aspects as well? You bet we should!

Starting a motor is a very hazardous moment for the system. Since you have an inductance whose energy storage capacity is basically empty, the motor will first act as an inductor. In a sense, it should not worry us too much because current can not change abruptly in an inductor, but the truth of the matter is that this is one of the instances in which you will see the highest currents flowing into the motor. The start is not necessarily bad for the motor itself as in fact the motor can easily take this Inrush Current. The power stage, on the other hand and if not properly designed for, may take a beating.

Once the motor has started, the motor current will go down from inrush levels to whatever load the motor is at. Per example, if the motor is moving a few gears, current will be proportional to that load and according to torque/current curves.

Stopping the motor is not as harsh as starting. In fact, stopping is pretty much a breeze. What we do need to concern ourselves is with how we want the motor to stop. Do we want it to coast down as energy is spent in the loop, or do we want the rotor to stop as fast as possible? If the later is the option, then we need braking. Braking is easily accomplished by shorting the motor outputs. The reason why the motor stops so fast is because as a short is applied to the motor terminals, the Back EMF is shorted. Because Back EMF is directly proportional to speed, making Back EMF = 0, also means making speed = 0.

August 5, 2009

Removing the Brakes

Filed under: Robotics — Avayan @ 11:04 pm

Wheel chairs are meant to carry somebody, usually somebody that can not walk. It should be of no surprise that in the last few decades, architectural constructions have been mandated to take this into account.  Wherever you go, there are ramps to make sure people in any form of wheel chair have access to the building in question.

This poses a problem because what if the user has to stop in one of these ramps? Sure enough, conventional wheel chairs have a brake the user can apply in situations like this. For electric wheelchairs it is no different. Except that the brake is an automatic feature the user has not to worry about.

As it turns out, both wheelchairs I managed to acquire have a solenoid based brake the controller activates whenever the motors are not meant to be moving. In other words, whenever the joystick is not actuated, the motors are disabled and right after, the brakes come up. This is an annoyance from my point of view as I am not interested in positioning my robot on a slope for long periods of time. Hence, needing a driver to be continuously engaging this 24V load as it drains my batteries is not what I had in mind. Hence, they must come up.

In this video I detail how painful it was to remove the frigging things! It should have been as easy as removing six screws but they had been glued making it basically impossible to go the easy way. The Allen thread would start slipping long before the screws started to bulge. Matters not! As you will see, a little rage at the right moment works wonders!

 

Wheel Chair Based Robotics

Filed under: Robotics — Avayan @ 10:49 pm

For a while now, I have been trying to secure a few old wheel chairs to use as big robot platforms. At first I tried searching the Craigs List, but as it turns out there is nothing better than actually asking for it! While searching, the best I could find was $200. But as soon as I asked, a chair for $75 was offered. Then a second for $150, but I actually managed to get it for $100. So for $175 I got two chairs, as opposed to one chair for $200. Looks like my large scale robot platform is in bussiness!

Why are they so cheap? As it turns out, mobility chairs are very expensive and are often subsidized by Medi Care. So Medi Care comes up with the 5K per chair and the users ride it until they become a burden. Replacing batteries is not chea! But guess what? Selling these chairs used is practically impossible as Medi Care will not subsidized used equipment. So now you have a big hunk of a chair, taking up precious space and nobody will pay what it is really worth. Enter us robotics enthusiasts, with some cash to spend on the next platform.

What will you get? Of course a chair, but this is not what we are interested in, so feel free to discard this portion of the rig as soon as you get home. You may want to hold onto it, though as they are pretty comfy and after cleaning, it may work for something else. What we can use are the two humongously large DC motors, already attached to wheels. This by itself is worth the $100.00. Inside you will also find a battery charger (it can not get more convenient than this!), up to four casters (I removed the two back ones), drained batteries (this is the only unfortunate part of the deal, as you may be stuck with a toxic piece of junk, although you can use it to buy new ones and skip some of the fees), and a controller. The controller is pretty much useles as it is wired and I just do not see a reason to employ a joystick based contraption, but you are free to differ.

The DC Motors

This is what we came looking for. These two DC motors are already attached to two awesome wheels. I always have a lot of problem with properly attaching wheels to a motor shaft, so this is a golden scenario for me. The only thing the motors have you may want to get rid of, is the brake. The brake is in place in case the wheel chair needs to stay positioned on an inclined surface. It sounds like a cool gadget but it implies you need to apply 24V at all times the motor is to move. Since I am not in the move of adding a relay per wheel and more microcontroller GPIO for this purpose, the brakes are gone. I will detail on a later post how to remove the brake.

There are four wires coming into the DC motors. Two are for the motor winding and two are for the brake mechanism. Of course, I will only use the two for the motor winding. I will soon be hooking the AE-MDL-7960 power stage boards and remote controlling the chairs. I will use the same rig I had on my R2D2 replica.

Battery Charger

When I used the R2D2, one of the hassles was removing and placing the batteries on a continuous basis. As it turns out, on R2, there was no charger for the batteries other than my car battery charger. Good thing with the wheelchair robot is the battery charger is included and I will never have to tamper with the batteries. But of course, only until they are replaced.

Chassis

There is a book out there that explains how to take the wheel chair motors and how to build the chassis. I think that if you have your own idea of how you want this to be, and are good at welding (which I am not), then that may be the way to go. But these wheelchairs have been designed to carry heavy loads! (AKA us). Why not take advantage of this?

More to come…

Older Posts »

Powered by WordPress