PDA

View Full Version : Controlling Solenoids



Paul Thompson
11-18-2006, 10:07 AM
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

Bruce Bates
11-18-2006, 04:30 PM
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 Thompson
11-18-2006, 07:24 PM
Here is the program... not totally complete, but works for testing purposes...
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ 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
' -----[ 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
' -----[ Main Routine ]----------------------------------------------------
DO
GOSUB ADC_Data
GOSUB Run_Motor
GOSUB Solenoids
GOSUB Display
LOOP
' -----[ Subroutines ]-----------------------------------------------------
ADC_Data:
HIGH CS
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[adcBits\8]
RETURN
Run_Motor:
result = (adcBits - 1) / 25
LOOKUP result, [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, [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], S3
LOOKUP result, [0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1], S2
LOOKUP result, [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=%22how%20to%20use%2 0transistors%20PNP%22
Thanks,
Paul Thompson

Hulk
11-18-2006, 11:24 PM
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 Savage
11-19-2006, 08:32 AM
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

Chris Savage
11-19-2006, 08:34 AM
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 Savage
11-20-2006, 12:58 AM
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 Evans
11-20-2006, 01:41 AM
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