Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Square wave with zero crossing?

Status
Not open for further replies.

ChrisCam

New Member
Hi all,

I have what seems like a simple problem, but I've been unable to find the solution.

I am using a PIC to generate a square wave. The problem is that the piece of equipment to which I'm sending the square wave requires the wave to cross through zero volts - so in other words, instead of a 0-5V square wave that the PIC generates, I need to make it into -2.5V -> +2.5V. Or -5V to plus 5V. It doesn't matter what the voltages are, as long as they're approximately the same, and the signal crosses through zero volts.

Is there some sort of chip or circuit I can use to do this?

Thanks in advance,

Chris C.
 
Hi all,

I have what seems like a simple problem, but I've been unable to find the solution.

I am using a PIC to generate a square wave. The problem is that the piece of equipment to which I'm sending the square wave requires the wave to cross through zero volts - so in other words, instead of a 0-5V square wave that the PIC generates, I need to make it into -2.5V -> +2.5V. Or -5V to plus 5V. It doesn't matter what the voltages are, as long as they're approximately the same, and the signal crosses through zero volts.

Is there some sort of chip or circuit I can use to do this?

Thanks in advance,

Chris C.

hi,
An OPA with a gain of 1 and a 2.5V offset would do the job.:)

What frequency range are you working with.?
 
Last edited:
Thanks for your help!

This particular circuit has a maximum frequency of about 8KHz - not very high.

I'm assuming that I have to power the Op-Amp with both V+ and V-, correct? Since this isn't my area of expertise, if you could recommend a P/N, that would be great!

Thanks again,

Chris C.
 
Thanks for your help!

This particular circuit has a maximum frequency of about 8KHz - not very high.

I'm assuming that I have to power the Op-Amp with both V+ and V-, correct? Since this isn't my area of expertise, if you could recommend a P/N, that would be great!

Thanks again,

Chris C.

hi,
Look at this image.
Its for +/-2.5Vout
If you want to goto +/-5Vout the +/-5V supplies have to be +/-9V
also the feedback resistor has to be increased.

Blue is input, Red is output

EDIT:
If you think you can build this, Ill post a complete circuit diagram
 

Attachments

  • Shift5Va.gif
    Shift5Va.gif
    21.5 KB · Views: 460
Last edited:
Thanks!

Wow, thanks a lot!

That is exactly what I was looking for.

I can certainly build that - looks pretty simple.

Of course, my next dumb question would be, how do I create the negative and positive supply voltages? This circuit is meant to operate in a a car, where all I have is +12V. I understand how to use a 7805 to make +5V, but how do I then make -5V?

Thanks again,

Chris C.
 
Last edited:
AC couple the signal and referance back to ground.
From the PIC run the signal through a 0.1uf capacitor. Then connect the output to ground with a 10k resistor. Now the signal will center around 0 volts and swing +/-2.5 volts.
 
