PNP with PIC

Discussion in 'General Electronics Chat' started by Guinness, Mar 31, 2010.

  1. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    Hi,
    I have a simple question but want to make sure I don't damage my PIC.
    I am building a crude stepper motor control with bits I have around the house. So that is why some of the combinations might seem wierd.

    I have a 24V 0.3A per phase unipolar stepper motor, a pic 16F84A PIC, and lots of darlington pair PNP transistor ( BD678 ) as the switches.

    I have used the BD678 in simple circuits to figure out how it works ( norm use NPN's ). But if I have 24V going across the E-C junction, can I just connect the PIC to the B ( with a resistor ) and sink 5V?
    Or would that sink the whole 24V into the PIC?

    Otherwise the only other option I have is to connect the output of the PIC to some NPN ( BC182B ) which I also have, to switch the PNP's on and off. Would prefer not to as tryin to keep the component count down. Oh and I can't use the BC182B to control the stepper motor as its Ic is only 0.1A.
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I agree with Alberto. A single ULN2803A eight-channel Darlington would be enough to drive two of those stepper motors, and it already has built-in freewheeling diodes. Make sure you connect the COM terminal to +24v.
     
  3. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    Cheers for the replies, I havn't got ULN2803A in my stock of bits, or anything close to it. Will look into gettin some in future, but for now im stuck with what I have :(

    I done a quick setup with the NPN and PNP setup, with a LED instead of the motor for now, I always do quick little circuits before building the whole thing. I seem to have missed something though, as when I turn on the 24V the LED lights up, regardless of what position the switch is in.

    Could you point out the obvious mistake please.
    Very crude drawing attached.
     
    • PNP.jpg
      PNP.jpg
      File size:
      76.4 KB
      Views:
      45
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Try it more like this:

    [​IMG]

    The trouble you're experiencing is caused by leakage current. Since your switch is applying +5v or an open circuit to the base of the NPN transistor, the leakage current through the NPN is turning on the PNP transistor. Using the pull-down resistor R2 and the pull-up resistor R4 keeps the transistors turned off unless your switch is closed.

    In your actual circuit where the PIC will be holding the input to the base resistor at either 5v or 0v, you won't need R2. However, if the PIC pin might ever be used as an input, you should use need R2. In either case, you should use R3/R4.

    I threw that schematic together in a bit of a hurry, and neglected to see that your PNP is actually a Darlington. This means that 750 Ohms is much too low of a value to use for R3, as the base current through Q2 would be much too high.

    Re-calculate as:
    R3 = (V2-Vbe)/(Ic/250) [note: the 250 figure was found in the datasheet]
    R3 = (24-1.4)/(.3/250) [note: Vbe derived from datasheet plot]
    R3 = 22.6/0.0012
    R3 = 18,833 Ohms
    You could round it down to 18k, and use 10k for R4.
     
  5. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    SgtWookie: I tried the circuit that you posted, for some reason the LED still lights up as soon as the 24V is turned on. Have give the circuit a quick look over and everything is where its supposed to be.

    Any idea's as to why its doing it?
     
  6. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    I didn't mention this before, but I am using 2 different power supplies, I don't know if this makes a difference, but at the end of the circuit I connected the negative terminals together. I guessed that doesn't matter as they are both 0v anyway!

    Just incase that helps
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Double-check to make certain you have connected the transistor's leads properly.

    For the BD678, with the pins down and the part number side facing you, the pins are from left to right:
    1) Emitter 2) Collector 3) Base.

    Same thing with your BC182 NPN transistors.

    The 5v and 24v supplies must have their grounds/returns connected together, or the circuit will not work.
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Following on to what you already have, here's how you could connect up to one of your stepper's inputs:

    [​IMG]

    Note the addition of D2, a Schottky diode. It doesn't have to be a Schottky, but it should be a fast recovery type diode. A 1N5818 or 1N5819 would do nicely. 1N400x or 1N540x series will be too slow. Without D2, Q2 may be destroyed when it turns off due to the reverse-EMF from the stepper motor's winding.
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Note that if you used a ULN2803A IC instead of the discrete components, you would only have one part to connect up in order to drive two steppers.

    I don't know where you are located, but ULN2803A Darlington driver ICs are available for under $1 USD here in the States.
     
  10. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    I got the circuit working, had to strip the whole thing down and start again, there was a mistake somewhere.

    Cheers for the circuit including the motor.

    I live in the UK, would have to order the ULN2803A off the internet as there are no stores that are open to the public that I can find.

    I rang RS once to place an order and they said they are only open for trade, not public:confused:
     
  11. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
  12. Guinness

    Thread Starter Member

    Dec 31, 2009
    81
    1
    Cheers, will look into gettin the ULN2803A then, seems it will save a lot of space and hassle, and should work out a lot cheaper, parts cost wise.

    Although this was very usefull for learning about PNP's, and I can at least use the circuit I have now untill I get the ULN2803A.

    Thanks again
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You are welcome. :)

    Note that when you change to using the ULN2803A drivers, your stepper motor common lead(s) will go to +24v, and the four individual leads will have their ground supplied by the ULN2803A. You must also connect the COM terminal to +24v, so that the Darlington outputs are protected from the stepper motor's reverse EMF.
     
Loading...