Pages: [1] 2   Go Down

Author Topic: Comparing the relative percentage change of two voltage outputs.  (Read 6567 times)

2E0ILY

  • Member
  • Posts: 237
Comparing the relative percentage change of two voltage outputs.
« on: December 11, 2016, 03:24:12 PM »

I have two separate variable voltage signals, 0 to 12V DC. Signal A and signal B. I want to read  both signals and if A ever rises more than say 10% higher than B an output goes high (or low, it doesn't really matter). I would much prefer this to be all analogue CMOS the stuff running a single 12 v supply. The circuit creating the voltages must not be unduly loaded. What are my options and please consider I am a real novice. It's to measure the outputs of an SWR bridge and at different operating power levels, and hence different voltages from the bridge, still be able to trip a no TX circuit if reflected power gets too high. Thanks. I can post a schematic of the circuit including the bridge if required.
Logged
Best regards, Chris Wilson.

WB6BYU

  • Member
  • Posts: 20896
    • Practical Antennas
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #1 on: December 11, 2016, 05:50:35 PM »

A comparator is designed to do exactly that task:  compare two signals and
set the output high or low depending on which one is higher.  The LM311
is an old standby as way of an example, but there are many others.  It's
basically just a high gain op amp optimized for this purpose, so if you have
a spare op amp section in your circuit you may be able to use it.

The only issue then is how to compare just ratios of signals.  To do that
just stick a voltage divider across one or both signals.  For example, to
compare one voltage to half of the other, use a pair of, say, 47k
resistors across the higher voltage to drive that side of the comparator.
(You might add a 100k load on the other voltage so they see about
the same load impedance.). In most cases the comparators should
present a high enough impedance that you can use large resistors
and not affect the rest of the SWR meter circuit.

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #2 on: December 13, 2016, 11:45:19 AM »

This can be done using an op amp and a comparator. I can post a circuit if I can figure out how to paste a URL or a picture here.
Logged

2E0ILY

  • Member
  • Posts: 237
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #3 on: December 13, 2016, 02:29:33 PM »

Thanks for the replies, I have it working on my breadboard using two dividers set slightly apart, but am failing in getting any hysteresis working for some reason. I would be very interested in seeing your schematic, but if you are having trouble sending a link ( I guess you can just type the URL direct into the message if you are unable to use the globe icon to add the URL), please feel free to send it to me direct I am at chris@chriswilson.tv

Logged
Best regards, Chris Wilson.

W6EM

  • Member
  • Posts: 1944
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #4 on: December 13, 2016, 03:00:49 PM »

This can be done using an op amp and a comparator. I can post a circuit if I can figure out how to paste a URL or a picture here.
  For a hyperlink, just click on the second button from the left of the second row above the window.  To post a picture, go to photobucket.com and create an account.  It will allow you to upload pix, then link to them.  Free of charge.  Just wait for the email spam, though.......
Logged

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #5 on: December 14, 2016, 05:15:00 AM »

Reading your description more closely I see that all that is needed (as WB6BYU says) is a comparator. As you want to sense down to zero volts, and use a single power supply, a comparator with common-mode range to zero volts is needed. The LM311 has a common-mode range down to 2 volts, has relatively high input bias current, and is much faster than is needed for this application. Its high speed invites oscillation. There are many suitable comparators and for this I'll recommend an old standby, the LM339.

From signal A to GND place a voltage divider having a ratio of 2.2:1. For example, a 100k resistor on top and an 82k on the bottom.
Connect the junction of the two resistors to the comparator non-inverting input.

From signal B to GND place a voltage divider having a ratio of 2.0:1. For example, a 100k resistor on top and a 100k on the bottom.
Connect the junction of the two resistors to the comparator inverting input.

From the comparator output connect a resistor to the logic power supply. For CMOS 10k will do. For old TTL 1k will do.

LOGIC: If A > 1.1B comparator output goes HIGH.

Note that there is no hysteresis feedback resistor (from output to the non-inverting input) but I don't see that it is needed. The output will stay HIGH long enough to toggle a logic gate. If you want to avoid possible oscillation as the output is transitioning high some hysteresis can be added. Let's say we want 50 mV of hysteresis at the inputs. 50mV/50k = 1uA. To get 1uA of hysteresis when the output transitions from 0 to 5V a 5M ohm resistor can be added from output to the non-inverting input. Or, the output can be divided 5:1 and a 1M ohm resistor is used.

Error stuff:
The max input offset current spec is 100nA. The Thevenin input source resistances are 45k and 50k. To simplify the math let's call them both 47.5k. The input offset voltage caused by the offset current is 100nA X 47.5k = 5mV.

The max input offset voltage spec is 4mV.

The effective input offset voltage at A or B is 2 x (5mV + 4mV)  = 18 mV.

The specified response time is 1.3us for a 5mV overdrive. There is additional delay due to the input capacitance (about 5pF for an input + wiring) and the 50k divider output resistance.

« Last Edit: December 14, 2016, 05:37:25 AM by WX7G »
Logged

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #6 on: December 14, 2016, 07:23:58 AM »

Also note that the hysteresis resistor is in parallel with the bottom resistor on divider A and raises the divider ratio. Adjust the divider A resistor for this if desired.
Logged

WB6BYU

  • Member
  • Posts: 20896
    • Practical Antennas
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #7 on: December 14, 2016, 07:32:37 AM »

While the hysteresis resistor will work, it may be more convenient to add hysteresis to the CMOS
circuitry rather than to the comparator.

2E0ILY

  • Member
  • Posts: 237
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #8 on: December 14, 2016, 09:31:22 AM »

Wow, great info everyone, sincere thanks for your trouble. I will breadboard this and let you know how I get on. I am now wondering if I have my head around this correctly though, and whether reflected power (volts from the bridge) really does rise linearly with forward power....Or should I just make the comparator at a certain level of reflected voltage and ignore the forward voltage? My desire was to have the thing trip iff running QRP levels of volts to the PA with a mismatch as well as tripping with full power into a mismatch. Obviously full power into a bad match is potentially more dangerous to the output FET's.  Am I being too clever (stupid) for my own good....? Whatever, this thread has taught me a lot and experimentation is always worthwhile at my stage of limited knowledge. Thanks again.

Logged
Best regards, Chris Wilson.

WB6BYU

  • Member
  • Posts: 20896
    • Practical Antennas
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #9 on: December 14, 2016, 10:06:12 AM »

Quote from: 2E0ILY

...I am now wondering if I have my head around this correctly though, and whether reflected power (volts from the bridge) really does rise linearly with forward power...


Of course it is not linear.  Voltage rises with the square root of power.  But the voltage ratio still
correlates to SWR, so you can use the comparator to trigger when the SWR exceeds a specific value.
You can also use a second comparator to trip on an absolute number of reflected watts regardless of
forward power, which may be more useful for protecting the output devices.

Comparators are cheap, and the LM339 is a quad comparator with 4 in a package, so you have lots
of them to play with.   You can wire up all 4 comparators with different inputs and pots to adjust
the ratios and see what works best for you.

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #10 on: December 14, 2016, 12:12:04 PM »

For a given VSWR the reflection coefficient will be the same regardless of the power level. For example, for a 1.5:1 VSWR The reflection coefficient is 0.2. To trip at that VSWR the circuit is set to trip when B = A/5. for a 2:1 VSWR the coefficient is 0.333. To trip at that VSWR the circuit is set to trip when B = A/3.

Logged

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #11 on: December 14, 2016, 01:48:35 PM »

But there's more. For the reflection coefficient in the previous post we need to know the incident signal. If I'm not mistaken, what we measure in the directional coupler out of port A is incident + reflected and from port B is reflected. So, to trip at a particular reflection coefficient we need to do A-B and ratio result that against B. The ratio is 1 divided by the reflection coefficient.

Another way to get the same trip point is to divide A by the sum of 1 + (1 divided by the reflection coefficient).

So, for a 2:1 VSWR set the divider ratio to 4:1. For a 1.5:1 VSWR set the divider ratio to 3:1.
Logged

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #12 on: December 14, 2016, 02:13:31 PM »

I checked and a directional coupler outputs the incident and reflected voltages. So, the 1+ is not needed. A divider ratio equal to the reciprocal of the magnitude of the reflection coefficient works.
Logged

KH6AQ

  • Member
  • Posts: 9292
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #13 on: December 14, 2016, 07:20:18 PM »

Two things need correcting. The first is that for an excessive signal on B (reflected power) to cause the comparator output to go positive, it should be connected to the non-inverting input.

The second thing is what happens when there is no RF and A and B are zero volts. The comparator input offset voltages will cause the output to go LOW or HIGH, depending on which input has more voltage offset. We need a way to make the output go LOW in the absence of signals. To do this we can introduce some positive offset voltage at the inverting input.

The link below shows the schematic. It is set up to trip if the VSWR exceeds 2:1. The reflection coefficient is 0.33 and the B signal will be 1/3 of the A signal.

The B signal is divided by 2 while the A signal is divided by 6. R5 and R4 introduce 18mV of offset to the inverting input to ensure that with no signals the comparator output goes LOW.

http://s942.photobucket.com/user/telegrapher9/media/VSWR_1A_zpshpy1nfj9.jpg.html?sort=3&o=0
« Last Edit: December 14, 2016, 07:26:19 PM by WX7G »
Logged

2E0ILY

  • Member
  • Posts: 237
RE: Comparing the relative percentage change of two voltage outputs.
« Reply #14 on: December 15, 2016, 11:43:23 AM »

I am indebted to you for taking such time and trouble, not only to explain how to create this circuit, but to also to explain how it works and foresee issues I hadn't even considered, and even create a schematic! My thanks too go to WB6BYU. I don't have that particular comparator, but have ordered 4 and hopefully they will arrive tomorrow. I only have LM339's here. I am not savvy enough to know if they are suitable.

I took the liberty to Google your call sign and I am flattered and honored that a gentleman with such a CV is willing to share freely such hard won and valuable knowledge with the ham community, it's much appreciated. I attach a link to the schematic for this LF amp, in case it's of interest to people as to what I am up to and why. Whilst 90% reliable, when it has "done something funny" the single trip LED left me guessing as to which of the 3 protection circuits had caused the trip. No drive signal, over current to the PA FET's, or high SWR, so I am rebuilding it with a separate LED fed via a set / reset flip flop, and where needed, an inverter, for each fail scenario. Then I will hopefully have an LED stay on showing WHAT tripped. I changed from a Hall effect device looking at the end of the choke ferrite to one of the current sensing modules now commonplace, and a comparator to allow accurate setting of the trip voltage from the sensing module, and I have the no signal scenario linked to a flip flop and separate LED. In fact from the original circuit I have fiddled about and deleted unneeded stuff like the keyer circuitry.

Before embarking on improving the high reflected power trip I had to feed the flip flop from the bridge side of the 47k resistor, just before the voltage limiting diode D3. I am unsure just what the 47k resistor does, is it current limiting?


Again, thank you most sincerely for all your help!

Original build document and schematic here: http://www.chriswilson.tv/bigtxv2.doc

http://www.chriswilson.tv/136bigv2mods-6.jpg shows a few deletions and where I have tapped for individual fault cause LED's
« Last Edit: December 15, 2016, 11:45:26 AM by 2E0ILY »
Logged
Best regards, Chris Wilson.
Pages: [1] 2   Go Up