PIC16F88 problem controlling hbridge

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Sorry for double thread, i think this thread better suits here. So firstly hello everyone :) And i would be very grateful if someone could help me. So i writted simple program to drive motor to one side (just bsf portb,0). It works for several seconds but after that it stops. Without uC hbridge works great without problems. But when i connected uC.... so after motor turns off i tryed to touch uC and it was very hot :/
--------------------------------------------------------------------------
Hmm i tested uC outputs if its working properly with Led, it works good. but when i realized that if i touch h-bridge wire which controls motor direction, motor starts and i can control direction only with my fingers :D i think its quite odd...
---------------------------------------------------------------------------
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Please attach your schematics/diagrams to your initial post instead of linking to them on another hosting site. I could not access the server that they are hosted on.

Use the "Edit" button, then "Go Advanced" (below the text box) and then "Manage Attachments"

[eta]
Never mind, they fixed the network problem and I attached them myself.

You're not going to get good results out of it the way you've connected up to your uC.

You need to have independent control of each half H-bridge.
You can keep the low-side MOSFETs on for as long as you like, but the high-side MOSFETs will have trouble after maybe 50mS-100mS as their caps get drained. The only way to re-charge the high side caps (C5, C6) is to turn off the high-side MOSFET for a brief period until the caps recharge via the diodes.

C5 and C6 are too large. Swap C5 with C3, and C6 with C4. Replace C7 and C8 with 100nF metal poly or ceramic caps.

It would also be a good idea to have 100nF (0.1uF) metal poly or ceramic caps in parallel with C5 and C6, as close to the bridge drivers as you can get them.

You also need a 100nF cap across the supply of your uC.
 

Attachments

Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Please attach your schematics/diagrams to your initial post instead of linking to them on another hosting site. I could not access the server that they are hosted on.

Use the "Edit" button, then "Go Advanced" (below the text box) and then "Manage Attachments"

[eta]
Never mind, they fixed the network problem and I attached them myself.

You're not going to get good results out of it the way you've connected up to your uC.

You need to have independent control of each half H-bridge.
You can keep the low-side MOSFETs on for as long as you like, but the high-side MOSFETs will have trouble after maybe 50mS-100mS as their caps get drained. The only way to re-charge the high side caps (C5, C6) is to turn off the high-side MOSFET for a brief period until the caps recharge via the diodes.

C5 and C6 are too large. Swap C5 with C3, and C6 with C4. Replace C7 and C8 with 100nF metal poly or ceramic caps.

It would also be a good idea to have 100nF (0.1uF) metal poly or ceramic caps in parallel with C5 and C6, as close to the bridge drivers as you can get them.

You also need a 100nF cap across the supply of your uC.
Hmh my bad it worked only for one time, another times motor rotates for sec. and stops, and still uC gets very hot. About 100nF across the supply you ment to place it betwen VDD VSS ?
 

SgtWookie

Joined Jul 17, 2007
22,230
I didn't notice that you omitted recirculation diodes across the bridge. You need one per MOSFET.

Use fast-recovery diodes, such as FR303's or the like. 1N400x and 1N540x are NOT suitable.

Yes, place a 100nF cap across the PIC's Vdd/Vss pins.

Did you measure the voltage across Vdd/Vss while it's running? You may find that it's more than 5v.
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
I didn't notice that you omitted recirculation diodes across the bridge. You need one per MOSFET.

Use fast-recovery diodes, such as FR303's or the like. 1N400x and 1N540x are NOT suitable.

Yes, place a 100nF cap across the PIC's Vdd/Vss pins.

Did you measure the voltage across Vdd/Vss while it's running? You may find that it's more than 5v.
Yeah i measured it. 5.3V hmh one per mosfet so i need to place diode between Drain and Source ? this one is quite good for circuit BYV28-200 ( http://www.datasheetcatalog.org/datasheet2/4/09e5k80ou8d2geuqy0x0ehsur47y.pdf ) y ? :) Sorry for so many easy questions just i am curious :)
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Please keep it clean; this is a family-oriented board.

Yes, it gets connected between the source and the drain, cathode towards +V, anode towards ground.

The BY255 is not a fast-recovery type diode; therefore it is not suitable.
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Please keep it clean; this is a family-oriented board.

Yes, it gets connected between the source and the drain, cathode towards +V, anode towards ground.

The BY255 is not a fast-recovery type diode; therefore it is not suitable.
I got some problems as always :| i buyed BYV28-200 and programmed uC with this code which i find in net. once my motor rotated as it should, but it's one of ten times... i dont know what to do anymore :/
ANSEL = 0 ' Configure all pins to digital
OSCCON = $60 ' Sets the internal oscillator in the
' 16F88 to 4 MHz

'-------------Main Code------------

loop:

pwm 0,255,200 ' Pulse sent to PORTB.0 at a duty 'value of 255(100% duty cycle) for 200 cycles.

pwm 0,190,200 ' Pulse sent to PORTB.0 at a duty 'value of 190(75% duty cycle) for 200 cycles.

pwm 0,190,200 ' Pulse sent to PORTB.0 at a duty 'value of 140(55% duty cycle) for 200 cycles.

goto loop ' Jump to loop label and start all over

end
the code is working, tested it on led.

I measured those outputs to motor and i got from bow high... why it is happenging ?
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Try this instead:

loop:
pwm 0,242,255 ' Pulse sent to PORTB.0 at a duty 'value of 255(95% duty cycle) for 255 cycles.
pwm 0,127,255 ' Pulse sent to PORTB.0 at a duty 'value of 127(50% duty cycle) for 255 cycles.
pwm 0,012,255 ' Pulse sent to PORTB.0 at a duty 'value of 12 ( 5% duty cycle) for 255 cycles.
pwm 0,127,255 ' Pulse sent to PORTB.0 at a duty 'value of 127(50% duty cycle) for 255 cycles.

goto loop ' Jump to loop label and start all over
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Try this instead:

loop:
pwm 0,242,255 ' Pulse sent to PORTB.0 at a duty 'value of 255(95% duty cycle) for 255 cycles.
pwm 0,127,255 ' Pulse sent to PORTB.0 at a duty 'value of 127(50% duty cycle) for 255 cycles.
pwm 0,012,255 ' Pulse sent to PORTB.0 at a duty 'value of 12 ( 5% duty cycle) for 255 cycles.
pwm 0,127,255 ' Pulse sent to PORTB.0 at a duty 'value of 127(50% duty cycle) for 255 cycles.

goto loop ' Jump to loop label and start all over
It didnt worked, hmh need to test on another not modified board, maybe it will work :) nope its same problem... i got both outputs to motor high...
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
So if i understand correctly i need to play with PWM ? or maybe where is another problem ? like i read once that that boost capacitor wont work because to charge it its negative pin should be periodical connected to ground, is it true ? :) if it's when how i should to correct this ?
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, wait a minute.

