Author Topic: Turn a sine wave into a square wave at 275 kHz?  (Read 6459 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris WilsonTopic starter

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: gb
  • Race car engineer, dog lover, hoarder.
Turn a sine wave into a square wave at 275 kHz?
« on: September 04, 2018, 11:31:55 am »
I want to turn its sub 1mW sine wave output from the Drive socket of
my TS-590S from a sine wave to a square wave of similar amplitude to
that from the CLK0 pin of the U3S Si5351A synthesizer chip. Anyone any
ideas for a simple way to do this then I can also use the 590 as a driver
for my 137kHz Class D amp with the X2 functionality in the current WSJT-X software?

The  amp  has  a 50 Ohm input impedance and I have to run the 590 at a
bit under 1mW output level otherwise the sine wave is distorted.

Just  to  clarify, I want to run the TS-590 at   275.1 kHz output from
it's  "Drive"  socket  and  turn  the sine wave to a similar frequency
square  wave  of  similar  amplitude to that from the U3S (a small commercially made TX exciter from QRP Labs) Si chip CLK0
pin. The 590 will TX around 235 kHz no problem. Thanks.

I attach scope screen shots of the Si5351A CLK0 output (at 137.55 kHz) into 50 Ohms and the TS-590S Drive output (at 275.1 kHz) into 50 Ohms.

The amp halves the input frequency at the output FET's. So then TX's at 137.550 kHz.
« Last Edit: September 04, 2018, 11:39:06 am by Chris Wilson »
Best regards,

                 Chris Wilson.
 
The following users thanked this post: iMo

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #1 on: September 04, 2018, 11:42:53 am »
I suppose you want to get 137,5kHz from the 275kHz - so the easiest is to use a divide-by-2 74HC74, that gives you at the same time a 50:50 duty cycle; then you put an attenuator to reach the desired signal level
 
The following users thanked this post: Chris Wilson

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23018
  • Country: gb
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #2 on: September 04, 2018, 11:47:51 am »
You can get a reasonably square output at 275KHz with a 2n3904 switch. Probably can be improved easily. Quick simulation



If you want half that, chuck it through an LVC family flip flop to divide by two. Will square up the edges nicely as well. Can use a 74LVC14 to get a very good 3.3v square wave out at the same frequency as the 1mW drive.

Sounds like an interesting project.

Edit: I use LVC1G14 "little logic" https://assets.nexperia.com/documents/data-sheet/74LVC1G14.pdf . You get 1x schmitt trigger in a SOT23 package. Universal crappy waveform fixer IC :)

Edit 2: just seen your similar post on the QRP labs list :)
« Last Edit: September 04, 2018, 11:54:44 am by bd139 »
 
The following users thanked this post: Chris Wilson

Offline Chris WilsonTopic starter

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: gb
  • Race car engineer, dog lover, hoarder.
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #3 on: September 04, 2018, 11:54:46 am »
Thanks, just to clarify, I  do not need to halve the frequency the driver in the amp already does that, I just need to change to sub 1mW sine wave into a square wave at the same 275kHz frequency.
Best regards,

                 Chris Wilson.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #4 on: September 04, 2018, 03:45:07 pm »
1 milliwatt into 50 ohms is about 230 millivolts which is plenty to directly drive a comparator.  The output of the comparator can be filtered and fed back to the input to maintain a 50% duty cycle if necessary.
 
The following users thanked this post: Chris Wilson

Offline Chris WilsonTopic starter

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: gb
  • Race car engineer, dog lover, hoarder.
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #5 on: September 04, 2018, 03:52:53 pm »
1 milliwatt into 50 ohms is about 230 millivolts which is plenty to directly drive a comparator.  The output of the comparator can be filtered and fed back to the input to maintain a 50% duty cycle if necessary.

Where might I find a practical circuit to build such a device please David? many thanks for the reply and for your awesome contributions to the Tektronix forum, I hope you are the same David Hess, I am pretty sure you are :) Apologies if that is not the case.
Best regards,

                 Chris Wilson.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #6 on: September 04, 2018, 05:29:36 pm »
