Friday, 13 August 2010

Lets Talk About H-bridge 3

Mosfet H bridge, is made up of 2 P Mosfets and 2 N MOsfets.

This is a P Mosfet

ImageLow at the gate will turn it On; High will turn the P Mosfet off.

Next here is a N Mosfet

Image

Low at the gate will turn N Mosfet on; low will turn it off.

Below shows a basic Mosfet H-bridge.

Image

Turning on the pair Q1 Q4 or Q2 Q3 will rotate the motor.

Q1 and Q3 on, the motor will be on a High brake

Q2 Q4 on, the motor will be low brake

Short circuit will occur if the pair Q1 Q2 or Q3 Q4 are turn on.

Mosfets are controlled by voltage present at their gate, it will be uncontrolled if the gate is disconnected. Hence it will be wise to set a default value to the Mosfet gate.

Below shows a diagram with all Mosfet gates connected to the ground by the pull down resistor. Here P Mosfet are ON (Q1 Q3), while N Mosfet are OFF (Q2 Q4) making the default state High Braking. Of course, we can make all MOsfet off as the default state, by using pull-up resistors for P Mosfet and pull down resistors for N MOsfet.

Image

How to interface the Mosfet H bridge

First, we can use a 4427 which is a driver to interface the H bridge with the microcontroller. I01 and IO3 are the inputs, IO4 IO5 outputs and IO2 ground. IO1 controls IO4,IO3 controls IO5.

Image

Below is the truth table for the H bridge operation

IO1

IO3

output

0

0

Hi brake

0

1

Q1Q4 ON

1

0

Q2Q3 ON

1

1

Low brake

Next we will use a 4428 ( also a driver ) to interface the H bridge with the microcontroller. I01 and IO3 are the inputs, IO4 IO5 outputs and IO2 ground. IO1 controls IO4, IO3 controls IO5. 4428 IO4 is an inventing output.

Image

Below is the truth table for the H bridge operation

IO1

IO3

output

0

0

Q2Q3 ON

0

1

Low brake

1

0

Hi brake

1

1

Q1Q4 ON

The advantages of these 2 designs are

  1. Only 2 inputs to control the H bridge
  2. Simple and easy to interface
  3. Eliminates short circuit combination

However, the design has a flaw, that is shoot-through will occur. The driver drives the same side of the H bridge and when driver output changes states, it will turn on both P Mosfet and N Mosfet for a brief moment, creating a short circuit path! The effect will be more serious if the motor changes states often, for example during PWM.

The 2 circuits below shows that by using 2 driver chip of each H-bridge we can eliminate shoot-through

Image

Using 2 4427 drivers, we can control each Mosfets individually. A delay can be added through software so that the shoot-through condition will not occur.

Disadvantages of this circuit iare

  1. Need 4 outputs to control 1 H bridge
  2. More expensive
  3. Short circuit might occur, and must be prevented through software.

Next a dual 4428 H-bridge.

Image

Below is the truth table for the H bridge operation

IO1

IO3

output

0

0

coast

0

1

Q2 Q3 ON

1

0

Q1 Q4 ON

1

1

Short circuit

Disadvantages of this circuit are

  1. No braking available
  2. More expensive
  3. Short circuit might occur, and must be prevented through software

There are so many types of H-bridge design and which one to use? It is all up to us to choose.

Friday, 11 June 2010

Lets Talk About H-bridge 2: Types of H-bridge ..

There are lots of different H-bridge design out there. If we catagotries h-bridge in terms of components used, there are 3 common types, namely transistor, MOSFET, and relay.

1st design

Image

Diagram below shows a H-bridge using transistors ( from previous post). The diagram shows that you need 4 output pins to control them, but the transistors in adjacent can be connected to the same output, reducng the no of output to 2. (transistors Q8 and Q2; Q7 and Q4 can be connected to gether)


Component used

1. 2 PNP transistors

2. 4 NPN transistors

3. 6 resistors, each at the base of the transistors ( There are missing in the schematic, my bad)

4. 4 flyback diodes ( my bad again =))

Truthtable

Just assuming left side is A, right side is B

A

B

motor

0

0

Coastng

0

1

Clockwise

1

0

Anti-clockwise

1

1

