PIC16F88 problem controlling hbridge

Thread Starter

aGpLT

Joined Jan 21, 2010
128
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.
Ok iam done upgrandind my board. And writted program, but still its not good :)

' RB0 and RB1 are for PWM
' RB2 is for SD

ANSEL = %00000000 ' All pins changed from analogue to digital
OSCCON = $60 ' Internal clock setted to 4Mhz
TRISB = %00000000 ' All PORTB pins are outputs.
HIGH PORTB.2 ' Turn on sd pin to shutdown ir2110

start:
Pause 100 ' Delay for 100ms waiting for mosfets to settle
low PORTB.2 ' Turned off sd pin
Pause 100 ' delay 100ms
PWM PORTB.0,242,255 ' Pulse sent to PORTB.0 at a duty 'value of 242(95% duty cycle) for 255 cycles.
PWM PORTB.1,012,255 ' Pulse sent to PORTB.0 at a duty 'value of 12(5% duty cycle) for 255 cycles.
PAUSE 100
PWM PORTB.0,127,255 ' 50%
PWM PORTB.1,127,255 ' 50%
PAUSE 100
PWM PORTB.0,012,255 ' 5%
PWM PORTB.1,242,255 ' 95%
PAUSE 100
PWM PORTB.0,127,255 '50%
PWM PORTB.1,127,255 '50%
PAUSE 100
GOTO start
END
still now working, i think before to do pwm i need to change one port for example HIGH PORTB,0 and when use PWM.
 

SgtWookie

Joined Jul 17, 2007
22,230
I'm half-asleep today. :rolleyes:

Give this a try:

Rich (BB code):
MSpause var byte          ' Milliseconds between charging caps, suggest 10 to 50, even numbers 
Ctr     var byte	  ' Used in loop for 50% pwm
RunCt   var byte	  ' Used in loop
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.
SD     var PORTB.2        ' Shutdown; low=run, high=off.

ANSEL = %00000000 ' All pins changed from analogue to digital
OSCCON = $60 ' Internal clock setted to 4Mhz
TRISB = %00000000 ' All PORTB pins are outputs. 

High SD                 ' Shut down MOSFET drivers
MSpause = 50		' initialize MSPause; 50mS, this will result in about 5 seconds forwards, 
                        '   5 seconds stopped, 5 seconds reverse, 2 seconds stopped.

Loop:
       ' Start the motor turning left.  Full speed ahead!
  
        High Left	 ' Start running left...
        Low  Right       ' Set them opposite
	For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           Low SD           ' Turn on MOSFET drivers
           Pause (MSpause-1) ' wait a bit...
           High SD          ' Turn off MOSFET drivers
           Pause 1          ' Charge MOSFET caps
        Next RunCt

       ' Stop the motor by giving it 50% PWM on both sides.

	For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           For Ctr = 1 to (MSpause >> 1)-2  '  
              Low Right
              High Left        ' Swap direction
              Low SD           ' Turn on MOSFET drivers
              Pause 1
              High SD          ' Turn off MOSFET drivers
              High Right       ' Swap direction
              Low Left
              Low SD           ' Turn on MOSFET drivers
              Pause 1
              High SD          ' Turn off MOSFET drivers
           next Ctr
        Next RunCt

        ' Run the motor in reverse

        High Right
        Low Left
        For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           For Ctr = 1 to (MSpause >> 1)-2  '  
              Low SD           ' Turn on MOSFET drivers
              Pause MSpause    ' delay for a bit
              High SD          ' Turn off MOSFET drivers
              Pause 1
           next Ctr
        next RunCt

	' Driver is shut down, let's just pause for 2 seconds
        Pause 1000
        Pause 1000

        goto Loop      ' do forever
END
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
I'm half-asleep today. :rolleyes:

Give this a try:

Rich (BB code):
MSpause var byte          ' Milliseconds between charging caps, suggest 10 to 50, even numbers 
Ctr     var byte      ' Used in loop for 50% pwm
RunCt   var byte      ' Used in loop
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.
SD     var PORTB.2        ' Shutdown; low=run, high=off.

ANSEL = %00000000 ' All pins changed from analogue to digital
OSCCON = $60 ' Internal clock setted to 4Mhz
TRISB = %00000000 ' All PORTB pins are outputs. 

High SD                 ' Shut down MOSFET drivers
MSpause = 50        ' initialize MSPause; 50mS, this will result in about 5 seconds forwards, 
                        '   5 seconds stopped, 5 seconds reverse, 2 seconds stopped.

Loop:
       ' Start the motor turning left.  Full speed ahead!
  
        High Left     ' Start running left...
        Low  Right       ' Set them opposite
    For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           Low SD           ' Turn on MOSFET drivers
           Pause (MSpause-1) ' wait a bit...
           High SD          ' Turn off MOSFET drivers
           Pause 1          ' Charge MOSFET caps
        Next RunCt

       ' Stop the motor by giving it 50% PWM on both sides.

    For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           For Ctr = 1 to (MSpause >> 1)-2  '  
              Low Right
              High Left        ' Swap direction
              Low SD           ' Turn on MOSFET drivers
              Pause 1
              High SD          ' Turn off MOSFET drivers
              High Right       ' Swap direction
              Low Left
              Low SD           ' Turn on MOSFET drivers
              Pause 1
              High SD          ' Turn off MOSFET drivers
           next Ctr
        Next RunCt

        ' Run the motor in reverse

        High Right
        Low Left
        For RunCt = 1 to 100 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           For Ctr = 1 to (MSpause >> 1)-2  '  
              Low SD           ' Turn on MOSFET drivers
              Pause MSpause    ' delay for a bit
              High SD          ' Turn off MOSFET drivers
              Pause 1
           next Ctr
        next RunCt

    ' Driver is shut down, let's just pause for 2 seconds
        Pause 1000
        Pause 1000

        goto Loop      ' do forever
END
Yeah it would be nice "Full speed ahead!" :) but still nothing :/ i am asking in 3 forums this thing, reading myself, searching all day, ohhh i forget and torture you :D But as i read this code and i dont get it why it dont work ;/ it looks everything logically. I meassured pins wile working, and it works good i think, RB0 - 5V after some time it drops to 2.5V and when to zero and RB1 opposite. But RB2 got only 0.12V all time.
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
RB2 stays low? Are you certain that you disconnected it from ground at both IR2110's?
Yeah i am certain, i checked now third time, IR2110 Pin 11 is SD i disconnected it from gnd and connected to another sd and to RB2 :) I measured RB2 without connecting it to SD, and get 0V to 0.45V. huh, or my tester is broke or my uC is dead... i measured again all port they were all high, turned off supply w8 for several minutes, turned on, measured again and get all pins low all the time :| maybe something wrong with fuse bits or what, hmm. i disabled watchdog, enabled intrn_cklout. And now meassured again and got the same as the first time that RB2 don't get high.
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Well, good luck. I'm out of time for today.
No prob. It is quite good feeling when people wish to help. I am grateful ! and Thank You once more ;D i feel like giving to many thanks :D

BTW :
Hi,
That schematic looks a bit strange to me.....

First, there doesn't seem to be any low side supply voltage (Vcc) as pin 3 seems to not be connected to anything except the bootstrap capacitor and diode. Only the logic supply (Vdd) seems to actually be connected to any supply rail.
Second, even if pin 3(Vcc) and 9(Vdd) ARE connected they are both connected to +5V while the datasheet for the IR2110 calls for a Vcc of 10-20V. The undervoltage protection for the low the side supply (Vcc) kicks in at around 8V which means the bridge drivers aren't even operating.
My bad... just showed circuit in which i didn't connect 3 pin to 12V supply.
/Henrik. This pin is made HIGH before the main loop then made LOW within the loop but never serviced again if you are wanting to Shut Down again sometime. That's why it's always LOW.
This one is about that RB2 always low.
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Ok, so i measured MOSFETS:

Rich (BB code):
All transistors:
DS - 1.2kOhm
SD - 1.2kOhm
this one is okay.

All transistors:
positive wire form tester to gate

VT1
GS 1.2 kOhm
GD 1.4 kOhm
VT2
GS 1.2 kOhm
GD 1.7 kOhm
VT3
GS 1 kOhm
GD 1.2 kOhm
VT4
GS 1.3 kOhm
GD 1.8 kOhm

All transistors:
negative wire from tester to gate

VT1
GS 800 Ohm
GD 1.2 kOhm
VT2
 GS 800 Ohm
 GD 1.2 kOhm
