Doubling up pin use: would this work please?

PaulRB

Senior Member
Hello all, please critique this idea for reusing output pins.

I want to use the same pins to drive a 16x2 lcd and drive 5 miniature solenoids. I propose to use 7 pins in total. The solenoids only need to be pulsed one at a time, for a few milliseconds, drawing a couple of hundred milliamps.

To send data to the lcd I will put data onto out1 to out5 and pulse out6.

To activate a solenoid, I would set out7 high and then pulse one of out1 to out5.

I have drawn a heavy duty logic level power fet, but would a bc337 do just as well? Or a bc327 on the high side?

Thanks,

Paul

1365355440272.jpg
 

AllyCat

Senior Member
Hi Paul,

The schematic diagram in the ULN data sheet shows (parasitic) diodes from the ground pin (substrate) to each input, so I don't think that a low-side switch in the earth line will work. But in any case I would take the decoupling capacitor to "real" ground not the chip pin.

Therefore, probably a high-side switch would be better; a BC327 should be fine if the peak current is no more than a few hundred milliamps. If the unconnected inputs of the ULN are "spare", you could use one as a driver for the PNP base (via a resistor of course) and you might also use another stage as an inverter so that only one PICaxe pin is needed to enable/disable both the solenoids and the LCD (Active High/Low).

Cheers, Alan.
 

PaulRB

Senior Member
Thanks Alan! I can always rely on you for these questions.

So my schematic becomes:

1365368894171.jpg

Not sure about the inverter idea though. I don't want either device reading the data lines before I have set them up!

Paul
 

g6ejd

Senior Member
Hello all, please critique this idea for reusing output pins.

I want to use the same pins to drive a 16x2 lcd and drive 5 miniature solenoids. I propose to use 7 pins in total. The solenoids only need to be pulsed one at a time, for a few milliseconds, drawing a couple of hundred milliamps.

To send data to the lcd I will put data onto out1 to out5 and pulse out6.

To activate a solenoid, I would set out7 high and then pulse one of out1 to out5.

I have drawn a heavy duty logic level power fet, but would a bc337 do just as well? Or a bc327 on the high side?

Thanks,

Paul

View attachment 13908
That would work OK. If the LCD did not respond to the LCD commands, or if it did and you don't care (perhaps screen is refreshed at regular intervals) then you could do away with another output.
 

AllyCat

Senior Member
Hi Paul,

On balance, I think the COM pin of the ULN should probably go directly to the +9 volt rail. Remember that the catching diodes on the output pins will try (and need) to pull up the COM pin to the supply rail. However, in practice there would probably be just a tiny pulse of current as the capacitor charges through the transistor base, when the power is initially connected.

Yes, using a combined active High/Low enable pin does need more care with the software design. But basically you just need to ensure that the "data" outputs are always Low except when you actually want to drive the LCD or Solenoids.

Cheers, Alan.
 

westaust55

Moderator
Where using a BC327 high side switch to provide the positive common the the relays, the PICAXE outputs cannot raise the output voltage high enough to turn of the B 327 transistor.

You will need a (say) 10 kOhm pull-up on the BC327 base and the. Add a BC548 as an interface from the PICAXE output to the BC327 base. Use a 1 kOhm BC548 collector to BC317 base and same again PICAXE output to BC548 base.

Don't have PC access to draw a diagram but have posted such a circuit in response to others in the past.
 

PaulRB

Senior Member
Thanks Westy, I get what you're describing, and if I didn't have spare inputs on the ULN, I would have gone with that.

Alan, I connected it up as you suggested with the COM pin connected to V+ and it works great. I've attached a short video showing the solenoid firing at 0 seconds on the clock.

I have not tried the inverter idea, I still can't think how that could work. I think the lcd reads data from the D4-D7 pins on the falling edge of the ENable pin. If I tried to use the same picaxe pin for that, the lcd would load a zero nibble each time even though the data lines were all low. Also the solenoids might buzz and chatter because of the data going to the lcd.

Anyway, very pleased with only using 7 pins to achieve both functions. Thanks again.

Paul