Short circuit!!!

**Coasting,both motor connections are not connected to anything, the motor is free to run

Advantages

No shoot thru when changing directions (??)

Can control motor speed with PWM


Disadvantages

Using 6 transistors, more costly

Not short circuit proof

Calculations need to be done in order to put transistor in saturated state ( to make transistor as a switch not amplifier).Read this for transitor calulation http://www.ermicro.com/blog/?p=423

2nd design

Image

The 2nd design , using only 2 NPN and PNP!


Components used

1. 2 PNP transistors

2. 2 NPN transistors

3. 4 resistors, each at the transistors base

4. 4 fly back diodes

Truthtable

Just assuming left side is A, right side is B

A

B

motor

0

0

Coastng

0

1

Clockwise

1

0

Anti-clockwise

1

1

Short circuit!!!


Avantages

4 transistors only = less cost

No shoot thru when changing directions (??)

Can control motor speed with PWM


Disadvantges

Not shortcircuit proof

Calculations need to be done in order to put transistor in saturated state ( to make transistor as a switch not amplifier). Read this for transitor calulation http://www.ermicro.com/blog/?p=423

3rd design

Image

The 3rd design is using relays as the main component. 2 NPN transistors are used to control the adjecents relays.


Component used

1. 4 relays

2. 8 flyback diode

3. 2 NPN transistors

4. 2 resistors

Truthtable

Just assuming left side is A, right side is B

A

B

motor

0

0

Coastng

0

1

Clockwise

1

0

Anti-clockwise

1

1

Short circuit!!!


Advantages

Relays are more rugged than transistors

Disadvantages

Relays have larger footprint, requiring more space

Abundant diodes needed 8 here, with only 4 with the 1st and 2nd design

Can't control motor speed with PWM, relay swithing speed too slow

Calculations need to be done in order to put transistor in saturated state ( to make transistor as a switch not amplifier). Read this for transitor calulation http://www.ermicro.com/blog/?p=423


4th design

This design in-corperates relays and mosfet in the H-bridge. I kinda thought of this design to overcome the disadvantage of all relay H-bridge no able to perform motor speed control with PWM. Well, the original design was to use 4 relays H-bridge, with a mosfet/ transistor controlling flow to the ground. The relay is just to control motor direction, MOSFET/ transistor to control motor speed with PWM.

However I stumble across Cytron's MD10 motor driver and guess that the schematic is as below. Very ingenius same concept , but only using 2 relays ( At the same time I'm implying that I'm slow, why didn't I thought of it!!! ). So, here we go, the 2 relay-1 mosfet H-bridge!

Image


Component used

1. 2 SPDT relays

2. 2 NPN transistors

3. P channel mosfet

4. 2 resistors

5. 1 optocoupler

6. 6 fly back diodes


Of course, I think that it is not necessary to use an opto couple to control the MOSFET. A transistor, mosfet driver or another mosfet might be able to do the job? You can also replace the MOSFET with a transistor, if you like , I think it will still be able to do the job!

Image

Truthtable

Just assuming left side is A, right side is B

A

B

motor

0

0

Brake high

0

1

Clockwise

1

0

Anti-clockwise

1

1

Brake low

** motor can be electrically brake when its 2 terminals are connect together. Brake high, means motor terminals are both connected to Vcc; Brake low, motors terminals are connected to gnd.

Advantages

Relays are more rugged than transistors

No short circuit mode!!!

Can control motor speed with PWM

Disadvantages

Relays have larger footprint, requiring more space

Abundant diodes needed6 here, with only 4 with the 1st and 2nd design

Well , that's all for now, there are still H-bridge using MOSFET, we'll keep that for the next time =)

Monday, 31 May 2010

Lets Talk About H-bridge 1: Why PNP-NPN? why not NPN only?





Dc motor can rotate in clockwise and counter-clockwise, just by switching the voltage polarity applied to the motor, and this is what a H-bridge is for.

I've written a few unworthy post 6 months ago, H-bridge 1, H-bridge 2, H-bridge 3. Looking back at the posts, my writting sucks and I made bad conclusions. I leave the review of my previous H-bridge posts to another day.

