Intermittent DC Motor on H-Bridge

Discussion in 'The Projects Forum' started by Dalaran, Dec 20, 2009.

  1. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    I am trying to run a DC motor using a L293DNE H-Bridge and PIC16F684. Pins 2 and 7 of the bridge are connected to 2 PORTC pins on the PIC. The PIc compares 2 analogue inputs and if A > B set PORTC.0 high and PORTC.4 low, and vice versa if A < B. There is a region in the middle that both ports go low if the inputs are sufficiently close. I can post code if anyone is interested but it was initially checked with LEDs connected to the ports and everything worked perfectly.

    This is the connections of the H-Bridge.
    [​IMG]

    Always when the PIC is first started the DC motor runs smoothly in the direction it is intended. I am currently using 2 voltage dividers to set the voltages on the two analogue pins on the PIC. CCW direction always works fine but when I try to set it to the CW rotation it gets all jittery and starts and stops a few times a second.

    Any ideas what might be going on?

    Thanks.
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Do you have a 0.1uF cap across the PIC's Vdd/GND pins?

    Do you have a non-polarized cap across the motor?

    Do you have small caps from the middle of the voltage dividers to ground?
     
  3. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    I do, I don't, I don't.

    What size cap do you recommend across the motor? I realize if I put caps on the middle of the voltage dividers to ground I will most likely need to slow down my ADC time between acquisitions. Are these necessary since I was having no function problems with LEDs to the outputs?

    Thanks.
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Try a non-polarized 0.1uF. If you have a larger non-polarized cap, try it.
    Yes. However, you need a low-impedance input to the ADC anyway. If you're just using a voltage divider, you're presenting a high-impedance input to the ADC, which is not good.
    The LEDs produce very little, if any noise. The motor produces a tremendous amount of electrical noise. It's like having a punk band concert in a library. :eek:

    I don't know how often you need to take ADC samples.
    If your divider network is around 250k Ohms total, and you use a 10nF cap, it'll take around 6mS for the voltage on the cap to get within 99% of actual.
     
  5. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    Cheers. I'll take a look at this when I get home and report results.
     
  6. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    I have placed 100nF non-polarized caps across the motor as well as from the middle of the voltage divider where the ADC samples to ground. This however has not helped the performance and I am still having the same issue, once in CCW it does not like going back to CW rotation. If it starts in CW rotation it is ok until you go to CCW and try to get back to CW. I have increased the time between acquisitions of ADC to almost 200ms just to play safe. I will need to sample fast than this but I figure lets get this thing to work first.

    Any other ideas what might be happening?
     
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Have you convinced yourself that the program is not causing the behaviour you have observed.

    hgmjr
     
  8. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    Hi Thanks. Yeah, I've convinced myself that it is not the program. With the output pins floating or connected through LEDs i get the exact response I am looking for. However when I hook up to the motor and H-bridge I have the funky behaviour.

    Thanks.
     
  9. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    168
    0
    I've done a little more testing and it seems that when I switch back to CW rotation and the motor seems to almost jam up the output pins on the PIC are not driving the correct voltage. Under the CCW rotation that works fine I have almost exactly 0V and 5V at RC0 and RC4 respectively. However when the motor struggles I only measure ~0.35V on both RC0 and RC4.

    What could cause this sort of behaviour in the PIC?

    Thanks.
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You might have a damaged L293, or a damaged output pin.

    Try disconnecting the PIC from the L293, and see if the output voltage comes up to normal.

    If it does, try a load test on it. Connect a 270 Ohm resistor from the pin that's low to ground, and try to output a logic high. It might not be right at 5v, but it should be above 4v.
     
Loading...