now how come i tried a similar circuit in multisim and the program went bazurk (meaning in practical terms that I can't do it as a simulation) I thought it such a simple circuit. I want to bring the ramp waveform of the condenser in a 555 timer circuit down to 0 rather than starting at 0.33 of the supply voltage
 
Thanks everyone for your help.

Eric, when you get a chance, could you post the entire circuit if you have it handy?
Can I use an inverter chip (ISL7660, e.g.) to make the negative voltage supply?

Ron, I'm going to try your method with the cap and resistor - but I'm concerned about it working over the range of frequencies that I need it to work over - which is from around 200Hz to around 8KHz. What will happen at very low frequencies?

Thanks again everyone for your help.

Cheers,

Chris C.
 
Thanks everyone for your help.

Eric, when you get a chance, could you post the entire circuit if you have it handy?
Can I use an inverter chip (ISL7660, e.g.) to make the negative voltage supply?

Ron, I'm going to try your method with the cap and resistor - but I'm concerned about it working over the range of frequencies that I need it to work over - which is from around 200Hz to around 8KHz. What will happen at very low frequencies?

Thanks again everyone for your help.

Cheers,

Chris C.

hi Chris,
I'll draw up the circuit and post in next couple of days.

I'll also run Rons idea, over that range of frequencies, let you know.
 
I did not see the 200 to 8khz range I only was thinking about 8khz.
A 0.1uf + 10k will have a 160hz high pass effect. At 8khz you will not see much effect. At 200 hz the square wave will be distorted.
If the capacitor was a 10uF ele. cap then the high pass corner will happen at 1.6hz.
This assumes your load (the equipment you are driving) is high Z (100k ohms or more). If you load is 50 ohms then you need 100uF 6.3 volt cap. (30hz high pass)
 
Thanks - I see

I understand - I'm not sure how important the shape of the signal is, as long as there is a zero crossing, and unfortunately, the input impedence of the target device is unknown. I think the best way may be to experiment.

The original input to the device is a magnetic gear tooth sensor that has a sine wave output. I'm trying to modify the timing of the signal with the PIC, and send it back to the device.

I'll let you know how the experiments go.

Thanks again,

Chris C.
 
hi,
Using LTSpics sim, shows that for a range of 200Hz thru 8KHz using the cap coupling circuit, the square wave for some frequencies pass thru without the required V/2 offset.
 
Say what? If you AC couple and referance back to GND it must center at ground. If the RC time constant is 0.1 second, then spice may need to simulate out for 200mS to get the right results.
 
Say what? If you AC couple and referance back to GND it must center at ground. If the RC time constant is 0.1 second, then spice may need to simulate out for 200mS to get the right results.

hi Ron,
If you use LTS, can you run a simulation for 200Hz and 8Khz, using 10uF/100K and 100uF/50R.

My runs suggest that the settling times are much longer than 1 sec.
 
Eric, I agree that it will take time. I was thinking that creating -5 volts from +5 and adding op-amp etc will take time to solder up. Just use a capacitor and maybe a resistor and your done. With a RC=0.1 sec it should be very very close in 1 second. Look at the RC charge up curve. In 10 time constants you are very close. He is just driving a frequency counter machine that usually gets a sign wave. If the center is off by 30% there will be no problem. In time the center will be 0.

I am in business where increasing the cost by $.01 causes much pain. We have to add more functions and get a 30% price reduction every year.
 
Actually, now that I understand I little bit more - I think I need the op-amp solution.

The timing of the pulses is very important - and constantly changing. The whole purpose of the PIC is to modify the timing of the pulses - so if the pulses are delayed by the RC circuit, then I won't have achieved my goal.

The op-amp solution will have very fast response time (I'm sure fast enough), and will work at all frequencies - correct? I'd rather have more circuitry than a mis-timed signal.

Again, thanks for all of your help.

Chris C.
 
Actually, now that I understand I little bit more - I think I need the op-amp solution.

The timing of the pulses is very important - and constantly changing. The whole purpose of the PIC is to modify the timing of the pulses - so if the pulses are delayed by the RC circuit, then I won't have achieved my goal.

The op-amp solution will have very fast response time (I'm sure fast enough), and will work at all frequencies - correct? I'd rather have more circuitry than a mis-timed signal.

Again, thanks for all of your help.

Chris C.

hi Chris,
I did think initially you had a -V supply on the existing circuit that could be used by the OPA, the CA3140 costs about 60pence GB.
We could use a 7660 for the -V as you suggest.

The point is adding this extra cost brings the total cost close to a MAX232 solution.
The only downside in using the MAX is that the output swing would be in the order of +/-9V.
You could reduce this to a lower voltage by using resistors and zeners.

Get the MAX232 datasheet and check to see if it would be suitable.

Ron,
My concern in using the R/C method, is that as the input frequency is changing from 200Hz thru 8KHz and the 'load' device is counting the zero crossing points.
There is a chance some thru zero swings, after a pause in the incoming pulses, could be missed.

Like you Ron, I had my own company for many years and I appreciate the savings that have to be considered.
I thought this is a 'one off' project.??
 
Thanks for your help!

This particular circuit has a maximum frequency of about 8KHz - not very high.

I'm assuming that I have to power the Op-Amp with both V+ and V-, correct? Since this isn't my area of expertise, if you could recommend a P/N, that would be great!

Thanks again,

Chris C.

In your case, I would something simpler: a diode and a 2.5 V battery in parallel with a resistor will do the trick. look at the circuit below: E here in your case should be 2.5, that way you will get 5 V square wave centered around 0V. the 0-5 V wave will be pulled down to -2.5V.
 

Attachments

  • Doc1.doc
    40.5 KB · Views: 200
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top