VT3
 GS 800 Ohm
 GD 1.2 kOhm
VT4
 GS 800 Ohm
 GD 1.2 kOhm
As i know the third test must show infinity. So my mosfets are dead... y ?
 

retched

Joined Dec 5, 2009
5,207
Your readings may bu going through the board tracks and giving you incorrect readings.

I would CAREFULLY pull 1 and test it. If it is dead (Most likely) you HAVE to replace them.
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Your readings may bu going through the board tracks and giving you incorrect readings.

I would CAREFULLY pull 1 and test it. If it is dead (Most likely) you HAVE to replace them.
ok i pulled one out (also i destroyed some holes :D) so i measured it. i got that with positive and negative both are infinity, between S and D i got 1.2kOhm and it was growing growing growing till infinity.. :>
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Heh, i think i will not graduate this year... :>

ok, i measured voltage on new transistors and get results:

GATE:
VT1 - low
VT2 - high
VT3 - high
VT4 - low
DRAIN
VT1 - high
VT2 - high
VT3 - high
VT4 - high
SOURCE
VT1 - high
VT2 - low
VT3 - high
VT4 - low

with Gate and Source everything is okey, but whats happening with Drain ? i dont get it at all...

corrected circuit:
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
You need to measure gate voltages in respect to the source terminal, not your ground reference.
If Vgs=0v, the MOSFET should be OFF.
If Vgs>=10v, the MOSFET should be ON.

Note that unless you pulse SD every 50mS or less (preferred), or toggle the LIN/HIN inputs occasionally, your bootstrap caps C5 and C6 will discharge, causing problems with your high-side MOSFETs (like getting really, really hot).
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
You need to measure gate voltages in respect to the source terminal, not your ground reference.
If Vgs=0v, the MOSFET should be OFF.
If Vgs>=10v, the MOSFET should be ON.

Note that unless you pulse SD every 50mS or less (preferred), or toggle the LIN/HIN inputs occasionally, your bootstrap caps C5 and C6 will discharge, causing problems with your high-side MOSFETs (like getting really, really hot).
i measured all MOSFETS as you said Vgs and get:
VT1
Vgs= 0
VT2
Vgs= 0
VT3
Vgs= 0
VT4
Vgs= 0

lol :>

Rich (BB code):
MSpause var byte          ' Milliseconds between charging caps, suggest 10 to 50, even numbers 
Ctr     var byte      ' Used in loop for 50% pwm
RunCt   var byte      ' Used in loop
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.
SD     var PORTB.2        ' Shutdown; low=run, high=off.

ANSEL = %00000000 ' All pins changed from analogue to digital
OSCCON = $60 ' Internal clock setted to 4Mhz
TRISB = %00000000 ' All PORTB pins are outputs. 

High SD                 ' Shut down MOSFET drivers
MSpause = 50        ' initialize MSPause; 50mS, this will result in about 5 seconds forwards, 
                        '   5 seconds stopped, 5 seconds reverse, 2 seconds stopped.

Loop:
       ' Start the motor turning left.  Full speed ahead!
  
        High Left     ' Start running left...
        Low  Right       ' Set them opposite 
    For RunCt = 1 to 200 ' We're going to loop 100 times, so run time will be MSpause * RunCt
           Low SD           ' Turn on MOSFET drivers
           Pause (MSpause-1) ' wait a bit...
           High SD          ' Turn off MOSFET drivers
           Pause 50          ' Charge MOSFET caps
        Next RunCt
        
        HIGH SD
        Pause 1000
        Pause 1000
        goto Lo
Tested it on led's everything is working.. But why i get on load from both sides 5V its VS and VB doing it ?
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
OK, just so you know what the loop is doing...

You set SD low, and then pause for MSpause-1, which evaluates to be 49mS.
Then you are setting SD high, and pausing for 50mS.
I think you want this 2nd pause to be of much shorter duration. The caps don't need to charge for an entire 50mS.

Try this:
Rich (BB code):
MSpause var byte      ' Milliseconds between charging caps, suggest 10 to 50, even numbers 
Ctr     var byte      ' Used in loop for 50% pwm
RunCt   var byte      ' Used in loop
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.
SD     var PORTB.2    ' Shutdown; low=run, high=off.

