Go Down

### Topic: How to generate square wave pulses >5V? (Read 6420 times)previous topic - next topic

#### Cloverleaf

##### Jul 12, 2012, 12:47 am
I'm trying to use an arduino Uno to replace an older piece of equipment--a Grass SS88 square pulse generator.  I don't need to reproduce the broad range of function, just a particular set.  Specifically, I need to generate square wave pulses in a range of 1-10V, duration from 0.1-10 ms, and at a frequency up to 200 Hz.

I'm not experienced with electronics, but I've found a few ideas to start from.  Particularly, using a relay to open/close a circuit at the desired voltage; however, I'm not sure of the relay's response time.  I've also seen TRIACs mentioned, though I'm not clear how to use them.

In addition to controlling the open/closed state of the circuit, I'm looking for a way to reliably control the voltage on a 0.1-10ms time frame.  I've seen diagrams that combine a capacitor and resistor to produce a low-pass filter that, combined with PWM duty time, can serve as a sort of analog control for voltage but the ramp up time is relatively long compared with the ideal pulse duration.  Currently I'm set up with a 12V wall mart adapter plugged into a voltage regulator to bring the voltage down to 9V.  If fine-tune control over the voltage from 1-10V is complicated, I could instead use a fixed voltage of 7V (the range of 1-10V is merely to extend the flexibility of the device to projects which haven't been thought of yet and not a necessity).

Thanks for your time.  Let me know if there are any bits of information missing, I'm afraid I'm too new to the electronics side of this to know if I've left anything out.

#### Magician

#1
##### Jul 12, 2012, 02:15 am
Start from the theory: http://www.electronics-tutorials.ws/transistor/tran_4.html
To generate different freq. with 50% duty cycle you can use Tone: http://arduino.cc/en/Reference/HomePage
To generate pulses, with variable duration, same freq. use analogWrite on PWM pin,
and to mix both , freq. and duty cycles, look into library with TIMER's: http://arduino.cc/en/Reference/Libraries

#### MarkT

#2
##### Jul 12, 2012, 12:05 pm
Are the pulses to be positive only (0V to 10V range) or do you want bipolar pulses (-5V..+5V)?  How much output current does it need to supply?

I'd suggest an opamp-circuit to amplify the Arduino logic output using a potentiometer to vary the gain.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### Cloverleaf

#3
##### Jul 15, 2012, 03:13 am
Thanks  for the reading. I'm working my way through it.

The voltage needs to be positive +0 to +10.  The current I'm not sure of, but probably in the 100 milliamperes range. I'll do some reading about op-amps. I saw one in a diagram for a square pulse generator so I think you're on to something.

Thanks

#### PiJoy

#4
##### Jul 16, 2012, 07:02 am

I'm trying to use an arduino Uno to replace an older piece of equipment--a Grass SS88 square pulse generator.  I don't need to reproduce the broad range of function, just a particular set.  Specifically, I need to generate square wave pulses in a range of 1-10V, duration from 0.1-10 ms, and at a frequency up to 200 Hz.

I'm not experienced with electronics, but I've found a few ideas to start from.  Particularly, using a relay to open/close a circuit at the desired voltage; however, I'm not sure of the relay's response time.  I've also seen TRIACs mentioned, though I'm not clear how to use them.

In addition to controlling the open/closed state of the circuit, I'm looking for a way to reliably control the voltage on a 0.1-10ms time frame.  I've seen diagrams that combine a capacitor and resistor to produce a low-pass filter that, combined with PWM duty time, can serve as a sort of analog control for voltage but the ramp up time is relatively long compared with the ideal pulse duration.  Currently I'm set up with a 12V wall mart adapter plugged into a voltage regulator to bring the voltage down to 9V.  If fine-tune control over the voltage from 1-10V is complicated, I could instead use a fixed voltage of 7V (the range of 1-10V is merely to extend the flexibility of the device to projects which haven't been thought of yet and not a necessity).

Thanks for your time.  Let me know if there are any bits of information missing, I'm afraid I'm too new to the electronics side of this to know if I've left anything out.

@Cloverleaf,

If what you need is just digital pulses, it's pretty simple.  If I recall correctly, most Grass devices give you a modest (tens of mA) "courtesy power supply (? +12V or so) that you can tap off from.  Simple open-collector drives (ULN2803) is available in a through-hole package (perfect for protoboarding) and would probably do fine, up to tens of mA.  But a TIP121, with an input resistor and (for safety) a diode to protect from reverse-voltage transients from any inductance lurking can really sink some serious current (Amps, if properly heat sunk.  For analog (variable) voltages, an OpAmp is your friend, and can source or sink at least 5 mA without letting the magic smoke out; add a push-pull pair after the OpAmp if you need more current.  If you don't need to control 120 VAC, you can  get away without the hassle of Triacs.

Hope this helps!

#5
##### Jul 16, 2012, 07:25 amLast Edit: Jul 16, 2012, 07:27 am by CrossRoads Reason: 1
If you just need the one output, than an arduino output pin driving an NPN transistor such as 2N2222A with 1K pullup to 10V on the collector is all you need.
If you need several outputs, than ULN2003 or ULN2803 is really convenient for bundling several transistors into one package.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Cloverleaf

#6
##### Jul 17, 2012, 11:19 pm
The 2N2222A with 1K pullup on the collector seems to reproduce what I need on the oscilloscope; however, the output is in the is only in the 5V.  I assume that is because I have the collector attached to the 5V source on the arduino.  If I change this to a 12V source from a wall mart style 12V DC plug I assume I'll have access to a range up about 12V, which I'll adjust manually using a potentiostat.  I think this is my solution.  Thanks for the help!