ImageHave you ever wonder why h-bridge is made up of a pair of PNPs and NPNs? turning off a PNP can be quite troublesome, especially when the MCU voltage is at 5V, you'll need to disconnect the PNP base or apply 12v to it so that Emitter - Base voltage is no more than 0.7V.

so why don't we use an all NPN transistors H-bridge, as seen below?

ImageYou'll just need to apply a 0.7 voltage at each base to turn it ON, a MCU can easily handle it.
On the surface, it looks simple to feasible. However n closer inspection you'll notice that the 0.7 voltage is referring to the Base-Emitter voltage.
Image
There will not be a problem for the bottom 2 transistors, as Vbe is the voltage from base to gnd (emitter connected to gnd).The problem arises when you try to turn on the top transistors. The Vbe needs to be 0.7V, but to achieve that, the voltage needed to the base, in respect to gnd would be

Voltage_Base= Vbe + voltage across motor + Vce of bottom transistor.
Assuming Vbe = 0.7 , M0tor voltage = 10, Vce = 0.8
Voltage_Base = 0.7 + 10 +0.8
= 11.5V

Essentially , you'll need to apply a freaking 11.7v to turn the top NPN transistors on.

Comparing NPN and PNP H-bridge.
With the PNP-NPN design, you'll have the option of disconnecting the PNP base to turn it off; NPN only design, you have to apply 11.5v to the base to turn it on, making it a little troublesome to implement.

Hence PNP-NPN design will be easier design! Wait, this is a rather incomplete conclusion to be made. Because the H bridge presented above isn't complete to be used together with MCU.

Turning on a PNP isn't hard, you just need to bring it to ground, but disconnecting it you'll need something extra. As seen in the diagram below, 2 additional NPN transistors are needed. Turning on NPN Q7, will bring PNP Q1's base to ground , and turning it on; while PNP Q1 will disconnect when, NPN Q7 is turned off.

Image
For an all NPN H-bridge, you also just need 2 more NPN transistors. When NPN Q7 is off, NPN Q1 will be on (see red arrow); turning on NPN Q7 will bring Q1 base to gnd, shutting it off. Q7 and Q1 are like inverter, one on the other will be off, vise verse.

ImageEither PNP-NPN or all NPN H-bridge they seem equal ( all using 6 transistors) So, why all NPN h-bridge aren't really common? Could it be that, it is common, just that I didn't do enough research??? For now it is still a mystery!


** All these are just theoretical ideas, based to diagrams drawn, no practical experiments were conducted. So Any mistakes, you are welcome to tell me!







Sunday, 30 May 2010

I'm back

I've abandoned this poor blog.
Ever since I started writing this blog, the no of post I've written has been inversely proportional to time.

Every now and then, I'll receive e-mail from Sitemeter, I used to have an average of 1 hit per day, that particular 1 hit came from me, how pathetic ; now the average hits per day is 0, super pathetic!


Oh well, the man point here is not to talk about the hits.(Who reads this, besides me? )
Instead, from now onwards, I'll be using this blog as my Final Year Project Weekly Logbook.
Ideas, new discovery, progress and thoughts regarding my FYP will be record here.

Just thought of something interesting! I'll add a countdown timer, what a brilliant idea =).

further note: My project deadline is either before or during Xmas week, So the I'll just use a Xmas countdown timer!

Sunday, 17 January 2010

Bye AVR....

When was the last time I program my AVR? Well that was a very very long time ago..

I started to learn AVR so that I can use it for my final year project and I don't need to pay RM 400 to learn it from someone.Well, my plan failed!!! I started off quite well, but the plan just dies down slowly.

Actually, I also realized that programming is easy, but putting the code into practical use is a whole different story.

By the way, my atmega168 is "dead". messed up with the fuse bit when trying to config it to use external clock. However, there is still hope to bring it back to life, by supplying a 1Mhz square wave to the XTAL1 pin, and I might be able to re-config it, as stated in AVRfreak.

However, I'm leaving these aside. I'm packing up my AVR to make way for PIC. which I'll be paying Rm450 to learn it!!!

Some photos from a switching regulator

Image
Image
naked switching regulator

Image
The bottom layer og the power supply. Assuming to be the control circuitImage
close up view of the regulator

Image
Look at the size of that capacitor (right)!!