Controlling Solenoids
Paul Thompson
Posts: 5
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
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
In order to assist you, a schematic of your circuit, and a copy of your program would be most helpful.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
' {$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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
·
·· 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
http://forums.parallax.com/attachment.php?attachmentid=37701
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
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