0

Example, one end (S1) of a solenoid hooked to 12 V and the other end (S2) to either ground or 24 V.

Could you use an op-amp to raise and lower S2 to control the flow of current through the solenoid? Setting S2 to 0 V would have current flow from S1 to S2. If S2 is 24 V, then current would from from S2 to S1.

Does this already exist? Is it unsafe to do it this way?

ocrdu
  • 9,195
  • 22
  • 32
  • 42
kevinbuiied
  • 131
  • 1

4 Answers4

3

You sure could. Make sure the 12V supply is able to accept current flowing into it, as well as providing current flowing out.

But it's more efficient to use an "H-bridge" circuit to reverse both ends.
To move in one direction, you put one end at 0V and the other end at 24V.
To move in the other direction, you put one end at 24V and the other end at 0V.

The half-H-bridge is just a pair of switches, one to 24V and one to 0V, so that the output can be either 24V or 0V depending on which one you turn on. Turning on both at the same time creates a short circuit, so don't do that. The H-bridge is just two halves, one for each end of the solenoid.

Of course, the solenoid has to be mechanically designed to work in both directions, too. There's no point moving a solenoid both ways, if one way causes it to bump into an end stop and not move.

The solenoid must use a permanent magnet in the moving piece, because iron that isn't magnetized will be attracted to either a north or south field equally well - reversing the current will reverse the magnetic field but that won't achieve anything.

user253751
  • 12,469
  • 2
  • 22
  • 37
  • 1
    Just a note: Reversing current on a solenoid does not reverse its direction. – John Birckhead Apr 11 '23 at 18:50
  • 4
    @JohnBirckhead I suppose that depends on the type of solenoid since it will reverse the polarity of the magnetic field. If your solenoid uses a permanent magnet it will move in the other direction. If it doesn't, it won't since unmagnetized iron is just as well attracted to any magnet no matter which way is north. – user253751 Apr 11 '23 at 18:53
  • 1
    Most bi-directional solenoids have two coils and two magnetic paths to provide force in both directions. There are latching ones with permanent magnets to hold a solenoid in place, which can be released with reverse current plus a return spring. Just using the field to repel isn't usually a good approach; the force falls off quickly. If the magnet is the moving piece, I would call it a linear motor or a voice coil. I just wanted to be clear that a practical solenoid does not generate force in more than one direction. But your point is valid. – John Birckhead Apr 11 '23 at 22:43
0

Could you use an opamp to raise and lower S2 to control the flow of current through the solenoid?

Thats fine, there are a few problems. One is overvoltage from the solenoid actuating. If it simply to turn the solenoid on and off, then an opamp would be an expensive way to do this.

You can use hit and hold if circuits if you need different current/voltage levels: How do I use a hit and hold circuit with a solenoid?

Voltage Spike
  • 82,181
  • 41
  • 84
  • 220
0

It would work, but an op-amp is not only an overkill, but you haven't solved the problem of how to interface said op-amp to the microcontroller. Never mind that you need two supply voltages, and the 12V supply must handle bidirectional loads, i.e. both sourcing and sinking current, so in practice you'd have to e.g. parallel a 7812 and a 7912 so that both current directions would be handled.

Instead, as has been suggested, this is normally done using a bridge driver. They can be bought as a "whole thing in a single IC", or implemented with discrete parts. And it only needs a single 12V supply for a 12V solenoid.

A discrete bridge driver:

schematic

simulate this circuit – Schematic created using CircuitLab

A discrete bridge driver controller with 3.3V/TTL/5V CMOS logic inputs:

schematic

simulate this circuit

Now, I'd just use a bridge driver chip, but if you got the discrete parts handy, that's another approach.

Connect the inputs of the two remaining NAND gates to GND - they cannot be left floating.

0

Another way to do this is with a SPDT relay. As with moat of the other responses, this works only if the 12 V supply can both source and sink the required solenoid current.

AnalogKid
  • 19,998
  • 1
  • 13
  • 32