Speed control of DC motors

advertisement

Objective:

Design a car which will have to follow a black line that will be processed by lineal camera, the image process will be made by a powerful microcontroller which is the heart for the smart car.

Summary:

We need to design the smart car, and we need to know first how to make it, because, there is a protocol we have to follow, the freescale company provided us the microcontroller, the structure car, DC motors, servo motor, and the lineal camera, and we have to use them to create our smart car.

About the microcontroller we are going to use a Bolero MCP5604b which is the more important part of the smart car, we had before some essential preparatory courses for the knowledge of the mentioned microcontroller.

We need also assemble the structure car, only some pieces like mount the servo motor, and the camera, etc, and we need to create our own model car which one is going to show the best performance as good as it can.

Diagranma aqui!!!!!!!!!!!!!!!!! Este consiste en dar un pequeño diagram de bloques de todo el sistema

Introduction:

How did we make the smart car? Well, in this report we are going to show how we made it, we needed to create different stages; we’ll mention them in this report, but first, the principal objective for the smart car is to follow a line as fast and efficient as the car can, with a minimal error, there will be a track with a black line that the smart car will has to follow automatic way.

Actually, we’ll show how we made the smart car below…

Otro diagrana aqui!!!!!!! Este consiste en dar la explicacion de como llevamos acabo el carro delde el principio

Speed control of DC motors

It consists of two DC motor and its respective coupling circuit to the microcontroller. It’s also has two mercury switches that indicate a rise in speed when going up the ramp or going down the ramp.

Servo motor control

Here, we explain how we make the driver that we needed to use in order to indicate to the smart car when turn on the left or when turn on the right, or just follow the line straight

Line detection by lineal camera

We are going to explain the behavior of the lineal camera, how it works and responds when it sees the line, and how interprets them for a better development for the smart car.

-----------------------------------------------------------------------------------------------------------------------------------

Speed control of DC motors

The purpose of a motor speed controller is to take a signal representing the demanded speed, and to drive a motor at that speed. The controller may or may not actually measure the speed of the motor. If it does, it is called a Feedback Speed Controller or Closed Loop Speed Controller, if not it is called an Open Loop Speed Controller. Feedback speed control is better, but more complicated, and may not be required for a simple control of DC motor design.

Motors come in a variety of forms, and the speed controller's motor drive output will be different dependent on these forms. The speed controller presented here is a simple and cheap design, which one can be made easily.

Why not use an H-Bridges in order to control of DC motor for the smart car?

Well, let’s see something about H-Bridges:

An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H bridges are available as integrated circuits, or can be built from discrete components.

Structure of an H bridge (highlighted in red)

The term H Bridge is derived from the typical graphical representation of such a circuit. An H bridge is built with four switches (solid-state or mechanical). When the switches S1 and S4

(according to the first figure) are closed (and S2 and S3 are open) a positive voltage will be applied across the motor. By opening S1 and S4 switches and closing S2 and S3 switches, this voltage is reversed, allowing reverse operation of the motor.

The two basic states of an H bridge

Using the nomenclature above, the switches S1 and S2 should never be closed at the same time, as this would cause a short circuit on the input voltage source. The same applies to the switches S3 and S4. This condition is known as shoot-through.

So, if we compare the H-bridge with a transistor configuration, we concluded that is better use a power transistor than H-bridge, because the smart car does not need run forwards and backwards.

Theory of DC motor speed control

The speed of a DC motor is directly proportional to the supply voltage, so if we reduce the supply voltage from 12 Volts to 6 Volts, the motor will run at half the speed.

The speed controller works by varying the average voltage sent to the motor. It could do this by simply adjusting the voltage sent to the motor, but this is quite inefficient to do. A better way is to switch the motor's supply on and off very quickly. If the switching is fast enough, the motor doesn't notice it, it only notices the average effect.

Now imagine a light bulb with a switch. When you close the switch, the bulb goes on and is at full brightness, say 100 Watts. When you open the switch it goes off (0 Watts). Now if you close the switch for a fraction of a second, and then open it for the same amount of time, the filament won't have time to cool down and heat up, and you will just get an average glow of 50 Watts. This is how lamp dimmers work, and the same principle is used by speed controllers to drive a motor. When the switch is closed, the motor sees 12 Volts, and when it is open it sees 0 Volts. If the switch is open for the same amount of time as it is closed, the motor will see an average of 6 Volts, and will run more slowly accordingly.