You're using RB0 and RB1 as the outputs from the PIC to the bridge drivers, right?

So, why is just RB0 getting PWM'ed?

You'd have to PWM both RB0 and RB1 at the same time, but with opposite ratios.

What Basic compiler are you using?
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
OK, wait a minute.

You're using RB0 and RB1 as the outputs from the PIC to the bridge drivers, right?

So, why is just RB0 getting PWM'ed?

You'd have to PWM both RB0 and RB1 at the same time, but with opposite ratios.

What Basic compiler are you using?
Oh so that's where problem i didnt knew that i need to control both at the same time :| "PicBasic PRO 2.45"

ANSEL = 0
OSCCON = $60
TRISA = %00000111
TRISB = %00000000

'--------------Main Code----------

loop:
PWM PORTB.0,242,255
PWM PORTB.1,012,255
PWM PORTB.0,127,255
PWM PORTB.1,127,255
PWM PORTB.0,012,255
PWM PORTB.1,242,255
PWM PORTB.0,127,255
PWM PORTB.1,127,255

GOTO loop
END
is it ok ? or its far far away from truth ? :>
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
So, try this:
(Not sure if the GPIO/TRISIO/ADCON statements are correct; I don't have a PIC16F88 datasheet)
Rich (BB code):
GPIO.0 = 1
GPIO.1 = 1
TRISIO = %000011
ADCON1 = 7

MSpause var byte          ' Milliseconds between steps, suggest 10 to 50, even numbers only
Ctr    var byte		  ' Used in loop for 50% pwm
Left   var PORTB.0        ' Don't know which is which, so declare one as left.
Right  var PORTB.1        ' By default, the other is right.

MSpause = 10		' initialize MSPause

Loop:
       '  
       High Left	' Start stepping left...
       Low  Right       ' Set them opposite
       Pause MSpause	' wait a bit
       ' 
       For Ctr = 1 to MSpause >> 1  '  
          Low Right
          High Left
          Pause 1
          High Right
          Low Left
          Pause 1
       next Ctr
       '
       Low Left
       High Right
       Pause MSpause	' wait a bit
       For Ctr = 1 to MSpause >> 1  '  
          High Right
          Low Left
          Pause 1
          Low Right
          High Left
          Pause 1
       next Ctr
       goto Loop:      ' do forever
 

SgtWookie

Joined Jul 17, 2007
22,230
Oh so that's where problem i didnt knew that i need to control both at the same time :| "PicBasic PRO 2.45"

is it ok ? or its far far away from truth ? :>
I haven't used PicBasic Pro, and I don't know if your PIC16F88 has the hardware necessary to PWM two ports at the same time.

However, you will need a delay between each step:
SYMBOL delay 10

loop:
PWM PORTB.0,242,255
PWM PORTB.1,012,255
PAUSE delay
PWM PORTB.0,127,255
PWM PORTB.1,127,255
PAUSE delay
PWM PORTB.0,012,255
PWM PORTB.1,242,255
PAUSE delay
PWM PORTB.0,127,255
PWM PORTB.1,127,255
PAUSE delay
GOTO loop
END
 

SgtWookie

Joined Jul 17, 2007
22,230
The way you have the thing wired makes it hard to do anything right.

You really need at least the SD pins connected to an output. Otherwise, you will probably get shoot-through, and there is no provision to provide dead time.
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
The way you have the thing wired makes it hard to do anything right.

You really need at least the SD pins connected to an output. Otherwise, you will probably get shoot-through, and there is no provision to provide dead time.
I am very grateful you that you have time and patience with me... my head is blowing up... :) connecting SD to an output you mean to uC ?
 

SgtWookie

Joined Jul 17, 2007
22,230
Yes. Right now, you have both IR2110 SD (shutdown) pins wired to ground.
You should wire them together, and connect them to an output pin on the PIC.

Otherwise, you will likely burn up MOSFETs.

When you first enter the program, put SD high; that will turn off all of the MOSFETs.

It would be a good thing to raise SD before changing the state of 0 or 1, and then lowering SD again. Unfortunately, it is not clear how long these PICbasic Pro instructions take to execute. It would be best to wait just long enough to ensure that the MOSFETs were turned OFF before proceeding. The shortest built-in time delay you have appears to be 1ms.
 
Top