# Convert Sawtooth to square wave

#### DebiP

Joined Jul 27, 2021
18
HI Please, can anyone help in realising a circuit (Ltspice) to convert a saw tooth signal to a square waveform. Please, see below for the image.
The green spikes are the original oscillation signal. And blue is the envelope signal. I need to convert the blue envelope to a square wave.

Thanks

#### Attachments

• 83 KB Views: 49

#### Papabravo

Joined Feb 24, 2006
21,005
Why not generate the square wave directly?
A retriggerable monostable should do the job.

#### DebiP

Joined Jul 27, 2021
18
HI Thanks

But the oscillation signals are from a sensor which generates spikes. I need to convert a bunch of spikes to a square wave.

#### IgorZg

Joined Jul 10, 2021
5
HI Thanks

But the oscillation signals are from a sensor which generates spikes. I need to convert a bunch of spikes to a square wave.
Schmitt trigger?

#### DebiP

Joined Jul 27, 2021
18
Schmitt trigger?
Thanks.. I think so.. A Schmitt trigger may work. Please, can I get a schmitt trigger circuit for a sawtooth wave form with similar voltage range. I need the square wave to be between 0 and 1. The frequency is between 7-20Hz.

#### IgorZg

Joined Jul 10, 2021
5
Now I take look more closely, for such low voltage schmitt trigger digital IC won't work. But what will work is opamp as comparator.

#### DebiP

Joined Jul 27, 2021
18
Now I take look more closely, for such low voltage schmitt trigger digital IC won't work. But what will work is opamp as comparator.
Thanks...
Can you help me with a circuit for similar voltage values.

#### IgorZg

Joined Jul 10, 2021
5
I dont't know nothing about rest of your circuits, about problem yo try to solve. The comaparator is the part of basics, there are plenty of educational material out there about.

#### crutschow

Joined Mar 14, 2008
34,047
Do you need to detect every triangle peak even if it only returns to a slightly smaller voltage than the peak (example below)?

What is generating the triangle wave?

#### DebiP

Joined Jul 27, 2021
18
Do you need to detect every triangle peak even if it only returns to a slightly smaller voltage than the peak (example below)?

View attachment 244547

What is generating the triangle wave?
HI

No, I would like to bunch the triangular peaks close to each other. See example below

#### Attachments

• 98.4 KB Views: 26

#### crutschow

Joined Mar 14, 2008
34,047
I would like to bunch the triangular peaks close to each other.
Okay.
Then a comparator such as the LM339/393 with input biased to the voltage you want to detect should work for you.
Do you know what the low voltage is, above which you want to generate a high for the square-wave?

#### LesJones

Joined Jan 8, 2017
4,173
I don't know what you want the square wave for but here is a suggestion that will give a square wave but it is probably half the frequency you require. Differentiate the positive going edge of the sawtooth wave and use it to toggle a flipflop. You will probably have to amplify to deal with when the positive edge is of a low amplitude.
The problem you have generating the square wave that you require is there is no way to know when to generate the negative going edge of the square wave until the next positive edge of the sawtooth. I think you could generate a slightly delayed version of the square wave you require using a microcontroller that measured the time between positive edges of the sawtooth. It could then divide this value by 2 to create the negative edge of the square wave. The microcontroller would make the positive edge of the square wave when the positive edge of the sawtooth occurred and create the negative edge after half the gap between the previous two positive edges. This would mean the generated square wave would be one cycle behind the sawtooth waveform.

Les.

#### LowQCab

Joined Nov 6, 2012
3,939
You would get much better answers if You would explain what the overall
problem is that You are trying to find a solution for.

And don't forget to provide Schematics,
words can only convey a limited amount of information.
.
.
.

#### Ian0

Joined Aug 7, 2020
9,503
Perhaps you could draw on the original waveform the square-wave you are hoping to generate, then we could probably work out how to do it.

#### crutschow

Joined Mar 14, 2008
34,047
Perhaps you could draw on the original waveform the square-wave you are hoping to generate, then we could probably work out how to do it.
He did a rough stab at that in post #10.

#### MrChips

Joined Oct 2, 2009
30,493
Forget the spikes, the sawtooth waves and a solution for a moment.
Tell us what is generating the signal and what it is you are trying to measure or do with the signal.

#### DebiP

Joined Jul 27, 2021
18
Okay.
Then a comparator such as the LM339/393 with input biased to the voltage you want to detect should work for you.
Do you know what the low voltage is, above which you want to generate a high for the square-wave?
Thanks for the response, the low threshold will be about >200mv

#### DebiP

Joined Jul 27, 2021
18
Forget the spikes, the sawtooth waves and a solution for a moment.
Tell us what is generating the signal and what it is you are trying to measure or do with the signal.
The spikes are generated by a sensor which oscillates on applying a voltage pulse. The spikes are stochastic and can vary in amplitude. I have managed to create an envelope across the the spikes. The envelope are a sawtooth wave. I wish to convert these sawtooth envelope to square wave.

#### DebiP

Joined Jul 27, 2021
18
You would get much better answers if You would explain what the overall
problem is that You are trying to find a solution for.

And don't forget to provide Schematics,
words can only convey a limited amount of information.
.
.
.
I would have provided a schematic if I had one. Sorry. At this moment. i have the generated sawtooth envelope. I need a circuit which can convert these to a square wave.

#### MrChips

Joined Oct 2, 2009
30,493
The spikes are generated by a sensor which oscillates on applying a voltage pulse. The spikes are stochastic and can vary in amplitude. I have managed to create an envelope across the the spikes. The envelope are a sawtooth wave. I wish to convert these sawtooth envelope to square wave.
This tells us nothing that you have not told us already.
Thanks for nothing.
Sorry, I have nothing else to offer.