1 milliwatt into 50 ohms is about 230 millivolts which is plenty to directly drive a comparator.  The output of the comparator can be filtered and fed back to the input to maintain a 50% duty cycle if necessary.

Where might I find a practical circuit to build such a device please David? many thanks for the reply and for your awesome contributions to the Tektronix forum, I hope you are the same David Hess, I am pretty sure you are :) Apologies if that is not the case.

Yea, that's me.  I don't participate these days as much as I would prefer.

The simple solution is to use a comparator as a data slicer as shown in the last example here.  The comparator compares the input signal to an average of the input signal so it automatically adapts to changes in input signal level.

If you need to maintain the lowest phase noise in the output, then some other circuit would probably be more suitable.
 
The following users thanked this post: Chris Wilson

Offline radioactive

  • Regular Contributor
  • *
  • Posts: 173
  • Country: us
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #7 on: September 04, 2018, 05:33:07 pm »
I had the same idea of using a comparator.  I've attached an LTSpice simulation that might get you close to what you are looking for.
 
The following users thanked this post: Chris Wilson

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4767
  • Country: nr
  • It's important to try new things..
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #8 on: September 04, 2018, 05:39:21 pm »
My favorite:
L1C1 is tuned to 275kHz. The amplitude at the HC14's input will be ~4Vpp centered at the Vcc/2.
R3=50ohm is the internal Z of the generator.
« Last Edit: September 04, 2018, 06:04:47 pm by imo »
 
The following users thanked this post: Chris Wilson

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1280
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #9 on: September 05, 2018, 03:58:00 am »
look for the two-transistor square wave circuit used in a number of the devices built by TAPR.org.  It is easy and known to work well.
 
The following users thanked this post: Chris Wilson

Offline Beamin

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #10 on: September 05, 2018, 10:39:38 am »
What's the purpose of doing this? Not a technical question but rather what are you building and what does it do?

How many mA or microA is a typical logic level signal into/out of something like an Arduino at 5 or 3.3V? When building more complex projects at what point do you start to run out of power from the chips alone?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 
The following users thanked this post: Chris Wilson

Offline donmr

  • Regular Contributor
  • *
  • Posts: 155
  • Country: us
  • W7DMR
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #11 on: September 05, 2018, 04:35:25 pm »
The short answer is "amplify and clip".  A comparitor with a Schmidt triggered input will help to keep the transitions clean.  You can find many examples on the web....
 
The following users thanked this post: Chris Wilson

Offline bson

  • Supporter
  • ****
  • Posts: 2269
  • Country: us
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #12 on: September 06, 2018, 06:19:49 am »
What voltage?  If you want logic levels any schmitt trigger inverter will do it.  Like the 74HC14:





Or a 1G SMT variety (74HC1G14) if you only need a single gate.

You could to some extent redefine the output high level by tweaking the supply voltage.

R1 and R2 need to be within ~5% of each other.
 
The following users thanked this post: Chris Wilson

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #13 on: September 06, 2018, 06:44:52 am »
What voltage?

645 mVpp. There's waveform in first post

Quote
If you want logic levels any schmitt trigger inverter will do it.  Like the 74HC14:

Maybe, but hold your horses. Resulting duty cycle can differ from 50%. Does application tolerate different than 50% duty cycle - good question. If strict 50% duty needed then fast comparator is the way.
 
The following users thanked this post: Chris Wilson

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #14 on: September 06, 2018, 06:51:48 am »
Maybe, but hold your horses. Resulting duty cycle can differ from 50%. Does application tolerate different than 50% duty cycle - good question. If strict 50% duty needed then fast comparator is the way.

Seems unlikely that 50% duty cycle is required when the very next step is a divide-by-2; since divide-by-2's by their very nature discard the duty cycle. But there may be specifics to the OP's usecase that I'm not aware of though.
 
