Author Topic: Convert a 0 to +5 signal to a +/-5 signal  (Read 3833 times)

0 Members and 1 Guest are viewing this topic.

Offline StonentTopic starter

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Convert a 0 to +5 signal to a +/-5 signal
« on: June 09, 2014, 04:32:36 pm »
I need to convert a 0 to +5 square wave into a +5 to -5 signal. The signal is being generated by a microcontroller and the resulting +/-5 needs to be able to drive a small electromagnet that's about 220 Ohms.

Nothing in the circuit is voltage or timing critical in fact the solenoid works fine from an AA battery. I just chose +/-5 so I didn't have to get two voltage sources.

It would seem that you could build a circuit with an NPN and PNP transistor but I'm having trouble figuring out how wire it correctly.

The circuit will not be at a fixed frequency but I doubt it will go over a few hundred hertz just because the reaction time electromagnet. I suppose ideally I would like the ability to have a +5, 0 and -5 rather than just either being +5 or -5.  I can use more than one I/O pin on the mcu if needed, but it would seem that you could express this with a tri-state setup with +5 being +5, input being 0, and Gnd being -5.
« Last Edit: June 09, 2014, 04:34:45 pm by Stonent »
The larger the government, the smaller the citizen.
 

Offline mazurov

  • Frequent Contributor
  • **
  • Posts: 524
  • Country: us
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #1 on: June 09, 2014, 04:43:06 pm »
You can try MAX232 TTL to RS-232 converter. The output voltage will be higher though.
With sufficient thrust, pigs fly just fine - RFC1925
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #2 on: June 09, 2014, 04:44:25 pm »
You can do it with an op-amp...

For -5/0/+5 output, just use 2 identical resistors on two pins for 0/2.5/5 in.

If the electromagnet is not grounded, just drive it with two 0/5V signals.
« Last Edit: June 09, 2014, 04:52:44 pm by oPossum »
 

Offline StonentTopic starter

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #3 on: June 09, 2014, 04:58:02 pm »
I suppose also going to +/- 2.5V would work as well.

I have quite a few transistors I can spare, mostly PN2222, 3904 and 3906, but not any OpAmps. 

The project is a part of the time machine display for my wife's classroom, the signal is needed to drive the wall clock's ticking so I can speed it up and slow it down.

From what I discovered yesterday, to complete a tick, the signal has to go over and under 0, not just positive and zero. If I just pulse on and off the second hand ticks forward and falls back to where it was.  When I looked at the signal on my oscilloscope I saw how it was going over and under 0 volts.

I know I could use other sources for the signal but since I plan to use a microcontroller in other parts of the display I figured I'd include it in this part as well.
The larger the government, the smaller the citizen.
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #4 on: June 09, 2014, 05:30:00 pm »
Oh, it's a clock solenoid.

Try 2 output pins with a ~330 ohm series resistor. That will give you bipolar drive and should have enough current for that little solenoid.

Code: [Select]
Out 1    Out 2  Solenoid
Low      Low      0
High     Low      +
Low      High     -
High     High     0
 

Offline StonentTopic starter

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #5 on: June 09, 2014, 06:00:00 pm »
Oh, it's a clock solenoid.

Try 2 output pins with a ~330 ohm series resistor. That will give you bipolar drive and should have enough current for that little solenoid.

Code: [Select]
Out 1    Out 2  Solenoid
Low      Low      0
High     Low      +
Low      High     -
High     High     0

Thanks.  Do you think there's much risk when the field collapses on the transition that it could kick back and damage anything, or would the 330R resistors be enough for that?
The larger the government, the smaller the citizen.
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #6 on: June 09, 2014, 06:11:52 pm »
Why not make a small H-bridge? That way you also avoid the potential inductive kickback of the coil damaging the micro.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #7 on: June 09, 2014, 06:14:30 pm »
It's on the edge of what a micro will tolerate.  You could buffer it with almost any buffer/inverter chip (74x04, 74x125, 74x244, etc...) or use your 2N3904/2N3906 as an emitter follower (common collector amp).
« Last Edit: June 09, 2014, 06:23:46 pm by oPossum »
 

Offline StonentTopic starter

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Convert a 0 to +5 signal to a +/-5 signal
« Reply #8 on: June 11, 2014, 05:29:41 pm »
I was able to drive the clock last night.  Unfortunately even with the resistor recommendations it didn't have enough current to force a tick over.  So what I ended up doing is putting a potentiometer in series and adjusting down until I could get it going with the final outcome being a 100 ohm resistor in series with the MCU pins.  I have to short the resistor to get it to start moving the gears and then remove the short so it can continue off of the 100 Ohm resistor.

The pulses I ended up with are to invert every 18ms.  17ms seems to have a little trouble starting sometimes, but 18 seems stable.  As of yet I haven't figured out a way to control the direction other than repeatedly resetting the power or tapping the second hand while it is in motion to cause it to change direction.

At the current rate of speed the minute hand moves at about the rate the second hand used to move.

I suspect the original wave form had something to do with keeping it in the same direction all the time.  I'm pretty much using a square wave right now, but I haven't scoped it out yet.

When I was looking at the original wave form, it looked sort of like this. (Not to time scale)



So the upside had a curve up and the down side had a curve down.  Due to the slowness of the spacing I can't get the up and down curve on my analog scope on the same screen.  That's also the reason I don't see a vertical line, it just shuts the power off at the end.
The larger the government, the smaller the citizen.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf