PIC16F88 problem controlling hbridge

Discussion in 'General Electronics Chat' started by aGpLT, May 18, 2010.

  1. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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...
    ---------------------------------------------------------------------------
     
    Last edited: May 18, 2010
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
    Last edited: May 18, 2010
  3. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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 ?
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  5. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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: May 18, 2010
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Sure, any of the BYV28-x diodes will work just fine.
     
  7. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    i was right about connecting it between S and D y ? :) <snip> i got BY255 (1300V) lol.

    sorry about it, its not intentionally.
     
    Last edited: May 19, 2010
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  9. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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 :/
    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: May 19, 2010
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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
     
  11. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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: May 19, 2010
  12. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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 ?
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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?
     
  14. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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 ? :>
     
    Last edited: May 19, 2010
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    So, try this:
    (Not sure if the GPIO/TRISIO/ADCON statements are correct; I don't have a PIC16F88 datasheet)
    Code ( (Unknown Language)):
    1. GPIO.0 = 1
    2. GPIO.1 = 1
    3. TRISIO = %000011
    4. ADCON1 = 7
    5.  
    6. MSpause var byte          ' Milliseconds between steps, suggest 10 to 50, even numbers only
    7. Ctr    var byte       ' Used in loop for 50% pwm
    8. Left   var PORTB.0        ' Don't know which is which, so declare one as left.
    9. Right  var PORTB.1        ' By default, the other is right.
    10.  
    11. MSpause = 10        ' initialize MSPause
    12.  
    13. Loop:
    14.        '  
    15.        High Left    ' Start stepping left...
    16.        Low  Right       ' Set them opposite
    17.        Pause MSpause    ' wait a bit
    18.        '
    19.        For Ctr = 1 to MSpause >> 1  '  
    20.           Low Right
    21.           High Left
    22.           Pause 1
    23.           High Right
    24.           Low Left
    25.           Pause 1
    26.        next Ctr
    27.        '
    28.        Low Left
    29.        High Right
    30.        Pause MSpause    ' wait a bit
    31.        For Ctr = 1 to MSpause >> 1  '  
    32.           High Right
    33.           Low Left
    34.           Pause 1
    35.           Low Right
    36.           High Left
    37.           Pause 1
    38.        next Ctr
    39.        goto Loop:      ' do forever
     
  16. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    http://ww1.microchip.com/downloads/en/devicedoc/30487c.pdf
    GPIO register configure if pin is high or low ? so in pic16f88 it would be HIGH PORTB.0 / PORTB.1
    TRISIO register configure pin in/out. in pic16f88 TRISB = %00000000 (i dont get it why you done RB0 and RB1 as inputs :/) and the last one ADCON1 = 7 i dont understand this one. ;) do adcon1 = 7 configure pins to be analogue or digital ?
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  19. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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 ?
     
  20. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
Loading...