The following users thanked this post: Chris Wilson

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4767
  • Country: nr
  • It's important to try new things..
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #15 on: September 06, 2018, 10:16:53 am »
Or a 1G SMT variety (74HC1G14) if you only need a single gate.
Afaik the HC14 hysteresis is 0.9V thus much more than the amplitude OP is feeding in.

My circuit above "amplifies" the signal to full Vcc+0.3 and GND-0.3 at the HC14's input almost "free of charge", thus the HC14 is pretty happy with it.

Also it suppresses a possible jitter significantly (LC filters out the harmonics). With the LC values above it fits the 275kHz, the L and C are standard off-the-shelf values, btw.

PS: How it works: the input C1L1 works as a parallel tuned resonant tank, fed by low-Z source, therefore creating large amplitude at the HC14's input (it is a high-Z side of the resonant circuit).

The amplitude at the HC14 input is only limited by the HC14's clamping diodes (and the other limit is the Q of the LC). Therefore the edges at the HC14's input are already quite steep with full Vcc+0.6V p-p amplitude.

From DC perspective the HC14's input is kept at Vcc/2 (the two 10k resistors). The middle of the divider must be AC grounded via the 1uF capacitor (could be 100n..1u ceramic) - because the AC grounding closes up the "parallel LC tank circuit"..
« Last Edit: September 06, 2018, 10:58:21 am by imo »
 
The following users thanked this post: Chris Wilson

Offline bloguetronica

  • Frequent Contributor
  • **
  • !
  • Posts: 354
  • Country: pt
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #16 on: September 06, 2018, 11:08:58 am »
Hi,

I had my fair share of success when using the circuit attached, that uses an high-speed comparator and has hysteresis to filter out noise. It can go up to 25MHz easily (but mileage may vary, as that depends on the amplitude of the signal). You may want to adapt it to your own needs, though. Mind that the hysteresis is around 21.4mV. The input is "ANA5" and the output is "CMPO".

Note that, by principle, if you reduce the hysteresis you'll have more sensitivity and have less delay between the original sine and the square wave. You can eliminate R30 and replace R29 by a direct connection, to get an hysteresis of just 6mV. However, your circuit may not be no longer immune to noise. It is a matter of testing in situ.

Kind regards, Samuel Lourenço
« Last Edit: September 06, 2018, 11:20:11 am by bloguetronica »
 
The following users thanked this post: Chris Wilson

Online coppercone2

  • Super Contributor
  • ***
  • Posts: 9422
  • Country: us
  • $
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #17 on: September 06, 2018, 06:52:09 pm »
If you want a HIGH quality square wave look at advanced linear devices (ALD) comparators, they have low offset comparators which should give you low phase noise from the zero crossing drift. I would expect a ordinary logic gate to be fairly shitty in comparison.

http://www.aldinc.com/ald_ultravcomp.php

You should have some kind of schmitt trigger circuit.

The offset voltage for a low VOS comparator is ~50-200uV, compared to something like 2-20mV for a traditional one.
The drift in offset voltage will result in variable trigger point. I think you said your signal is 600mV

0.2/600 = 0.03% error
25/600= 4.1 % error

You can trim it, but you still have thermal drift.

This part should be nice:
http://www.aldinc.com/pdf/ALD2321.pdf

300ns rise time

If you subsequently speed it up obviously your gonna inherit the offset from the next comparator circuit.

since the ALD is very high Z you wanna filter it nicely, but you will be dealing with a 5V signal at this point, so any incured offset error will be drastically reduced. I don't renember i the ALD part put out a bipolar output, if it does you can use a LT1016 10ns comparator to condition it to a 5V output.
« Last Edit: September 06, 2018, 07:11:38 pm by coppercone2 »
 
The following users thanked this post: Chris Wilson

Offline radioactive

  • Regular Contributor
  • *
  • Posts: 173
  • Country: us
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #18 on: September 06, 2018, 07:20:14 pm »
According to some,  you can get 74xx inverters to "square up" by putting several gates in parallel for a clocking application.
 
The following users thanked this post: Chris Wilson

