How to get squarer square waves? - Page 1
Forum section: electronics / beginners

author: Electro Fan
author_rank: Super Contributor
timestamp: December 14, 2013, 03:46:34 am
content: Just checking to see what are some of the common or likely causes of square waves not being nicely square?Below are a couple images from probing the TX and GND pins on a RS232 port. The signal is not very high speed (only 2400 bps); seems like it should be possible to get squarer square waves.I'm confident it's not the scope - must be either the signal generated by the computer, or more likely the way in which I used the probe ground clip to attach to the GND pin and an alligator cable to connect the probe to the TX pin? Maybe just need better connections to the RS232 pins?Thanks

author: marshallh
author_rank: Unknown
timestamp: December 14, 2013, 03:48:18 am
content: probably artifacts from the boost converter in the level converter. (max232 etc)

author: Electro Fan
author_rank: Super Contributor
timestamp: December 14, 2013, 05:13:34 am
content: I watched one of w2aew's (Alan's) videos showing the effect of shorter/better connections and this clearly cleaned up the square waves.Below are 4 images using better connections and 4 images with not so good connections.I had been using a combination of breadboard wires and alligator clip wires to connect the probe and the probe ground to the R232 pins - you can see the results in images 19-22. Eliminating the additional wires and clips (which ranged from about 10-60cm) and using just the probe ground clip attached directly onto the RS232 GND pin and using a special 17cm probe adapter wire (that fits snug over the probe and has a very good female connection on the other end for attaching to the RS232 TX pin) created very square square waves as shown in images 15-19.As or more intesting than the better shaped square waves was the voltage reading. With the not so square square waves I had a voltage reading of about 13.6-13.8 Volts; with the good connections creating the uniform square waves the voltage dropped to about 9.55-9.56 Volts.Every day is an adventure in learning land. EF- at the bottom is an image of the probe to pin adapter; might have to find some more of these; after you see really nice square waves it's harder to get excited about less square waves

author: codeboy2k
author_rank: Super Contributor
timestamp: December 14, 2013, 06:23:01 am
content: Good for you to learn first hand that the connection to the scope (via the probe) is very important..Yes, Alan's videos (w2aew) are very instructive and informative. I watch them all.Your experimental results shows another gotcha for anyone just learning... it's not the speed of the signal that matters...it's the speed of the edges.In order to get edge rise times from -4.77 to +4.77 (or p-p 9.55V as shown on your scope trace), the edges must travel at 955V/us , assuming a 10ns rise time, (and they might be faster than that). So, even though your circuit is not high-speed and you might think you don't need to worry about a good scope connection, you have learned that your edges are very high-speed and are traveling in the vicinity of 955V/us or, depending on actual rise times, somewhere above 30-50Mhz. So you really do need a good scope connection. This is also why even a slow circuit can fail EMI testing (and the answer is often to add some capacitance to slow down the fast edges, or specifically pick slower drivers/buffers in the design)

author: AndyC_772
author_rank: Super Contributor
timestamp: December 14, 2013, 07:21:12 am
content: There must be more to what you've changed than just some shorter wires. Wires alone won't make the difference between a signal that's 13.6Vpp and one which is 9.5Vpp.RS232 has slow edges, and I wouldn't normally expect to see much in the way of 'high speed' effects on an RS232 signal. The change in signal amplitude you've seen can only really be explained by a difference in the loading on the signal.What I think is happening is:- in the original case, there's little or no load on the signal. The charge pump in the line driver is in a pulse-skipping mode, charging up to +/- 7V or so and then allowing the voltage to decay a little before starting up again to keep its caps charged. This is a fairly common power saving technique.- in the 'fixed' case, there's more load on the signal (is it plugged into a PC?). This draws current from the driver, and the charge pump has to run continuously to provide it. The voltage coming from the charge pump remains constant, and so do the logic levels. This is why the pulses are now square.