[video]http://m.youtube.com/watch?feature=plcp&v=q120zaH9KCs#[/video]
 

PaulRB

Senior Member
Where using a BC327 high side switch to provide the positive common the the relays, the PICAXE outputs cannot raise the output voltage high enough to turn of the B 327 transistor.

You will need a (say) 10 kOhm pull-up on the BC327 base and the. Add a BC548 as an interface from the PICAXE output to the BC327 base. Use a 1 kOhm BC548 collector to BC317 base and same again PICAXE output to BC548 base.
As the design has evolved, I've changed my mind about using one of the darlingtons to drive the pnp. I now need the 3 remaining darlingtons on the ULM2803 for another purpose (pwm-ing an array of rgb leds). So I am re-reading your advice, Westy. But I have a question or two you or Alan could help me with please?

1. The arrangement using the darlington to drive the pnp seemed to work ok with a solenoid connected. But when I tried connecting a piezo buzzer in place of the solenoid, I was getting a little bit of buzz and vibration when the pnp was supposed to be off. Does this mean it wasn't 100% off? Is that why Westy suggested a 10K pullup on its base?

2. Why the suggestion of the npn as an interface between the picaxe and pnp? Is it simply to keep the "logic-sense" the same? Alternatively, could I use a 10K pullup on the pnp's base and also connect the pnp base direct to the picaxe output with a 1K? This would mean that I would need to reverse the logic sense in the code so that a low output would enable the solenoids. I would then need to make the output change to an input to switch off the pnp and disable the solenoids. Just making the output high would not be enough, as there would still be a 4V differential across the base/collector of the pnp, causing current to flow and the pnp to stay switched on.

Thanks yet again,

Paul
 
Last edited:

westaust55

Moderator
The BC548 or similar as an interface is not essential if the supply voltage for the BC327 and load (motor, buzzer or whatever) is the same voltage as the PICAXE.
The BC548 as an interface keeps the logic right (by my convention at least) in so far as a high on a PICAXE output turns on the BC327 and the load and also allows the BC327 to switch a higher voltage where the PICAXE output could not drive the BC327 base high enough to turn the transistor off.

When a PICAXE is first powered up the IO are all inputs which leaves the signal to the transistor(s) floating. The pull-up resistor ensures that the BC327 base is pulled high to keep the transistor turned off.
 

AllyCat

Senior Member
... there would still be a 4V differential across the base/collector of the pnp, causing current to flow and the pnp to stay switched on.l
Hi Paul,

It's the base-emitter voltage of the PNP (or any bipolar) transistor which is important and must be less than (about) 0.5 volt to hold it OFF. With stable 5 and 9 volt rails it might just be possible to use a resistor divider chain (say 1k + 10K) directly from a PICaxe pin, such that 5 volts output (4 volts across the chain) keeps the PNP off, but 0 volts output (9 volts across the chain) brings the PNP into conduction, but IMHO it's a poor design.

Far better to use a PICAxe pin to drive an NPN which then drives the PNP. Since bipolar base-emitter inputs are basically diodes, you must use current-limiting in some form, typically 10k in series with each base. Since some slight leakage current through the transistors at high temperatures is a possibility, a "safe" arrangement is to also put a 10k across the base-emitter of the PNP.

An alternative arrangement (which saves a resistor) is to take the base of the NPN directly to the PICaxe pin and collector directly to the PNP base, but put a resistor (again say 10k) from the emitter of the NPN to ground (which limits both the base and collector currents through the NPN). In all these cases a "high" on the PICaxe ouput turns ON the NPN and the PNP.

Cheers, Alan.
 

PaulRB

Senior Member
The arrangement using the darlington to drive the pnp seemed to work ok with a solenoid connected. But when I tried connecting a piezo buzzer in place of the solenoid, I was getting a little bit of buzz and vibration when the pnp was supposed to be off. Does this mean it wasn't 100% off? Is that why Westy suggested a 10K pullup on its base?
I eventually solved this. After a couple of hours convinced my understanding of pnp vs npn transistors must be wrong in some way, I tried replacing the pnp with a fresh one out of the packet. Problem dissapeared instantly!

Paul
 
Top