Is there a circuit out there that could control both 24VDC or 24VAC solenoids from a 24VDC power supply? I am working on a sprinkler control board that I would like to be able to use both on. The first idea that came to mind was using an H-bridge to either run the DC valve, or chop up the DC current into a square wave pattern to run the AC solenoid. Any better ideas?
Electrical – Circuit to control 24VAC OR 24VDC solenoids
ach-bridgesolenoidsolenoid-valve
Related Solutions
FTDI USB chip + daisy-chained '595 shift register. Put a separate transistor on each relay.
More detail:
A chain of 74hc595 is described here: http://www.arduino.cc/en/Tutorial/ShiftOut (Only two are shown, but the concept can be expanded to any number of '595s.)
To drive a the chain, three signals are needed, data, latch, and clock.
You can use an FTDI part in "bitbang" mode to generate three signals from computer control. To use the FTDI in bitbang mode, use libftdi (You could also use FTDI's official drivers, but libftdi is less hassle in my experience). A FT232R has enough pins to do this. FTDI sells a DIP breakout, and Sparkfun sells some breakouts too.
Notice you will need 128 2N2222s and 128 330 ohm resistors. (you can get resistor arrays that might be easier to manage.)
I've drawn the circuit assuming a 12V supply for your relays and no less than 24 ohm coils. If this is not the case, you might need a sturdier transistor or logic-level MOSFETs. The 2222 is about as cheap a transistor as you will find, and when you're buying 128 pieces that makes a difference.
I didn't show bypass caps or the exact 232R hookup. Read the datasheet.
OK, I just saw the solenoid you are trying to control. 2N2222 won't work. You need to switch 120VAC to the solenoid. So you can either have a small relay (with 2N2222) to switch the 120V, or use a solid-state relay that can take logic inputs and connect it directly to the '595 output.
OK, here's code to drive this using libftdi. Pin assigments in the source code. apt-get install libftdi-dev, then compile like this: "gcc test_595.c -lftdi"
/* This program is distributed under the GPL, version 2 */
#include <stdio.h>
#include <ftdi.h>
#define HC595_CT (1) // number of '595 chips
int main(int argc, char **argv)
{
struct ftdi_context ftdic;
int f,i;
unsigned char buf[2*8*HC595_CT+1]; // latch pulse, 8*HC595_CT clock pulses
if ((f=ftdi_init(&ftdic)) < 0)
{
fprintf(stderr, "ftdi_init failed\n");
return f;
}
f = ftdi_usb_open(&ftdic, 0x0403, 0x6001);
if (f < 0 && f != -5)
{
fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(&ftdic));
exit(-1);
}
printf("ftdi open succeeded: %d\n",f);
// FTDI cable assignments:
#define BIT_DATA (1<<0) // 1: orange. TXD, "data"
// 2: yellow. RXD, unused
#define BIT_CLOCK (1<<2) // 4: green. RTS, "clock"
#define BIT_LATCH (1<<3) // 8: brown. CTS, "latch"
ftdi_enable_bitbang(&ftdic, BIT_DATA | BIT_CLOCK | BIT_LATCH);
// set zero
*buf=0;
f = ftdi_write_data(&ftdic, buf, 1);
unsigned char *b=buf;
unsigned char data;
unsigned char state;
if (argc == 2) {
data=atof(argv[1]);
} else {
data=0x5a;
}
printf("sending data %d\n",data);
for (i=0; i<8; i++) {
state=(data & (128L>>i))?BIT_DATA:0;
*b++=state;
state |= BIT_CLOCK;
*b++=state;
}
*b++=BIT_LATCH;
f = ftdi_write_data(&ftdic, buf, (b-buf));
ftdi_disable_bitbang(&ftdic);
ftdi_usb_close(&ftdic);
ftdi_deinit(&ftdic);
}
And here's a picture of my test setup:
(I used the TTL-232R-3V3 cable.)
Your solution started out as bearable (5V at 100mA) but ended up completely unacceptable at 500 mA. You say that your "wall wart" is rated at 300 mA. When you supply a voltage using a linear regulator the current in is the same as the current out - the regulator drops the difference in voltage. So here if you draw 500 mA at 5V you must supply 500 mA at 12V or 24V. The transformer will be overloaded in either case.
If the ratings are as you say then a potentially acceptable solution is to use a switching regulator (SR) operating from 24V in. \$5V \times 500 mA = 2.5 W\$.
\$24V \times 5 W =~ 210 mA\$. If the SR is 80% efficient (easily achieved) that rises to 260 mA. As that is liable to be an occasional requirement the total current at 24V will probably be acceptable with a 300 mA supply - depending on how many solenoids you wish to maintain on.
If you switch only one solenoid on at once the current drain with N activated is \$20 \times N + 20 mA\$. The surge current is essentially immaterial.
If you wanted more than 3 or 4 solenoids then current drain at 5V may need to be limited.
e.g.
- 10 solenoids at 20 mA = \$200 mA\$
- Balance = \$300mA-200mA = 100 mA\$
- Available current at 5V at 80 % efficient = \$ 100 mA \times \frac{24}{5} \times 0.8 = 384 mA\$, say \$400 mA\$.
Note that when a switching regulator is used, using a higher input voltage will result in less input current drain. Hence it is better here to use the full 24V supply.
Note also that if the transformer is a genuine 24 VAC then the rectified DC will be about \$24 VAC \times 1.414 - 1.5V - \$ "a bit" \$~= 30 VDC \$
Because:
\$VDC_{peak} = VAC_{RMS} \times \sqrt{2} ~= VAC \times 1.414 ~= 34 V\$.
A full bridge rectifier will drop about 1.5V.
34 VDC is peak voltage and available DC will be slightly lower - depends on load. There will be "a bit" of ripple and wiring loss and transformer droop and ...
At 80% efficiency this gives a 24VAC to 5V DC current boost of \$ \frac{30}{5} \times 0.8 = 4.8:1 \$
e.g.
- for 48 mA at 5V you need 10 mA at 30V.
- for 480 mA at 5V you need 100 mA at 30V.
So you about get 10 solenoids plus almost 500 mA at 5V DC :-)
One solution of many:
There are many SR IC's and designs. Here a simple buck regulator will suffice. You can buy commercial units or "roll your own". There are many modern ICs but if cost is at a premium you could look at ye olde MC34063. About the cheapest switching regulator IC available and able to handle essentially any topology. It would handle this task with no external semiconductors and a minimum of other components.
MC34063. $US0.62 from Digikey in 1's. I pay about 10 cents each in 10,000 qauntity in China (about half Digikey's price).
Figure 8 in the datasheet referenced below happens to be a "perfect match" to your requirement. Here 25 VDC in, 5V at 500 mA out. 83% efficient. 3 x R, 3 x C, diode, inductor. It would work without alteration at 30 VDC in.
Datasheet - http://focus.ti.com/lit/ds/symlink/mc33063a.pdf
Prices - http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-17766-5-ND
- Added:
Figure 8 in the LM34063 datasheet shows ALL component values except for the inductor design (inductance only is given). We can spec the inductor for you from Digikey (see below) or wherever and/or help you design it. Basically it's a 200 uH inducor designed for general power switching use with a saturation current of say 750 mA or more. Things like resonant frequency, resistance etc matter BUT are liable to be fine in any part that meets the basic spec. OR you can wind your own for very little on eg a Micrometals core. Design software on their site.
From Digikey $US0.62/1. In stock. Bourns (ie good).
Price: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=SDR1005-221KLCT-ND
Datasheet: http://www.bourns.com/data/global/pdfs/SDR1005.pdf
Slightly better spec
$US0.75/1.
Surface mount.
Bourns.
Best Answer
Your user profile gives no clue as to your level of electrical knowledge (and that's why you should put some info in there) so this may be of no use to you. Some ideas to consider:
If you measure the AC holding current on the solenoid and measure its DC resistance using an ohmmeter you can calculate the safe DC voltage that can be applied without burning out the coil. \$ V_{DC} = I_{AC}R_{COIL} \$. You will then need to test this using a variable voltage PSU or by adding series resistors to get the required voltage.
Your next problem is to see if the solenoid will pull in with the DC voltage. If not you'll need to give it a higher voltage pulse to pull in.
simulate this circuit – Schematic created using CircuitLab
Figure 1. C1 charges up to +24 V while RLY1 is open circuit. On closing RLY1 the solenoid gets a 24 V pulse and then the voltage drops to the level set by the ratio of R1 and RL.
There is a risk that running the solenoid on DC will permanently magnetise something. I've never tried it so I don't know but someone will point it out in the comments.