Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Controlling a H-Bridge with PWM from a PIC16F887

Status
Not open for further replies.

santais

Junior Member level 1
Joined
Jan 14, 2011
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,474
Building a H-Bridge using PWM from a PIC16F887

Hi Guys.

I'm currently working on a school project, where we are trying to build a Line Following Robot. So far I'm able to control duty cycle of the PWM signal, with the use of 3 different sensors. So far so good. The last thing I'm missing, is to get the H-bridge working, and to be honest, I'm completely lost here.

I've tried different types of H-bridges, where I found the circuit on the internet. One of them worked, if I used the voltage from an power supply and regulated it from that. However, no success with the pic itself. Here's the transistors and other hardware, which is being used:

PIC 16F887 with a duty cycle varying from 0 - 200 (8 bit PWM. Not using 255, because of the chance to burn off the motor).

3 V DC motor x2.

2 x TIP121 and 2x TIP127 transistors.

A Power supply VDD at 5v

The motor has to be able to run both forward and backward. Today I tried with this setup:



However, the voltage on the pin to the motor was just high all the time, and my PWM input didn't have any effect at all.

Thanks on beforehand :) Hope that some of you have an idea, on how to get this running. It's an exam project, so it's quite important I get it running ;)
 
Last edited:

enjunear

Advanced Member level 3
Joined
Dec 21, 2010
Messages
960
Helped
309
Reputation
618
Reaction score
303
Trophy points
1,343
Location
USA, midwest
Activity points
9,749
Since your design shows BJT's, you'll need to drive a fair amount of current into the base to get them to go into saturation (like a switch in the "ON" position... low resistance from colelctor to emitter). The microcontroller probably can't source enough current to turn them on fully.

Option 1) Try swapping the single BJT's for Darlington-pair equivalents. Darlington's are basically two BJTs in one package, which give you a much higher current-gain (base current -> collector current).

Option 2) Put in MOSFETs, instead of BJTs. FETs can be used as VOLTAGE-controlled switches, where the BJT's are being used as CURRENT-controlled switches. Since they only need voltage to make them change operation, you won't see the current-limiting problem that the BJTs may be having. (see kabiru's circuit)
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
Re: Building a H-Bridge using PWM from a PIC16F887

3 V DC motor x2.
2 x TIP121 and 2x TIP127 transistors.
The schematic shows 4 NPN transistor but you say 2 x TIP121 which are NPN and 2x TIP127 which are PNP.
How are your transistors connected?
they should be connected like this A simple H-Bridge design « PocketMagic , also a PNP will turn on with LOW and the NPN with HIGH or you can use the two extra transistors in the schematic and drive it with just 2 inputs.

Alex
 

BradtheRad

Super Moderator
Staff member
Joined
Apr 1, 2011
Messages
13,888
Helped
2,755
Reputation
5,508
Reaction score
2,664
Trophy points
1,393
Location
Minneapolis, Minnesota, USA
Activity points
103,621
By using NPN's in the upper section you're making their bias current go through the load and another transistor. This is bound to result in glitchy behavior since the bias controls transistor operation.

Consider using PNP's at the top. Their bias is referenced to the positive terminal. You'll get stable behavior because they'd have a direct connection to the positive supply rail.

Also note that PNP's turn on when bias terminal is grounded. Your control device upstream must sink current to do this.

If you use mosfets, then consider P-channel at the top. The bottom mosfets can be N-channel.
 

timi

Junior Member level 2
Joined
Feb 28, 2006
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,422
hi all,

i am too loking to make the pic16F887 as a H bridge controller till now i got the example from ccs. but as the H brdge needs a dead time i dont know how to make it with the pic. any suggestion ??? thanks all fro helping.

BR's

Shpetim Aliaj
 

kabiru

Banned
Joined
Nov 22, 2009
Messages
503
Helped
160
Reputation
320
Reaction score
146
Trophy points
1,323
Location
Nigeria
Activity points
0
It's the normal sine pwm you know but it's not necessary to used pwm you can still your normal square wave using your pushpull oscilators.
 

neddie

Full Member level 5
Joined
Feb 23, 2010
Messages
257
Helped
41
Reputation
82
Reaction score
39
Trophy points
1,308
Location
South Africa
Activity points
3,042
Re: Building a H-Bridge using PWM from a PIC16F887

You won't be able to drive the top transistors without some cct to boost the driive voltage above the supply. Look for a half bridge driver cct. IR2104 comes to mind.
Replacing the top 2 transistors with PNP's could also work.
Cheers
Rob
 

gedza

Junior Member level 2
Joined
Nov 3, 2010
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,467
Re: Building a H-Bridge using PWM from a PIC16F887

can you please show the code for the pic.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top