As the amount of time that the voltage is on increases compared with the amount of time that it is off, the average speed of the motor increases.

This on-off switching is performed by power transistors. A power transistor is a device that can turn very large currents on and off under the control of a low signal level voltage.

The time that it takes a motor to speed up and slow down under switching conditions is dependent on the inertia of the rotor (basically how heavy it is), and how much friction and load torque there is. The graph below shows the speed of a motor that is being turned on and off fairly slowly:

You can see that the average speed is around 150, although it varies quite a bit. If the supply voltage is switched fast enough, it won’t have time to change speed much, and the speed will be quite steady. This is the principle of switch mode speed control. Thus the speed is set by PWM –

Pulse Width Modulation.

Pulse-width modulation (PWM)

Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a commonly used technique for controlling power to inertial electrical devices, made practical by modern electronic power switches.

The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast pace. The longer the switch is on compared to the off periods, the higher the power supplied to the load is.

The PWM switching frequency has to be much faster than what would affect the load, which is to say the device that uses the power. Typically switchings have to be done several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.

The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on.

The main advantage of PWM is that power loss in the switching devices is very low. When a switch is off there is practically no current, and when it is on, there is almost no voltage drop across the switch. Power loss, being the product of voltage and current, is thus in both cases close to zero.

PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle.

PWM has also been used in certain communication systems where its duty cycle has been used to convey information over a communications channel.

PWM frequency with a power transistor

The frequency of the resulting PWM signal is dependent on the frequency of the ramp waveform.

What frequency do we want? This is not a simple question. Some pros and cons are:

•Frequencies between 20Hz and 18kHz may produce audible screaming from the speed controller and motors - this may be an added attraction for your smart car!

•RF interference emitted by the circuit will be worse the higher the switching frequency is.

•Each switching on and off of the speed controller results in a little power loss. Therefore the greater the time spent switching compared with the static on and off times, the greater will be the resulting 'switching loss' in the power transistor.

•The higher the switching frequency, the more stable is the current waveform in the motors. This waveform will be a spiky switching waveform at low frequencies, but at high frequencies the

inductance of the motor will smooth this out to an average DC current level proportional to the

PWM demand. This spikiness will cause greater power loss in the resistances of the wires,

MOSFETs, and motor windings than a steady DC current waveform.

This third point can be seen from the following two graphs. One shows the worst case on-off current waveform, the other the best case steady DC current waveform:

Both waveforms have the same average current. However, when we work out the power dissipation in the stray resistances in our motor and speed controller, for the DC case: and for the switching case, the average power is

So in the switching waveform, twice as much power is lost in the stray resistances. In practice the current waveform will not be square wave like this, but it always remains true that there will be more power loss in a non-DC waveform.

Transistor Circuits

Using a transistor as a switch

When a transistor is used as a switch it must be either OFF or fully ON. In the fully ON state the voltage VCE across the transistor is almost zero and the transistor is said to be saturated because it cannot pass any more collector current Ic. The output device switched by the transistor is usually called the 'load'.

The power developed in a switching transistor is very small:

In the OFF state: power = Ic × VCE, but Ic = 0, so the power is zero.

In the full ON state: power = Ic × VCE, but VCE = 0 (almost), so the power is very small.

This means that the transistor should not become hot in use and you do not need to consider its maximum power rating. The important ratings in switching circuits are the maximum collector current Ic(max) and the minimum current gain hFE(min). The transistor's voltage ratings may be ignored unless you are using a supply voltage of more than about 15V.

Protection diode

If the load is a motor, relay or solenoid (or any other device with a coil) a diode must be connected across the load to protect the transistor from the brief high voltage produced when the load is switched off. The diagram shows how a protection diode is connected 'backwards' across the load, in this case a relay coil.

Current flowing through a coil creates a magnetic field which collapses suddenly when the current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across the coil which is very likely to damage transistors and ICs. The protection diode allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. This prevents the induced voltage becoming high enough to cause damage to transistors and ICs.

Connecting a transistor to the output from an IC

Most ICs cannot supply large output currents so it may be necessary to use a transistor to switch the larger current required for output devices such as lamps, motors and relays.

A transistor can also be used to enable an IC connected to a low voltage supply (such as 5V) to switch the current for an output device with a separate higher voltage supply (such as 12V). The two power supplies must be linked, normally this is done by linking their 0V connections. In this case you should use an NPN transistor.

A resistor RB is required to limit the current flowing into the base of the transistor and prevent it being damaged. However, RB must be sufficiently low to ensure that the transistor is thoroughly saturated to prevent it overheating, this is particularly important if the transistor is switching a large current (> 100mA). A safe rule is to make the base current IB about five times larger than the value which should just saturate the transistor.

Choosing a suitable NPN transistor

The circuit diagram shows how to connect an NPN transistor, this will switch on the load when the

IC output is high. If you need the opposite action, with the load switched on when the IC output is low (0V) please see the circuit for a PNP transistor below.

The procedure below explains how to choose a suitable switching transistor.

1. - The transistor's maximum collector current Ic(max) must be greater than the load current Ic. load current Ic = supply voltage Vs load resistance R

L

2. - The transistor's minimum current gain hFE(min) must be at least five times the load current Ic divided by the maximum output current from the IC. h

FE

(min) > 5 ×

Load current Ic

Max IC current

3. - Choose a transistor which meets these requirements and make a note of its properties:

Ic(max) and hFE(min). .

4. - Calculate an approximate value for the base resistor:

R

B

= Vc × h

FE

where Vc = IC supply voltage

5 × Ic (in a simple circuit with one supply this is Vs)

For a simple circuit where the IC and the load share the same power supply (Vc = Vs) you may prefer to use:

RB = 0.2 × RL × hFE

Then choose the nearest standard value for the base resistor.

5.- Finally, remember that if the load is a motor or relay coil a protection diode is required.

Example

The output from a 4000 series CMOS IC is required to operate a relay with a 100 coil.

The supply voltage is 6V for both the IC and load. The IC can supply a maximum current of 5mA.

1. - Load current = Vs/RL = 6/100 = 0.06A = 60mA, so transistor must have Ic(max) > 60mA.

2. - The maximum current from the IC is 5mA, so transistor must have hFE(min) > 60 (5 ×

60mA/5mA).

3. - Choose general purpose low power transistor BC182 with Ic(max) = 100mA and hFE(min) =

100.

4. - RB = 0.2 × RL × hFE = 0.2 × 100 × 100 = 2000. so choose RB = 1k8 or 2k2.

5. - The relay coil requires a protection diode.

-

Design of control DC motor

We are going to use a Tip120 power transistor (you can see the data sheet at the end of the report), but before to continue with the design, we need to know how to realize the correct calculate of the configuration circuit and also know about the transistor.

We need to saturate the transistor to use it such a switch and also we need to know how much current the motor needs in order to proceed with the calculate, so as we can see in the transistors datasheet, around of 20mA we need to obtain a 5mA of Ic, enough for the motor.

To calculate the RB, we need to use the below equation:

𝑅𝐡 ≤

VCC − VBE

𝐼𝐡 and if we replace the values that we know, VCC=7.2v (battery voltage), VBE=0.7 and IB=20mA:

𝑅𝐡 ≤

7.2 − 0.7

20π‘šπ΄

RB=325Ohms and we are going to use a 330 Ohms.

Some diagrams illustrating how to use the tip120 transistor to control 7.2v (actually up to 60v DC)

PCB design

Once known the circuit diagram, we're going to create a PCB with a program who it can simulate circuits and also create PCBs, this program is called Proteus.

As this card handles more power is taken into consideration in the design of the PCB the increasing of the width of the tracks that control high signals. The PCB design is performed using Proteus

Ares.

We need to make the circuit in Proteus Isis and become it to PCB with Proteus Ares.

The below image shows the circuit in ISIS:

And these other ones show the PCB in ARES:

Servo motor control

The servo motor is an electric actuator that can be positioned in a desired angle from 0° to 180°.

The operation of a typical servo motor is explained in Figure 1; depending on the duty cycle of the control signal, the servo motor will rotate to a specific position.

Figure 1. Controlling a Servo motor

The signal that controls the servo motor is given by series of pulses (Figure 1) with a period of 200 ms or 5 Hz and the duration depends on the required direction. For most servo motors, pulses of 1 ms represent a 0 degree turn, and 2 ms represent a 180 degree turn, but it can vary. This information shall be specified in the data sheet of each servo motor and can be tested by trying different PWM signals. To send the signal by software, the MCU must generate a PWM signal with a duty cycle of 0.5% to 1% and a period of 200 ms. It is recommended to elaborate a function that has a position parameter and sets the servo motor to the desired position to simplify the code.

Line detection by lineal camera

This application note explains how lineal camera works and how it can be used for the specific application of following a line for the Smart Car. We will use the camera TSL1401R−LF.

The TSL1401R−LF linear sensor array consists of a 128 × 1 array of photodiodes, associated charge amplifier circuitry, and an internal pixel data-hold function that provides simultaneous-integration start and stop times for all pixels. The pixels measure 63.5 μm (H) by 55.5 μm (W) with 63.5-μm center-to-center spacing and 8-μm spacing between pixels. Operation is simplified by internal control logic that requires only a serial-input (SI) signal and a clock.

Some of the advantages of using this camera are the following:

• Simple and easy to use

• Frequency of capture can be manipulated by the user

• Enough definition for line following application

• Removable and interchangeable lens for different resolutions

Besides the above benefits, the only disadvantage is the output signal of the camera is completely analog, which means the user has to be creative, to process this signal in order to make it

“understandable”. This document provides two different methods to process this signal.

Camera signal interpretation

How is light interpreted? As mentioned before, the camera is a combination of an image sensor

(linear in this case) and a lens. The light that bounces from the environment enters through the lens, and the last one deflects light into the sensor. The sensor consists of a microscopic array of capacitors that gain charge depending on light intensity, therefore all pixel charge at the same time and the sensor releases each pixel value in one output signal one after the other until all pixel charges are released. The following image illustrates the process.

Figure 1. Imaging process in the lens

Figure 2. One caption example

Because the camera is using a linear sensor it is impossible to gain a full view of the panorama in a single shot, therefore it only takes one line of the full panorama as shown in the next image. Here, the line to be captured is completely dependent on the distance to the lens as shown in Figure 2.

Finally this image is released in an analog signal as shown in Figure 3.

Figure 3. Output signal from parallax camera

Signal processing

For normal operation of the camera, the user needs to take care of the following signals only:

• CK (clock)

• SI (serial input)

• AO (analog output)

Where CK and SI are camera inputs and AO is a camera output.

As mentioned before, the user can manipulate the frame speed of the camera by adjusting CK and

SI signals. Faster is the CK frequency, the faster the camera releases the pixel values, and the closer each SI is from one another the faster each frame capture occurs. It is important to understand, the faster the frame capture occur the lower each pixel gain charge. This leads to another important factor, the “integration time”.

Integration time (Figure 4) is the time the pixels have to complete its charge. With very long integration time, the pixels will be saturated even if there is low light intensity in the environment, on the other hand with very short integration time the pixel will not gain charge even if there is excessive light on the environment.

As it can be seen in Figure 4, after 18 clock cycles, the pixels begin to charge back again. After 129 clock cycles all pixels are released from the camera, this means, from that moment it can send another SI pulse to release AO signal again; but as mentioned before longer the cycle, the pixels will charge more and user will get better pixel quality.

Signal processing

Figure 4. Integration time

These three signals (CK, SI and AO) are synchronized (Figure 5), so the SI and CK signals will be adjusted to start the camera operation correctly:

1. Both signals must have the same pulse width

2. Both must be perfectly aligned out of phase for half pulse

3. As a result AO signal will be perfectly aligned with CK.

Figure 5. SI and CK signals synchronized to get AO

NOTE

Once all the 129 clock cycles are passed, it is very important to shut down the CK signal, this will help the pixels to charge much better than if CK signal is on forever. For more information about

the basic operation of the camera module look at: http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/TSL1401-DB_manual.pdf

Download