Offline bson

  • Supporter
  • ****
  • Posts: 2269
  • Country: us
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #19 on: September 07, 2018, 03:47:25 am »
Afaik the HC14 hysteresis is 0.9V thus much more than the amplitude OP is feeding in.
I measured it to just over 0.5V on a couple of different TI 74HC14's I have (DIP), with a 3.3V supply.  This is why it's important to know what the logic voltage is, because the hysteresis depends on the supply voltage.  I never got an answer to that.

Unless the cable is ridiculously long or the source does load detection, there's zero benefit in terminating a 275 kHz signal into a 50ohm load.  It's just a pure voltage signal.  Power is irrelevant.  Use a shielded cable and terminate it into e.g. 22k.  This will produce a stronger signal.
 
The following users thanked this post: Chris Wilson

Offline bloguetronica

  • Frequent Contributor
  • **
  • !
  • Posts: 354
  • Country: pt
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #20 on: September 07, 2018, 09:28:57 am »
Afaik the HC14 hysteresis is 0.9V thus much more than the amplitude OP is feeding in.
I measured it to just over 0.5V on a couple of different TI 74HC14's I have (DIP), with a 3.3V supply.  This is why it's important to know what the logic voltage is, because the hysteresis depends on the supply voltage.  I never got an answer to that.

Unless the cable is ridiculously long or the source does load detection, there's zero benefit in terminating a 275 kHz signal into a 50ohm load.  It's just a pure voltage signal.  Power is irrelevant.  Use a shielded cable and terminate it into e.g. 22k.  This will produce a stronger signal.
Admitting that hysteresis is important, which in fact is, you should use a comparator for your first stage. It is a bad idea do use logic directly for that, especially when dealing with signals that only have 600mVpp of amplitude. It is not guaranteed that you'll always get a decent signal out, and if you do, it may as well not having a 50% duty cycle. The hysteresis of a Schmitt trigger is not finely tuned and will depend on many factors, and not just supply. To aggravate, the output signal will be out of sync.

You are much better off using a comparator, since that you can even adjust the amount of hysteresis you wish. Plus, there are very fast comparators on the market.

For example, this is what I got with the schematic shown in my post above. Notice that the analog signal you see is an amplified version (2.43x) of the signal going to the comparator. The digital signal is generated by the comparator, but going through a clock buffer before the output. Both outputs were terminated. See the image attached. The schematic may help, but is there just for reference.

Kind regards, Samuel Lourenço
« Last Edit: September 07, 2018, 09:34:26 am by bloguetronica »
 
The following users thanked this post: Chris Wilson

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #21 on: September 07, 2018, 06:58:26 pm »
According to some,  you can get 74xx inverters to "square up" by putting several gates in parallel for a clocking application.

This works but you have to somehow bias them into their linear range.  A feedback resistor is used to do this with gate based crystal oscillators.

Differential input stages have the advantage of power supply rejection so they will always have lower noise than single ended logic stages.  Phase noise can be lowered by amplifying the signal before comparison so less time is spent in the transition zone.  For singled ended logic gate, the power connections can be decoupled.

« Last Edit: September 08, 2018, 06:16:19 am by David Hess »
 
The following users thanked this post: Chris Wilson

Online coppercone2

  • Super Contributor
  • ***
  • Posts: 9422
  • Country: us
  • $
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #22 on: September 07, 2018, 08:04:47 pm »
what is the offset voltage on one of those logic gates, where do you go from the ideal 50%?
 

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1280
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #23 on: September 07, 2018, 09:22:23 pm »
Go here and look at the two-transistor generator about half way down:

http://www.wenzel.com/documents/waveform.html
 
The following users thanked this post: Chris Wilson

Offline Chris WilsonTopic starter

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: gb
  • Race car engineer, dog lover, hoarder.
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #24 on: September 08, 2018, 12:37:53 pm »
Go here and look at the two-transistor generator about half way down:

http://www.wenzel.com/documents/waveform.html


Wow, been working away and come back to so many helpful posts, thanks very much to you all!

