Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Solenoids — Parallax Forums

Controlling Solenoids

Paul ThompsonPaul Thompson Posts: 5
edited 2006-11-19 18:41 in BASIC Stamp
Hello All,
I have been working on a project for a while that deals with alcohol/water injection for motorsport applications. I am having trouble getting the solenoids to work with the Basic stamp. I have a 2N4920 PNP power transistor that I have connected to a 12V 500mA solenoid. When I connect it to the pin that is supposed to control the solenoid, it turns on but stays on even if the pin is high or low. When I disconnect the wire from the pin of the stamp, it turns off like it should and works normally when I connect to to ground. Is there not enough of a voltage drop from 12 to 5V for the transistor? I need help!! Thanks.
-Paul Thompson

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-11-18 09:30
    Paul -

    In order to assist you, a schematic of your circuit, and a copy of your program would be most helpful.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Paul ThompsonPaul Thompson Posts: 5
    edited 2006-11-18 12:24
    Here is the program... not totally complete, but works for testing purposes...
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    [noparse][[/noparse] Declarations ]
    adcBits VAR Byte
    result VAR Byte
    speed VAR Word
    v VAR Byte
    r VAR Byte
    v2 VAR Byte
    v3 VAR Byte
    S1 VAR Bit
    S2 VAR Bit
    S3 VAR Bit
    '
    [noparse][[/noparse] Initialization ]
    HB25 PIN 15
    CS PIN 0
    CLK PIN 1
    OUTPUT 4
    OUTPUT 5
    OUTPUT 6
    DataOutput PIN 2
    DEBUG CLS 'Start display.
    'DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    PAUSE 5 ' Wait For HB-25 To Initialize
    PULSOUT HB25, 750
    '
    [noparse][[/noparse] Main Routine ]
    DO
    GOSUB ADC_Data
    GOSUB Run_Motor
    GOSUB Solenoids
    GOSUB Display
    LOOP
    '
    [noparse][[/noparse] Subroutines ]
    ADC_Data:
    HIGH CS
    LOW CS
    LOW CLK
    PULSOUT CLK, 210
    SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
    RETURN
    Run_Motor:
    result = (adcBits - 1) / 25
    LOOKUP result, [noparse][[/noparse]750, 750, 750, 785, 820, 855, 890, 925, 960, 1000, 1000], speed
    PAUSE 20
    PULSOUT HB25, speed '750=stop, 1100 full fwd, 400 full reverse
    PAUSE 7
    RETURN
    Solenoids:
    result = (adcBits - 1) / 25
    LOOKUP result, [noparse][[/noparse]0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], S3
    LOOKUP result, [noparse][[/noparse]0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1], S2
    LOOKUP result, [noparse][[/noparse]0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1], S1
    OUT4 = S3
    OUT5 = S2
    OUT6 = S1
    RETURN
    Display:
    DEBUG HOME
    DEBUG BIN S3, BIN S2, BIN S1
    DEBUG "8-bit binary value: ", DEC3 result
    DEBUG CR, CR, "Decimal value: ", DEC3 speed ' new line
    RETURN

    I am using a pot to change the value of adcvolts and a lookup table to change the value of the solenoids. The other lookup table is for a motor control. The schematic is at the very bottom of this page...
    http://techhouse.brown.edu/~dmorris/projects/tutorials/transistor.switches.pdf#search="how to use transistors PNP"
    Thanks,
    Paul Thompson
  • HulkHulk Posts: 68
    edited 2006-11-18 16:24
    I think you need a different circuit than the one in the url above. That PNP circuit will turn "on" with either a "1" or "0" output from the stamp. The stamp gives a 0 or 1 referenced from ground. The circuit that you refer to is referenced to B+ so you get a translation error. If you search for a circuit that uses an NPN with the load in the collector circuit, I think it will remove your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-19 01:32
    Hello,
    ·
    ·· A PNP is not the best choice for controlling a voltage higher than the control voltage.· In this case the Stamp I/O pin will never be able to supply a high enough voltage to turn off the transistor.· Instead, use an NPN such as that shown in the attached schematic.· You can also use a MOSFET.· That schematic is also attached.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    320 x 240 - 6K
    320 x 240 - 6K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-19 01:34
    Another thing I forgot to mention above is that you might want to read a post by Beau Schwabe which elaborates on transistor control in a little more detail.

    http://forums.parallax.com/attachment.php?attachmentid=37701

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-19 17:58
    Yes, there could well be a problem with that, but it depends on the transistor.· There are ratings for a transistor that define how they can be used and without knowing that information you could damage the transistor and/or the Stamp I/O pin.· In this case the VBE has a significant impact because of the switching voltage versus the supply voltage.· Beau might be able to put it more in layman’s terms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Randy EvansRandy Evans Posts: 24
    edited 2006-11-19 18:41
    agfa:

    That's called a Common Collector circuit aka Emitter Follower. The only gain you get is current gain. The output voltage will be what you put into the base minus the base-emitter junction voltage. For low voltage applications it's fine but if you're driving motors higher than 5 volts, you'll have to use the standard Common Emitter which gives you both current and voltage gain.

    Randy
Sign In or Register to comment.