Turn a sine wave into a square wave at 275 kHz? - Page 1
Forum section: electronics / rf-microwave

author: Chris Wilson
author_rank: Super Contributor
timestamp: September 04, 2018, 11:31:55 am
content: I want to turn its sub 1mW sine wave output from the Drive socket ofmy TS-590S from a sine wave to a square wave of similar amplitude tothat from the CLK0 pin of the U3S Si5351A synthesizer chip. Anyone anyideas for a simple way to do this then I can also use the 590 as a driverfor 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 abit 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 fromit's "Drive" socket and turn the sine wave to a similar frequencysquare wave of similar amplitude to that from the U3S (a small commercially made TX exciter from QRP Labs) Si chip CLK0pin. 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.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: September 04, 2018, 11:42:53 am
content: 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

author: bd139
author_rank: Super Contributor
timestamp: September 04, 2018, 11:47:51 am
content: You can get a reasonably square output at 275KHz with a 2n3904 switch. Probably can be improved easily. Quick simulationIf 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 ICEdit 2: just seen your similar post on the QRP labs list

author: Chris Wilson
author_rank: Super Contributor
timestamp: September 04, 2018, 11:54:46 am
content: 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.

author: David Hess
author_rank: Super Contributor
timestamp: September 04, 2018, 03:45:07 pm
content: 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.

author: Chris Wilson
author_rank: Super Contributor
timestamp: September 04, 2018, 03:52:53 pm
content: Quote from: David Hess on September 04, 2018, 03:45:07 pmWhere 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 areApologies if that is not the case.

author: David Hess
author_rank: Super Contributor
timestamp: September 04, 2018, 05:29:36 pm
content: Quote from: Chris Wilson on September 04, 2018, 03:52:53 pmYea, 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 examplehere. 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.

author: radioactive
author_rank: Regular Contributor
timestamp: September 04, 2018, 05:33:07 pm
content: 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.

author: iMo
author_rank: Super Contributor
timestamp: September 04, 2018, 05:39:21 pm
content: 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.

author: cncjerry
author_rank: Unknown
timestamp: September 05, 2018, 03:58:00 am
content: 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.

author: Beamin
author_rank: Super Contributor
timestamp: September 05, 2018, 10:39:38 am
content: 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?

author: donmr
author_rank: Regular Contributor
timestamp: September 05, 2018, 04:35:25 pm
content: 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....

author: bson
author_rank: Unknown
timestamp: September 06, 2018, 06:19:49 am
content: 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.

author: ogden
author_rank: Super Contributor
timestamp: September 06, 2018, 06:44:52 am
content: Quote from: bson on September 06, 2018, 06:19:49 am645 mVpp. There's waveform in first postQuoteMaybe, 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.

author: rs20
author_rank: Super Contributor
timestamp: September 06, 2018, 06:51:48 am
content: Quote from: ogden on September 06, 2018, 06:44:52 amSeems 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.

author: iMo
author_rank: Super Contributor
timestamp: September 06, 2018, 10:16:53 am
content: Quote from: bson on September 06, 2018, 06:19:49 amAfaik 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"..

author: bloguetronica
author_rank: Frequent Contributor
timestamp: September 06, 2018, 11:08:58 am
content: 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 testingin situ.Kind regards, Samuel Lourenço

author: coppercone2
author_rank: Super Contributor
timestamp: September 06, 2018, 06:52:09 pm
content: 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.phpYou 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 600mV0.2/600 = 0.03% error25/600= 4.1 % errorYou can trim it, but you still have thermal drift.This part should be nice:http://www.aldinc.com/pdf/ALD2321.pdf300ns rise timeIf 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.

author: radioactive
author_rank: Regular Contributor
timestamp: September 06, 2018, 07:20:14 pm
content: According to some, you can get 74xx inverters to "square up" by putting several gates in parallel for a clocking application.

author: bson
author_rank: Unknown
timestamp: September 07, 2018, 03:47:25 am
content: Quote from: imo on September 06, 2018, 10:16:53 amI 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.

author: bloguetronica
author_rank: Frequent Contributor
timestamp: September 07, 2018, 09:28:57 am
content: Quote from: bson on September 07, 2018, 03:47:25 amAdmitting 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

author: David Hess
author_rank: Super Contributor
timestamp: September 07, 2018, 06:58:26 pm
content: Quote from: radioactive on September 06, 2018, 07:20:14 pmThis 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.

author: coppercone2
author_rank: Super Contributor
timestamp: September 07, 2018, 08:04:47 pm
content: what is the offset voltage on one of those logic gates, where do you go from the ideal 50%?

author: cncjerry
author_rank: Unknown
timestamp: September 07, 2018, 09:22:23 pm
content: Go here and look at the two-transistor generator about half way down:http://www.wenzel.com/documents/waveform.html

author: Chris Wilson
author_rank: Super Contributor
timestamp: September 08, 2018, 12:37:53 pm
content: Quote from: cncjerry on September 07, 2018, 09:22:23 pmWow, 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.

author: bloguetronica
author_rank: Frequent Contributor
timestamp: September 08, 2018, 03:40:48 pm
content: 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

author: Chris Wilson
author_rank: Super Contributor
timestamp: September 08, 2018, 04:09:20 pm
content: Quote from: bloguetronica on September 08, 2018, 03:40:48 pmJust 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

author: cncjerry
author_rank: Unknown
timestamp: September 08, 2018, 09:05:27 pm
content: 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

author: cncjerry
author_rank: Unknown
timestamp: September 08, 2018, 09:36:55 pm
content: 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.pdfOtherwise 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

author: Beamin
author_rank: Super Contributor
timestamp: September 13, 2018, 02:22:00 am
content: Quote from: donmr on September 05, 2018, 04:35:25 pmI 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?