ANSEL = %00000000     ' All pins changed from analogue to digital
OSCCON = $60          ' Internal clock setted to 4Mhz
TRISB = %00000000     ' All PORTB pins are outputs. 
' ---------------------------------------------------------------
        High SD        ' Turn off MOSFET drivers and charge boost caps C5/C6
        MSpause = 50   ' 50 millisecond pause
        Pause MSpause  ' wait a bit
Loop:
        High Left      ' Start running left...
        Low  Right     ' Set them opposite 
        For RunCt = 1 to 200 ' We're going to loop 200 times, so run time will be MSpause * RunCt = 10 seconds
           Low SD        ' Turn on MOSFET drivers
           Pause (MSpause-2) ' wait a bit...
           High SD       ' Turn off MOSFET drivers...
           Pause 2       ' ...and charge MOSFET caps for 2mS
        Next RunCt

        '  At this point, the IR2110 drivers are disabled, and the caps have charged for at least 2mS.

        Pause 1000 ' One second pause.
        goto Loop
END
It's on for 48mS then off for 2mS. That's a 96% duty cycle.
 

SgtWookie

Joined Jul 17, 2007
22,230
What voltage do you measure between the Vs and Vb terminals of the IR2110's?
(same as measuring across C5 and C6)

You should see >10v there.
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
I measured between Vs and Vb i get 6.5V. I tested program it works great, RB2 LED blinks some time when it stops for several second and starts again.
 

SgtWookie

Joined Jul 17, 2007
22,230
I measured between Vs and Vb i get 6.5V.
OK, there's a problem.

Does your 12v in measure 12v? If so, figure out why your C5 and C6 are not measuring >10v.

Dog-gonit. Just realized that in order to charge C5, VT1 must be OFF, and VT2 must be ON.
In order to charge C6, VT3 must be OFF and VT4 must be ON. Otherwise, there is no path to ground to charge the caps; simply raising SD won't charge them.

However, the way you have the HIN/LIN wired, you don't have independent control of the LINs - which is what I was referring to earlier on in the thread. :/

In order to charge the high-side boost caps, you will have to momentarily flip RB0 and RB1. This will be hard on the motor.
 

SgtWookie

Joined Jul 17, 2007
22,230
Ok, NEXT! :D

Give this a shot:

Rich (BB code):
MSpause var byte      ' Milliseconds between charging caps, suggest 10 to 50, even numbers 
Ctr     var byte      ' Used in loop for 50% pwm
RunCt   var byte      ' Used in loop
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.
SD     var PORTB.2    ' Shutdown; low=run, high=off.

ANSEL = %00000000     ' All pins changed from analogue to digital
OSCCON = $60          ' Internal clock setted to 4Mhz
TRISB = %00000000     ' All PORTB pins are outputs. 
' ---------------------------------------------------------------
        ' Initialization sequence - necessary to charge both boost caps.
        High SD        ' Turn off MOSFET drivers
        MSpause = 50   ' 50 millisecond pause
        Pause MSpause  ' wait a bit
        High Left      ' Charge one side
        Low  Right     ' ....
        Low SD	       ' turn on bridge...
        Pause 2	       ' for 2mS
        High SD        ' Turn off MOSFET drivers
        pause 1        ' pause a moment
        Low Left       ' Charge other side
        High Right     '...
        Low SD	       ' turn on bridge...
        Pause 2	       ' for 2mS
        High SD        ' Turn off MOSFET drivers
Loop:
        For RunCt = 1 to 200 ' We're going to loop 200 times, so run time will be MSpause * RunCt = 10 seconds
           High Left     ' Start running left...
           Low  Right    ' Set them opposite 
           Pause 1       ' Ensure MOSFETs are off.
           Low SD        ' Turn on MOSFET drivers
           Pause (MSpause-3) ' wait a bit...
           High SD       ' Turn off MOSFET drivers...
           Low Left
           High Right
           Pause 1       ' Ensure MOSFETs are off.
           Low SD        ' Charge caps
           Pause 1       ' ...and charge MOSFET caps for 1mS
           High SD        ' Turn off MOSFET drivers
        Next RunCt

        '  At this point, the IR2110 drivers are disabled, and the caps have charged for at least 1mS.

        Pause 1000 ' One second pause.
        goto Loop
END
I'm not crazy about this, but it's necessary due to the way you've cross-connected HIN and LIN.
 
Top