author: Electro Fan
author_rank: Super Contributor
timestamp: December 14, 2013, 06:01:48 pm
content: Both sets of images above were made with the same PC and the same test file and the same probe. Only differences were in how the probe tip and the probe ground were attached to the PC's RS32 TX and GND pins.I went back and re-did the test - results are shown below.In #24 i used the two breadboard m/f wires (about 11cm long each) to attach to the pins on the port; the probe GND clip was attached to the breadboard wire that was attached to the GND pin. The probe tip was connected to the other breadboard wire (which was attached to the TX pin) via an extension alligator clip wire (~58cm). All this was the same as in the initial test above - and not surprising it got pretty much the same results (a clean square wave, with an amplitude of 9.7V (with a peak to peak of 10.4V).In #25 I removed the breadboard wires and the extension alligator clip wire and attached the probe GND clip directly to the GND pin. I used the special probe tip connector wire with a secure female connector to attach to the TX pin. Not surprisingly this produced pretty much the same results as in the original test. (The amplitude was 14.0V and the peak to peak was 15.4V).In #26 I put the breadboard wire and the extension alligator clip wire back in place to attach the probe tip to the TX pin but I attached the probe GND clip directly to the GND pin (without the breadboard wire). This clearned up the square wave (very similar to #24); the amplitude was nearly the same at 9.68V; the 10.6V peak to peak was slightly higher than in #24.So, while the additional length of wire from the probe tip might imact the signal somewhat it appears (at least in this test) that the quality of the GND connection has an even greater impact on both the integrity of the waveform (in terms of "squareness") and the amplitude.Seems like the moral of the story is "make a firm GND connection", but maybe there's more to it? Kind of hard to imagine that improving the GND connection could reduce the amplitude from 14.0V to 9.7V but it appears to be the case.

author: codeboy2k
author_rank: Super Contributor
timestamp: December 14, 2013, 09:26:23 pm
content: Its the added inductance and capacitance of the longer lead lengths that are charging and discharging during the pulses of the serial bit stream. This is acting like a boost converter (not exactly, but similar principle, where the inductance can store energy). This causes higher voltages on the wires.More inductance then capacitance, actually, since I presume the wires are separated by large air gaps, so the capacitance is minimized. But even the breadboard adds lots of extra capacitance, so getting the probe wires out of the breadboard helps too.

author: w2aew
author_rank: Super Contributor
timestamp: December 15, 2013, 12:37:38 am
content: Yay! I'm am always so happy to hear when my videos help someone!

author: AndyC_772
author_rank: Super Contributor
timestamp: December 15, 2013, 07:33:18 am
content: If it were anything to do with inductance or capacitance, you'd be seeing ringing on the edges.You're not - but what you are seeing is small steps appearing in the wave at times which are unrelated to the bit transitions in the signal. There is no way this can be anything to do with your wiring.RS232 just isn't fast enough for these 'high speed' effects to be significant. At 2400 bps, with correspondingly slow slew rates, I doubt they'd be even visible. You're at least three orders of magnitude too slow to be seeing such large differences in signal height as a result of a few bits of wire.This is about DC loading, pure and simple. Something you think is grounded isn't, or vice versa.Go back to a setup where you see the larger signal with steps in it, and then connect a 1k resistor between the signal and ground. See the difference.

author: Electro Fan
author_rank: Super Contributor
timestamp: December 15, 2013, 04:20:51 pm
content: Quote from: AndyC_772 on December 15, 2013, 07:33:18 amJust to clarify: you are suggesting to 1) insert a 1k resistor between the GND probe clip and the GND pin on the RS232 port, or 2) put a 1k resistor from the GND pin on RS232 port to the TX pin on the RS232 port, or 3) something else? Thanks

author: AndyC_772
author_rank: Super Contributor
timestamp: December 15, 2013, 05:08:47 pm
content: Option (2). The idea is to draw some current from the device that's generating the TX data signal.If you're using a 9 way D-type connector for the serial port, it'll go between pin 2 and pin 5, or between pin 3 and pin 5, depending on which data direction you're looking at.

author: Electro Fan
author_rank: Super Contributor
timestamp: December 16, 2013, 02:06:31 am
content: Ok, reporting back. I inserted a 1k resistor as suggested and tested both the original connection (using the breadboard wiring) and the second connection (using the more secure connection).The results are posted below.My tentative conclusion so far (at least at these relatively low speeds) is that a modest increase in wire length does not have as much impact on signal quality as the difference between a secure/firm connection and a not so secure/firm connection. A more secure/firm connection seems to drop the voltage reading by a notable amount. This seems to make sense assuming that a more secure/firm connection lowers the resistance which would lower the voltage (assuming a constant current).Further, at these relatively low speeds the square wave can be seen degrading with the less secure/firm connection so it is believeable that the rise and fall times are likely to become much more noticeable and impactful at faster speeds.So, the practical take-away I have so far is that if I plug something together and I get poor square waves it's worth checking to see if I can make better connections.Thoughts/Comments?Thanks