I have started by knocking together on strip board cncjerry 's circuit recommendation., as I had all the bits handy. It works but the output waveform is very unbalanced, I'll attach scope screenshots and 2 photos of the device itself. Tried a 50 ohm resistor input to ground before the 0.01uF ceramic, no good. tried varying voltage to the circuit, only amplitude changes. tried increasing capacitance of the 0.01uF across the 6.8k, no good. Have I done something wrong? Tanks again,, I may have components for one of the other ideas, will check meanwhile.
« Last Edit: September 08, 2018, 12:39:28 pm by Chris Wilson »
Best regards,

                 Chris Wilson.
 

Offline bloguetronica

  • Frequent Contributor
  • **
  • !
  • Posts: 354
  • Country: pt
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #25 on: September 08, 2018, 03:40:48 pm »
Hi,

Any reason why you are using discrete components? You can use a comparator for such a low frequency. You don't need to use transistors, IMHO. And besides the uneven duty cycle, the slew rate is not the best.

Kind regards, Samuel Lourenço
 
The following users thanked this post: Chris Wilson

Offline Chris WilsonTopic starter

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: gb
  • Race car engineer, dog lover, hoarder.
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #26 on: September 08, 2018, 04:09:20 pm »
Hi,

Any reason why you are using discrete components? You can use a comparator for such a low frequency. You don't need to use transistors, IMHO. And besides the uneven duty cycle, the slew rate is not the best.

Kind regards, Samuel Lourenço

Just because it was a simple circuit and I had the bits in the junk box really. I may try and find a suitable IC and try something else. Thanks
Best regards,

                 Chris Wilson.
 

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1280
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #27 on: September 08, 2018, 09:05:27 pm »
I use a 9V power supply on the two transistors and this generates a very nice square wave with 138ns rise time, 50.0% positive duty cycle, 4.78V across the load resistor, with a 0dBm signal input.  With a -10dBm signal, I get a duty cycle of 48.8% at the same voltage but the rise time drops to 430ns.  I drive a PIC 12F675 programmed by John Miles, I thought, to use for dividing a 10Mhz signal down by 1000.  I pulled the load off and I still had the same output results so I think there is something wrong with your circuit.  Using 5V Vdc gives again a nice square wave of 1.86V output on the resistor with a duty cycle of 50.8%.  I don't have my GPIB or ethernet attached to the scope to make a picture.


Though it doesn't matter in your application, I can't remember if John sent me the chip or I programmed it myself.  I also don't remember what I was trying to accomplish but it was the front end to a timing application and I think I was using it as a scale for Alan Deviation testing..  I still have the board built if you need help.


Jerry
 

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1280
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #28 on: September 08, 2018, 09:36:55 pm »
By the way, I use a transformer as in the input for the TADD-2 by TAPR:

https://www.tapr.org/~n8ur/TADD-2_Manual.pdf

Otherwise it is the same circuit.  I have the TADD-2 and it works exceptionally well for dividing down signals.  The 12F675 programmed though, is much simpler.  I am driving the base of the first transistor at 488mv P-P which is slightly lower than what you had spec'ed in your post.  This is on the base, not as an input to the transformer, which is an MCL T1-6T I think.  But if your input can handle the drive, you can take the transformer out and use a 50ohm resistor to ground with the cap going to the base or just drive the base directly through the capacitor.  I tried it both ways.  If you need more gain ahead of the circuit, at that frequency you can just wire up a 10dB gain amp with a transistor or FET depending on your junk box.

Wenzel makes some incredible oscillators, etc. and I go there or TAPR for things like this.  Also, you can use a chip like an inverter/buffer with a voltage divider in front for bias but I've found that getting the bias right takes a little messing around and what can be cheaper than a 3-cent pair of transistors?

Jerry
 

Offline Beamin

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Turn a sine wave into a square wave at 275 kHz?
« Reply #29 on: September 13, 2018, 02:22:00 am »
The short answer is "amplify and clip".  A comparitor with a Schmidt triggered input will help to keep the transitions clean.  You can find many examples on the web....


I as thinking that same thing but thought the clipping was more along the lines of overdriving an audio AB amp. Is it the exact same concept?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf