Tuesday, September 27, 2022

Using an ATX computer power supply to run KiwiSDRs - and as a general purpose 5 and 12 volt supply

At the Northern Utah WebSDR (link) we run a number of KiwiSDR receivers.  These receivers, which are inherently broadband (10 kHz to 30 MHz) allow a limited number of users to tune across the bands, allowing reception on frequencies that are not covered by the WebSDR servers.

At present there are six of these receivers on site:  Three are connected to the TCI-530 Omnidirectional antenna (covering 630-10 meters - 2200 meters is included via a separate E-field whip), two are on the east-pointing log-periodic beam antenna (which overs 40-10 meters) and the newest is connected to the northwest-pointing log-periodic beam antenna (which covers 30-10 meters).

Figure 1:
Power supply in a PC case!
The PC case housing the power supply was repurposed -
because, why not?
Click for larger version
The power requirements of a KiwiSDR are modest, being on the order of 600-800 mA, but the start-up current can briefly exceed 1.25 amps.  Additionally, they do not start up reliably if the voltage "ramps up" rather slowly - a problem often exacerbated by the fact that the extra current that they draw upon power-up can cause a power supply to "brown out".

Up to this point we had been running 5 KiwiSDRs:  Three of them were powered by a pair of 5 volt, 3 amp linear power supplies that are "dioded-ANDed" together to form a 6 amp power supply and the other two KiwiSDRs were powered from a heavily-filtered 5-volt, 3 amp switching power supply.

In recent months, the dual 3 amp linear supply had become problematic, not being able to handle the load of the three KiwiSDRs, so we had to power down KiwiSDR #3.  With the recent installation of the northwest-pointing log periodic antenna, we were also looking toward installing another KiwiSDR for that antenna and we were clearly out of power supply capacity.

Using an ATX supply as a general-purpose power supply - it's not just the green wire!

If you look around on the Web, you'll see suggestions that you just "ground the green wire" to turn on an ATX supply, at which point you may use it as a general-purpose supply.  While grounding the green wire does turn it on, it's not as simple as that - particularly if you leave the power supply unattended.

For example, what is there is a brief short on the output while you are connecting things, or what if the power browns out (or turns off) for just the "wrong" amount of time.  These sorts of things do happen, and can "trip out" the power supply and it may never restart on its own.

We couldn't afford for this to happen - so you'll see, below, how we remedied this.

Putting together another power supply:

With six KiwiSDRs, the power supply requirements were thus:

  • 5 amps continuous, making the assumption that a KiwiSDR's average current consumption would be about 830 mA - a number with generous overhead.
  • 9 amps on start-up, presuming that each KiwiSDR would briefly consume 1.5 amps upon power-up, again a value with a bit of overhead.
  • The power supply must not exhibit a "slow" ramp-up voltage as the KiwiSDRs did not "like" that.

In looking around for a power supply on which to base the design, the obvious choice was an computer-type ATX power supply.  Fortunately, I have on-hand a large number of 240 watt ATX supplies with active power factor correction which are more than capable of supplying the current demands, being rated for up to 22 amps load on the 5 volt supply - more than enough headroom as I would be using less than half of that, at least with the currently-planned usage.

Circuit description:

Refer to the schematic in Figure 2 for components in the description.

Added filtering:

While these power supplies were already known to be adequately RF-clean from their wide use for the WebSDR servers (important for a receive site!) because we would be conducting the DC outputs outside the box - and to receivers - I felt it important that additional filtering be added.  Having scrapped a number of PC power supplies in the past, I rummaged around in my box of random toroids and found two that had probably come from old PC power supplies, wound with heavy wire consisting of 4 or 5 strands in parallel.  These inductors measured in the 10s of microHenries, enough for HF filtering when used with additional outboard capacitance.

These filter networks were constructed using old-fashioned phenolic terminal lug strips.  These consist of a row of lugs to which components are soldered - typically with one or two of the lugs used for mounting, and also "grounding".  Rather than mount these lugs using a drill and screw, they were soldered to the steel case itself - something easily done by first sanding a "bare" spot on the case to remove any paint or oxide and then using an acid-core flux - cleaning it up afterwards, of course!

The heavier components (inductors, capacitors) were mechanically secured using RTV (silicone) adhesive to keep them from moving around - and to prevent the possibility of the inductor's wire from touching the case.

Looking at the schematic you may note that  C202, C302, C501, C502 and C503 are connected to a "different" ground than everything else.  While - at least for this power supply - the "Common" (black) wire is internally connected to the case, it's initially assumed that this lead - which comes from the power supply - may be a bit "noisy" in terms of RF energy, so they are RF bypassed to the case of the power supply.  This may have been an unneeded precaution, but it was done nonetheless.

Connectorizing and wiring the power supply:

The ATX power connector was extracted from a defunct PC motherboard to allow the power supply itself to be replaced in the future if needed.  On this connector, all of the pins corresponding with the 5 volt (red wires), 12 volt (yellow wires) and ground (black wires) were bonded together to form three individual busses and heavy (12 AWG) wires were attached to each:  This was done to put as many of the wires emerging from the power supply in parallel with each other to minimized resistive losses. 

The green wire (the "power" switch) and purple wire (the 5 volt "standby") were brought out separately as they would be used as well - and the remainder of the pins (3.3 volt, -12 volt, -5 volt, "power good", etc.) were flooded with "hot melt" glue to prevent anything from touching anything else that it shouldn't.

The 5 volt supply was split two ways - each going to its own L/C filter network (L501, L502, C502, C503, C504, C505) as shown in the schematic, this being done to reduce the total current through the inductor - both to minimize resistive losses, but also to reduce the magnetic flux in each inductor, something that could reduce its effective inductance.

Although I don't have immediate plans to use the 12 volt supply, a similar filter (L503, C506, C507) was constructed for the 12 volt supply lead.  On the output side of the 12 volt filter, a 3 amp self-resetting thermal fuse (F501) was installed to help limit the current should a fault occur. 

About the self-resetting fuses:

 These fuses - which look like capacitors - operate by having a very low resistance when "cold".  When excess current flows, they start to get warm - and if too much current flows, they get quite hot (somewhere around 200F, 100C) and their internal resistance skyrockets, dropping the current to a fraction of its original value:  It's this current flow and their heat that keeps the resistance high.

It's worth noting that these fuses don't "disconnect" the load - they just reduce the current considerably to protect whatever it is connected to it.  Since, when "blown", they are hot, they must be mounted "in the clear" away from nearby objects that could be damaged by the heat - and also to prevent lowering of their trip current by trapping heat or being warmed by another component - such as another such fuse.  

It should be noted that if the outputs - either 5 or 12 volts - are "hard shorted", the thermal fuse may not react quickly enough prevent the power supply from detecting an overcurrent condition and shutting down.  As an output short is not expected to be a "normal" occurrence, this behavior is acceptable - but it will require that the power supply be restarted to recover from shutdown, as described below.

In the case of the KiwiSDRs, they are connected with fairly long leads (about 6 feet, 2 meters) and often have enough internal resistance to reduce the current below the power supply's overcurrent limit and rather than allowing the full current of the power supply (which could be more than 20 amps) to flow through and burn up this cable, the fuse will trip as it should, protecting the circuit.  To "reset" the fuse, the current must be removed completely for long enough for the device to cool - something that is done with the 5 volt supplies as we'll see, below.

The controller:

As mentioned earlier, if you look on the web, you'll see other power supply projects that use an ATX power supply as a benchtop power source and most of those suggest that one simply connect the green (power on) wire to ground to turn it on - but this isn't the whole story.  In testing the power supply, I noticed two conditions in which doing this wouldn't be enough:

  • Shorting a power supply output.  If the output of a good-quality ATX power supply is shorted, it will immediately shut down - and stay that way until the mains power is removed (for a minute or so) or the power supply is "shut off" by un-grounding the green wire for a few seconds before reconnecting to "restart" the power supply.
  • Erratic mains power interruption.  It was also observed that if the mains power was removed for just the right amount of time, the power supply would also shut down and would not restart on its own.  It took the same efforts as recovering from an output short to restart the power supply.

Since this power supply would be at the WebSDR site - an unmanned location in rural, northern Utah - it would require additional circuitry to make this power supply usable.

Fortunately, an ATX power supply has a second built-in power supply that is independent of the main one - the "standby" power supply.  This is a low-power 5 volt supply that is unaffected by what happens to the main supply (e.g. not controlled by the power switch and not affected if it "trips off") and can be used to power a simple microcontroller-based board that can monitor and sequence the start-up of the main power supply.  For this task I chose the PIC16F688, a 14 pin microcontroller with A/D conversion capability and a built-in clock oscillator.

As seen in the schematic, the "5 volt standby" is dioded-ORed (D601, D602) with the main power supply (12 volts) so that it always gets power - from either the 5 volt standby, or from the 12 volt output - when mains is applied.  R603 and capacitor C602 provide a degree of protection to the voltage regulator should some sort of "glitch" appear on the 12 volt supply - possibly due to the 5 volt load being abruptly disconnected (or connected) as the 5 and 12 volt supplies are "co-regulated" in the sense that it's really only the 5 volt output that is being regulated well - the 12 volt power supply's output is pretty much a fixed ratio to the 5 volt and doesn't really have much in terms of separate regulation.

It should be noted that when operating from the standby +5 volt power source, the voltage from U2 (the 5 volt regulator) is on the order of 3 volts or so (drop through D602 and U2) but this is comfortably above the "brownout" threshold of the PIC, which is around 2.5 volts, so there isn't really a worry that the low-voltage brownout detector will trigger erroneously and prevent start-up.  If it had, I would have simply moved the cathode side of D602 to the +5V side of U2.

Figure 3: 
Inside the case!
Top right:  12 volt supply filtering and thermal fuse
Upper-middle:  Dual 5 volt filtering
Lower middle:  Controller board with FET switches
and thermal fusing.
The ATX power supply is in the lower-left corner.
Click on the image for a larger version.
Because the PIC microcontroller can monitor the 12 volt supply (via R601/R602) it "knows" when the main ATX supply is turned off.  Through the use of an NPN transistor (Q401) - the collector of which can be used to "ground" the green "power on" line, the controller can turn the main power supply on and off as follows:
  • When the microcontroller starts up, it makes sure that the ATX "power on" wire is turned off (e.g. un-grounded).  This is done by the microcontroller turning off Q401.
  • After a 10 second delay, it turns on the power supply by turning on Q401.

It also monitors the power supply to look for a fault.  If either the 5 or 12 volt output is shorted or faults out, both power supply outputs (but not the 5 volt "standby" output) disappear.

  • If, while running, the monitored 12 volt supply (via R601/R602 and "12V V_MON") drops below about half the voltage (e.g. trips out) the "power on" wire is turned off using Q401, disabling the ATX power supply.
  • A 10 second delay is imposed before attempting to turn the power supply back on.
  • Once the power supply is turned back on, monitoring of the voltage resumes.

In practice, if there is a "hard" short on the output, the power supply will attempt to restart every 10 seconds or so, but remember that a short on an output could occur with ANY sort of power supply, so this isn't a unique condition.

5 volt output sequencing and monitoring:

The other function of the controller is to sequence and monitor the 5 volt outputs.  As mentioned earlier, it was noted that the KiwiSDRs do not "like" a slow voltage ramp-up so a FET switch is employed to effect a rapid turn-on - and since there are two separately-filtered 5 volt busses, there are two such switches.  In order to reduce the peak current caused when the load is suddenly connected, each of these busses is turned on separately, a 10 second delay between the two of them.

The N-channel FET switches (Q203, Q303) are controlled by an NPN (Q201, Q301) transistor being turned on by the microcontroller which, in turns, "pulls" the base of a PNP transistor (Q202, Q302) low via a base resistor (R202/R302), turning it on - and other resistors (R203, R303) assure that these transistors are turned off as needed.

With the emitter of the PNP connected to the 12 volt supply, the gate voltage of the FET is approximately 7 volts higher than the drain voltage, assuring that it is turned on with adequately low resistance.  Capacitors (C201, C301) are connected between the FET's gates and sources to suppress any ringing that might occur when the power is turned on/off and as a degree of protection against source-gate voltage spikes while the 47k resistor (R207/R307) assure that the FET gets turned off.

The use of P-channel FETs was considered, but unless special "logic level" threshold devices were used, having only 5 volts between the gate and drain wouldn't have turned them fully "on" unless the -5 or -12 volt supply from the power supply was also used.  While this would certainly have been practical, N-channel FETs are more commonly available.

Figure 2: 
Schematic of the ATX controller with power supply filtering, voltage monitoring, and control.
See the text for a description.
Click on the image for a larger version.

In series with the 5 volt supply and the FET's source is a 5 amp self-resetting thermal fuse to limit current.  Should an overload (more than 5-ish amps) occur on the output bus, this fuse will heat up and go to high resistance, causing the output voltage to drop.  If this occurs, the microcontroller, which is using its A/D converter to look at the voltage divider on the outputs (R205/R206 for the "A" channel, R305/R306 for the "B" channel) will detect this dip in voltage and immediately turn off the associated FET.  After a wait of at least 10 seconds - for the fault to be cleared (in the event that it is momentary) and to allow the thermal fuse to cool off and reset - the power will be reconnected.  If there continues to be a fault, the reset time is lengthened (up to about 100 seconds) between restart attempts.

Finally, the status of the power supply is indicated by a 2-lead dual-color (red/green) LED (LED701) mounted to be visible from the front panel.  During power supply start-up, it flashes red, during the time delay to turn on the power supplies it is yellow, when operation is normal it is green - and if there is a fault, it is red.  Optionally, another LED (LED702) can be mounted to be visible:  This LED is driven with the algorithm that causes it to "breath" (fade on and off - and on, and off...) to indicate that "something" was working.  I simply ran out of time, so I didn't install it.

* * *

This power supply was put together fairly quickly, so I didn't take as many pictures as I usually would - and I omitted taking pictures of the back panel where the power supply connections are made.  Perhaps it's just as well as while I used a good-quality screw-type barrier strip, it was mounted to a small piece of 1/4" (6mm) thick plywood that was epoxied into the rectangular hole where one would connect peripherals to the motherboard.

As you would expect, the terminals are color-coded (using "Sharpies" on the wood!) and appropriately labeled.  While not pretty, it's functional!

(Comment:  The photo in Figure 3 was taken before I added the circuit to control the "Power On" wire (e.g. Q401) and the diode-OR power (D601, D602) - and it shows the dual-color LED on the board during testing.)

If you are interested in the PIC's code, drop me a note.

This page stolen from ka7oei.blogspot.com


Tuesday, August 30, 2022

Making a "Word Metronome" for pacing of speech

Figure 1:
The completed "Word Metronome".  There are two recessed
buttons on the front and the lights on on the left side.
Click on the image for a larger version.
One of the things that my younger brother's job entails is to provide teaching materials - and this often includes some narration.  To assure consistency - and to fall within the required timeline - such presentations must be carefully designed in terms of timing to assure that everything is said that should be said within the window of the presentation itself.

Thus, he asked me to make a "word metronome" - a stand-alone device that would provide a visual cue for speaking cadence.  The idea wasn't to make the speech robotic and staccato in its nature, but rather providing a mental cue to provide pacing - something that is always a concern when trying to make a given amount of material fit in a specific time window:  You don't want to go too fast - and you certainly don't want to be too slow and run over the desired time and, of course, you don't want to randomly change your rate of speech over time - unless there's a dramatic or context-sensitive reason to do so.

To be sure, there are likely phone apps to do this, but I tend to think of a phone as a general-purpose device, not super-well suited for most of the things done with it, so a purpose-built, simple-to-operate device with visual indicators on its side that could just sit on a shelf or desk (rather than a phone, which would have to be propped up) couldn't be beat in terms of ease-of-use.


The schematic of the Word Metronome is depicted in Figure 2, below:

Figure 2:
Schematic of the "Word Metronome"
(As noted in the text, the LiIon "cell protection" board is not included in the drawing).
Click on the image for a larger version.

This device was built around the PIC16F688, a 14 pin device with a built-in oscillator.  This oscillator isn't super-accurate - probably within +/-3% or so - but it's plenty good for this application.

One of the complications of this circuit is that of the LEDs:  Of the five LEDs, three of them are of the silicon nitride "blue-green" type (which includes "white" LEDs) and the other two are high-brightness red and yellow - and this mix of LED types poses a problem:  How does one maintain consistent brightness over varying voltage.

As seen in Figure 3, below, this unit is powered by a single lithium-ion cell, which can have a voltage ranging from 4.2 volts while on the charger to less than 3 volts when it is (mostly) discharged.  What this means is that the range of voltage - at least for the silicon nitride types of LEDs, can range from "more than enough to light it" to "being so dim that you may need to strike a match to see if it's lighting up".  For the red and yellow LEDs, which need only a bit above two volts, this isn't quite the issue, but if one used a simple dropping resistor, the LED brightness would change dramatically over the range of voltages available from the battery during its discharge curve.

As one of the goals of this device was to have the LEDs be both of consistent brightness - and to be dimmable -  a different approach was required - and this required several bits of circuity and a bit of attention to detail in the programming.

The Charge Pump:

Perhaps the most obvious feature of this circuit is the "Charge Pump".  Popularized by the well-known ICL7660 and its many (many!) clones, this circuit uses a "flying capacitor" to step up the voltage - specifically, that surrounding Q1 and Q2.  In software - at a rate of several kHz - a pulse train is created, and its operation is thus:

  • Let is start by assuming that pin RC4 is set high (which turns off Q1) and pin RA4 is set low (which turns off Q2.)
  • Pin RA4 is set high, turning on Q2, which drags the negative side of capacitor C2 to ground.  This capacitor is charged to nearly the power supply voltage (minus the "diode drop") via D1 when this happens.
  • Pin RA4 is then set low, and Q2 is turned off.
  • At this point nothing else is done for a brief moment, allowing both transistors to turn themselves off.  This very brief pause is necessary as pulling RC4 low the instant RA4 is set low would result in both Q1 and Q2 being on for an instant, causing "shoot through" - a condition where the power supply is momentarily shorted out when both transistors are on, resulting in a loss of efficiency.  This "pause" need only be a few hundred nanoseconds, so waiting for a few instruction cycles to go by in the processor is enough.
  • After just a brief moment, pin RC4 is pulled low, turning on Q1, which then drags the negative side of C2 high.  When this happens, the positive side of C2 - which already has (approximately) the power supply voltage is at a potential well above that of the power supply voltage.
  • This higher voltage flows through diode D3 and charges capacitor C4, which acts as a reservoir:  This voltage on the positive side of C4 is now a volt or so less than twice the battery voltage.
  • Pin RC4 is then pulled high, turning of Q1.
  • There is a brief pause, as described above to prevent "shoot through", before we set RA4 high and turn Q2 on for the next cycle.

It is by this method that we generate a voltage several volts higher than that of the battery voltage, and this gives us a bit of "headroom" in our control of the LED current - and thus the brightness.

Current limiter:

Transistors Q3 and Q4 form a very simple current limiter:  In this case it is "upside-down" from the more familiar configuration as it uses PNP transistors - something that I did for no particular reason as the NPN configuration would have been just fine.

Figure 3:
Inside the "Word Metronome".  The 18650 LiIon cell is on
the right - a cast-off from an old computer battery pack.  The
buttons on the board are in parallel with those on the case and
were used during initial construction/debugging.
Click on the image for a larger version.

This circuit works by monitoring the voltage across R3:  If this voltage exceeds the turn-on threshold of Q3 - around 0.6 volts - it will turn on, and when this does it pulls the base voltage, provided by R5, toward Q4's emitter, turning off Q3.  By this action, the current will actually come to equilibrium at that which results in about 0.6 volts across R3 - and in this case, Ohm's law tells us that 0.6 volts across 47 ohms implies (0.6/47=0.0128 amps) around 13 milliamps:  At room temperature, this current was measured to be  a bit above 14 milliamps - very close to that predicted.

With this current being limited, the voltage of the power supply has very little effect on the current - in this case, that through the LEDs which means that it didn't matter whether the LED was of the 2 or 3 volt type, or the state-of-of charge of the battery:  The most that could ever flow through an LED no matter what was 14 milliamps.

With the current fixed in this manner, brightness could be adjusted using PWM (Pulse Width Modulation) techniques.  In this method, the duty cycle ("On" time) of the LED is varied to adjust the brightness.  If the duty cycle is 100% (on all of the time) the LED will be at maximum brightness, but if the duty cycle is 50% (on half of the time) the LED will be at half-brightness - and so-on.  Because the current is held constant, no matter what by the current limiter circuit, we know that the only think that affects brightness of the LED is the duty cycle.

LED multiplexing:

The final aspect of the LED drive circuitry is the fact that the LEDs are all connected in parallel, with transistors Q5-Q9 being used to turn them on.  When wiring LEDs in parallel, one must make absolutely sure that each LED is of the exact-same type or else that with the lowest voltage will consume the most current.

In this case, we definitely do NOT have same-type of LEDs (they are ALL different from each other) which means that if we were to turn on two LEDs at once, it's likely that only one of them would illuminate:  That would certainly be the case if, say, the red and blue LEDs would turn on:  With the red's forward voltage being in the 2.5 volt area, the voltage would be too low for the green, blue or white to even light up.

What this means is that only ONE LED must be turned on at any given instant - but this is fine, considering how the LEDs are used.  The red, yellow or green are intended to be on constantly to indicate the current beat rate (100, 130 or 160 BPM, respectively) with the blue LED being flashed to the beat (and the white LED flashing once-per-minute) - but by blanking the "rate" LED (red, yellow or green) LED when we want to flash the blue or white one, we avoid the problem altogether.

Battery charging:

Not shown in the schematic is the USB battery charging circuit.  Implementing this was very easy:  I just bought some LiIon charger boards from Amazon.  These small circuit boards came with a small USB connector (visible in the video, below) and a chip that controlled both charging and "cell protection" - that is, they would disconnect the cell if the battery voltage got too low (below 2.5-2.7 volts) to protect it.  Since its use is so straightforward - and covered by others - I'm only mentioning it in passing.


Because of its familiarity to me, I wrote the code for this device in C using the "PICC" compiler by CCS Computer Systems.  As it is my practice, this code was written for the "bare metal" meaning that it interfaces directly with the PIC's built-in peripherals and porting it to other platforms would require a bit of work.

The unit is controlled via two pushbuttons, using the PIC's own pull-up resistors.  One button primarily controls the rate while the other sets the brightness level between several steps, and pressing and holding the rate button will turn it off and on.  When "off", the processor isn't really off, but rather the internal clock is switched to 31 kHz and the charge pump and LED drivers are turned off, reducing the operating current of the processor to a few microamps at most.

Built into the software, there is a timer that, if there is no button press within 90 minutes or so, will cause the unit to automatically power down.  This "auto power off" feature is important as this device makes no noise and it would be very easy to accidentally leave it running.

Below is a short (wordless!) video showing the operation of the "Word Metronome" - enjoy!


This page stolen from ka7oei.blogspot.com


Sunday, July 31, 2022

Improving my ultrasonic sniffer for finding power line arcing by using MEMs microphones

Figure 1:
The packaged MEMs microphone, along with the
ultrasonic receiver.
Click on the image for a larger version.

Years ago - probably 20+ - I constructed a superheterodyne "Bat Listener" to eavesdrop on the goings-on of our winged Chiroptera friends.

In retrospect, this device is probably a lot more complicated than it need be as it up-converts from "audio" to a 125 kHz IF, using a modified 262.5 kHz Philco (Ford) car radio IF Can as the filtering element before being converted back down to audio.  This device has a built-in microphone, but it also has a jack for an external microphone, which comes in useful.

This device actually works pretty well for its intended purpose and, in a pinch, can even be used to listen to LF and VLF signals like the time station WWVB at 60 kHz and the powerful transmissions intended for submarines in the 20-40 kHz range if a simple wire is attached to the external microphone input, but I digress.

One of the weak points of this unit has always been the microphone.  To be sure, there exist the 40 kHz ultrasonic transducer modules:  These units used to be common in TV remote controls before the Infrared versions became common and you might still find them in the (now rare-ish) ultrasonic intrusion alarms.  While fairly sensitive, these units do have a "problem":  They are rather sharply resonant around their design frequency - which is typically somewhere around 40 kHz.  In other words, they aren't very good over much of the ultrasonic frequency range above or below 40 kHz.

It would seem that many commercial ultrasonic power mains arc detectors use these things (The MFJ-5008 seems to be an example of one of these) and there have been a few articles on how to make these devices (See the April, 2006 QST article, A Home-made Ultrasonic Power Line Arc Detector - link) but it, too, uses one of these "narrowband" 40 kHz transducers.

While certainly fit for purpose, I was more interested in something that could be used across the ultrasonic spectrum.  When I built my "bat listener" I fitted it with a "condensor" (electret) microphone, rummaging through and trying each of the units that I'd accumulated in my parts box at the time to find the one (make and model unknown) that seemed to be the most sensitive - but compared to a 40 kHz transducer, it was still somewhat "deaf".

This issue has nagged at me for years:  I occasionally break out the "bat listener" to (would you believe) listen for bats and other insects when camping, and it is useful if you have a suspected air leak in a compressed air system - plus it's sometimes just plain interesting to walk around the house and yard to hear what's happening at frequencies beyond human hearing.

In more recent years, an alternative to the electret microphone has appeared on the scene in the form of the MEMS (MicroElectricroMechanical System) microphone.  This class of devices are literally tiny mechanical devices embodied in silicon structures and they can range from oscillators to accelerometers to exotic tiny motors to (you guessed it) - microphones.  Their small size, which makes them the choice when space is at a premium, as in the case of a phone or web camera, also reduces the mass of the the mechanical portion that responds to variations in air pressure (e.g. sound) which can enable them to respond to frequencies from a few 10s of Hertz to well into the 10s of kHz.

Figure 2:
The MEMs microphone mounted and wired up.  The element
is mounted "dead bug" by gluing its top side to the circuit
board and small (#30) wires connect to the pads.
Click on the image for a larger version.

Perusing the data sheets of devices found on the Mouser Electronics web site, I found what seemed to be (one of many) suitable candidates:  The Knowles SPU0410LR5H-QB.  This device, which is a version with an analog output, is about 3mm by 4mm, has a rated frequency response to at least 80 kHz - and it is pretty cheap:  US$ 0.79 each in single quantities at the time of this writing - and, in these days of erratic supply lines, it was available immediately as Mouser reported having more then 30k of them in stock.  

Importantly, this device had its "audio port" on the same side as the wiring - the intention being that it would get its sound through a hole in the circuit board, but this would also make it easier to wire up as described below.

The fact that this is a small, surface-mounted device may seem daunting to the home building - but don't be daunted:  Given the appropriate magnification device (I use a pair of "Geezer Goggles" that I got from Harbor Freight) and a fine-tipped soldering iron, it's perfectly reasonable to solder just a few fine (30 gauge) wires to a device this small.

Figure 3:
The completed board, containing the circuit depicted in
Figure 4, below.  The board with the microphone is on
the left, and the attaching cable is seen in the upper-right.
LED1, the one across the microphone element itself,
was mounted on the bottom side of the board.
Click on the image for a larger version.

First, I cut a small piece of circuit board material to use as a substrate and mounted at a right angle on a larger piece, as shown.  I then took the microphone and "Super Glued" it "dead bug" to the middle of this board (see Figure 2, above) leaving the side with the connections and sound port facing outwards.

With this simple operation, a very tiny part suddenly becomes a larger, easier-to-manage part - albeit with very closely-spaced wire connections.  Being careful with very thin solder not to get any solder or flux in the sound port, I first tinned the connections on the device itself (there are four pads - two grounds, a power and an audio) and then proceeded to use some #30 "wire wrap" wire to make flying lead connections to the device, using a slightly longer section of one to tie the two "grounds" together.  I could have just as easily used some tinned #30 enameled wire, instead, but I tend to keep the Kynar-covered wire wrap wire on-hand for this very purpose.  

With the flying leads and the piece of circuit board as a "breakout" device, I was then free to treat the MEMs microphone as a "normal sized" device and build an interface circuit onto the rest of the board.

In perusing the data sheet, I noted that the power supply voltage rating was 1.5-3.6 volts which was incompatible with the 5 volts of "phantom power" applied by my bat listener to the microphone jack to power a condensor (electret) microphone, but this was easily remedied using the circuit shown below:

Figure 4:
The interface circuit used to adapt the MEMs microphone to the existing 5-volt
electrect microphone circuit.
Click on the image for a larger version.

Circuit description:

This circuit depends on there being power applied via the audio/microphone lead, as is commonly done for computer microphones.  Typically, this is done by biasing the audio line through a resistor (2.2-10k is common) from a 5 volt supply - and that is assumed to have been done here on the device to which this will be connected, as I did on my "bat listener".

DC is decoupled from the audio output of the microphone via C1.  In this circuit, I chose a 0.01uF capacitor as I wanted to reject audible frequencies (<10 kHz) to a reasonable extent - and this means that this capacitor value is way too small if you plan to use it as a "normal" microphone to listen well down into the lower audible range:  Something on the order of 1-10 uF would be appropriate if you do want audio response down to a few 10s or 100s of Hz.  A word of warning:  Do NOT use a ceramic capacitor for C1 as these can be microphonic in their own right.  I used a 0.01uF plastic capacitor (probably polyester) which is neither microphonic or prone to change capacitance wildly with temperature.

Resistor R1 (2.2k shown here, but anything from 2.2k to 4.7k would likely be just fine) decouples the audio from the DC and capacitor C2 removes that audio, providing a "clean" power source for the microphone.

Here, LED2 is used as a voltage limiter:  Being an "old fashioned" green panel indicator LED, it's forward voltage is somewhere around 2 volts.  The use of an LED in this manner has the advantage that unlike a Zener, this type type of LED has a very sharp "knee" and practically no leakage current below its forward voltage - and it is much easier to find than a 2-2.5 volt Zener.  It's likely that about any LED would work here - including a more modern Gallium Nitride type (e.g. blue, white, super bright green) but I have not verified that they would properly clamp the voltage in the 1.5-3.6 volt range needed by the microphone.  (And no, there are not any detectable effects on the circuit from light impinging on the LEDs.)

LED1 is present to protect the microphone itself.  When it's plugged in, whatever voltage is present on the audio cable will be dumped into the microphone output as capacitor C1 is charged and it could damage it, particularly if the power source is 5 volts and the microphone's maximum rated voltage is just 3.6 volts.  This LED, which is the same type as LED2, will not normally conduct as the audio output from the microphone typically has a voltage of roughly half that of the supply, so LED1 will be completely "invisible" (in the electrical sense) in normal operation.

Figure 5:
A spring, soldered to a wire connecting to the "ground"
side of the circuit (also the microphone cable shield)
used to make contact with the aluminum tubing.
Click on the image for a larger version.

I mounted the board with the microphone in a piece of aluminum tubing that would fit the microphone mount of my parabolic dish (see below) and this not only provides protection for the microphone and circuitry, but also serves as an electrostatic shield, preventing energy - say, from a power line - getting into the circuitry.  To make this effective, the tubing itself is connected to the ground lead (cable shield) by soldering a wire to a metal spring and placing it in the end of the tubing as seen in Figure 5.

To secure things into place, a bit of "hot melt" glue was used, preventing the board from sliding out.  The connection to the receiver was made via a length of PTFE (Teflon) RG-316 coaxial cable - but shielded audio cable would have sufficed:  This cable is firmly attached to the board as seen in Figure 3 as a strain relief. 

The parabola:

While the microphone is sensitive in its own right, its sensitivity can be noiselessly "amplified" many-fold by placing it at the focus of a parabolic dish.  I was fortunate to have obtained a Dan Gibson EPM model P-200 (minus the original microphone element or any electronics, but including the holder) at a swap meet, but the QST article linked above suggests other sources - and I have seen parabolic-based microphones on Amazon - often as semi-serious toys - as well.  Using the holder - the inner diameter of which was the basis for choosing the specific size of the aluminum tubing - the microphone was mounted at the focus of the dish.

Finding this focus can be a bit of a challenge without the proper equipment, so I set up a "test range".  At one end of my back yard I placed a 40 kHz transducer (of the sort noted in the QST article linked above) connected to a function generator set to 40 kHz:  I'm sure that a small speaker would have been sufficient to generate a signal.

Figure 6:
The MEMs microphone, mounted in the aluminum
tubing, at the focus of the parabolic dish, with attached
Click on the image for a larger version.

From across the yard - perhaps 30 feet (10 meters) away, I sighted the emitter through the dish, using its alignment dots and slid the microphone in and out until I had the best combination of the loudest signal, the sharpest aiming, and the "cleanest" pattern.  On this last point, I noted that if I focused too far in our out, the peak of the signal would become "blurry" (e.g. spread out) or, in some cases, I would get two peaks on either side of the "real" one, so the object was to have the single, loudest peak possible.  Once this was found, it was marked and a bit of heat-shrink tubing was put over the end of the aluminum tube, corresponding with that mark, to act as a "stop" to set the correct focus depth.

Again, refer to the QST article linked above for additional advice on where to obtain a suitable parabolic reflector, and hints on the mechanical construction.

Does it work?

The answer is yes.  From significant distances, I can hear the acoustic signature of switching power supplies (apparently, many of these have transformers that vibrate at their 30-60 kHz switching frequency) as well as the sounds of insects, the hissing of the capillary valve of the neighbor's window air conditioner.

Importantly, I was able to verify that a power pole's hardware was, in fact, arcing slightly - although I wasn't able to determine which hardware, exactly was making the racket as it was quiet enough that it became inaudible when I stood far enough away from the (tall!) pole to get a better viewing angle.

When I get the chance, I will replace the capsule electret microphone built into the receiver itself with one of these MEMs units, but that's just one project on a rather long list!

This page stolen from ka7oei.blogspot.com


Wednesday, June 29, 2022

The use case for a blinking infrared LED

Many years ago at a company where I worked, we had two sets of computer systems:  The ones that we used every day for engineering purposes, and the "corporate" computers that were used for things like "official" email and interfacing with accounting.

Figure 1:
The IR (clear) LED and the red blinking LED.
The red LED was uncovered for this picture.  The IR
LED is positioned to stick up, inside the mouse's lens
assembly when it's placed atop the pad.
Click on the image for a larger version.
One day, the edict came from on-high that the corporate computers would log themselves off the network after a ridiculously short amount of time (it may have been as little as 5 minutes) if no mouse or keyboard activity was used.

This was particularly bothersome to the local accountant person who would have to turn away from the corporate computer for a few minutes at a time to do something else (paperwork, answer a phone, etc.) only to find that it had logged off and out of whatever application was running.  To make matters worse, it took several minutes to log back in as the authentication was painfully slow:  This was way back in the late 1990s/early 2000s, you know!


It should go without saying that absurd and draconian "security" measures like those described above are usually self-defeating:  It adds unnecessary frustration to those using the system, causing "creative" means to be derived to circumvent it which can completely defeat the intent of the measures.  It had already been the practice of the person using this computer to log off when stepping out of the office (and locking it!) but we heard of other "interesting" ways that others came up with to circumvent this within the company. 
Fortunately, it was only a few months later that the computer security folks came up with a much more sensible plan and the device described here was no longer "needed".
After several weeks of being frustrated by this - and being denied the request to lengthen the auto-logoff to something more reasonable like 10-30 minutes, I was asked if there was something that I could do.  The first thing that I thought of was some motorized do-hickey that would move the mouse just a little bit to make it "look" like the computer was in use - but something else occurred to me:  Interfere with the optical mouse in some way.

Modern optical mouses (mice?) literally take a picture of the desktop - many times a second - and divine the movement by tracking very small features under them.  Fortunately most surfaces have small-scale features that make this possible - but if you were ever wondering why an optical mouse doesn't work well on a piece of clean glass - now you know!

Figure 2:
The optical mouse atop the IR LED.  The IR LED fits
up inside the lens cavity.  The entire circuit was inserted
and built into a piece of scrap mouse pad.
Click on the image for a larger version.
So, how would one make the think the mouse is moving - without actually moving it?  It occurred to me that a flashing, red LED would accomplish this.  A quick test by sticking the blinking LED up into the lens assembly showed that as it blinked, the cursor would move one "Mickey" (the unit of mouse movement - look it up!) up and to the right on this particular mouse, satisfying the computer that the mouse was actually being moved.  It didn't seem to matter that the mouse cursor would inevitably end up in the top-right corner of the screen - it seemed to stop the time-out nonetheless.

This worked well - but what if a blinking LED bothers you?  The answer is a blinking infrared LED.

Where does one get a blinking Infrared LED?

Of course, no-one makes such a thing (why would they?) - but the work-around is simple:  Place an ordinary infrared LED in series with a visible blinking one and place the latter LED out of sight.

Infrared LEDs - which may be harvested from defunct/surplus infrared remotes - come in two flavors:  Those that operate at 850 nanometers, and those that operate at 940 nanometers.  The 850 nanometer versions are just visible to the human eye (in a dark room) and work best in this situation as they are well within the response curve of the sensor in the mouse:  In fact, some optical mouses (mice?) use Infrared LEDs to be more "stealthy".  I didn't try a 940 nanometer LED, but I know from experience that if something operates on a visible (red) wavelength, it will likely work just fine with an 850 nanometer LED.

The circuit to do this was very simple, and is as follows:

Figure 3:
Diagram of the circuit - pretty simple, actually!
As noted, the voltage can be anywhere between 9 and 15 volts DC - 12 volts nominal.
Click on the image for a larger version.

The power supply used was a random "wall wart":  The one that I'd grabbed was marked 9 volts at 100 milliamps and it put out about 13 volts DC under no load, but any DC voltage between 9 and 15 volts ought to be fine:  5 volts from a USB charger is simply too low!

The way this works is that with the two LEDs in series, the current in the two LEDs MUST be identical (Kirkhoff's law and all of that...) which means that when the blinking LED was on, more current also went through the other LED, making it brighter.  When the blinking LED was off, the other LED doesn't go completely off, but it gets noticeably dimmer - which was enough to make the mouse detect "movement".  The 470 ohm resistor limits the current to a safe value and the 100 uF capacitor provides a bit of bypassing that helps assure that the blinking LED will function properly:  It may work without it - but not all blinking LEDs do.  Because they are in series, it doesn't matter the order in which the LEDs are placed - just that they are in series and connected correctly in terms of polarity.

If you are unsure that the infrared LED is blinking, check it with your cell-phone camera as it will respond adequately to Infrared, particularly up-close, and with 850 nanometer LEDs.

This trick also works with other LEDs:  If you have a cheap, red blinking LED but not one of the color that you might want to blink (say a white or blue LED) this could be substituted for the "IR LED".  Again, the "other" LED may not extinguish completely during the "off"portion and if this bothers you, a resistor could be placed across it to "bridge" some of the current around it (e.g. the non-blinking LED) and drop the voltage below its illumination threshold:  The value would have to be experimentally determined.

There you go:  A use-case for a blinking infrared LED!

* * *

This page stolen from ka7oei.blogspot.com


Saturday, May 28, 2022

Fixing a TS-570G (The tuner couldn't find a match, timing out...)

The TS-570D's front panel

 A couple of months ago I happened to be at a swap meet in Northern Utah and talking to a gentlemen - with whom I had a passing acquaintance - as he was unloading his vehicles.  One of the things that he placed on his table was a Kenwood TS-570D, in its original box, with a price tag on it that seemed to be too good to be true.

Asking about it, he said that it worked fine, but that the "tuner wouldn't stop", so it had to be used with the antenna tuner bypassed.  Visually inspecting it, it looked to be in "good nick" (a 4 out of 5) so I shut up and gave him the money.

After digging out from underneath a few other projects, I finally took a look at it and sure enough, pressing the AT TUNE button started a bout of furious clicking that didn't stop for about 30 seconds with the radio beeping an error.  I couldn't help but notice, however, that there was no SWR or power output indication while the tuner was doing its thing - but if I bypassed the tuner, both of these were true.

Going into the menu (#11 - "Antenna tuner operation while receiving") I set that to "on" and noticed that the receiver went mostly dead - a sure sign that something was amiss with the signal path through the tuner.  Popping the covers, I whacked on the relays with the handle of a screwdriver while the radio was connected to an antenna and could hear signals come and go.  This attempt at "percussive repair" quickly narrowed the culprit to relay K1, the relay that switches the antenna tuner in and out of the signal path.

A few weeks later, after having ordered and receive a new relay, I cleared enough space on the workbench to accommodate the radio and commenced a repair.

The repair:

The antenna tuner is on the same, large circuit board as the final and low-pass filter, which meant that not only were there a zillion screws to take out, but I also had to remove the white thermal heat-sink compound from several devices, un-clip the back panel connectors and un-plug a few signal cables.  Using my trusty Hakko DFR-300 desoldering gun, I was able to cleanly remove both K1 and - because I had two relays, and they were identical - K3 as well, soldering in the replacement.

When I'd pulled the board, I also noticed that components "D10" - which is a glass discharge tube across Antenna connector #2 - had some internal discoloration, possibly indicating that it had seen some sort of stress, so I rummaged about and found two 350 volt Bourns gas discharge tubes and replaced both "D10" and "D11" - the unit on the Antenna #1 connector.  Unlike the originals - which are glass - these are metal and ceramic, requiring that I put a piece of polyamide (a.k.a. Kapton) tape on the board to insulate them from the traces underneath.  The leads of these new devices were also much heavier and would not fit through the board (drilling larger would remove through-plating!) so I soldered short lengths of #24 tinned wire through the holes and used these to attach the straight leads of the new discharge tubes.

After cleaning the board of flux with denatured alcohol and an old toothbrush, I put an appropriately sparse amount of heat sink compound on the required devices, loosely started all of the screws and with everything fitting, I snugged them all down, finishing with the RF output transistors - and then re-checking everything again to make sure that I didn't miss anything.

After plugging the connecting cables back in I noted that the receiver now worked through the tuner and pressed the AT Tune button and was greeted with lots of clicking and varying VSWR - but still, it continued and eventually errored out.

Figuring that the radio's computer may have been messed up, I did a complete CPU reset, but to no avail.  Because the SWR and power indication were working correctly, I knew that this wasn't likely to be a component failure like the reverse power detection circuit, so it had to be something amiss with the configuration, so I referred to the service manual's section about the "Service Adjustment Mode".

Going through the Service Adjustment Mode Menu:

Like most modern radios, this one has a "Service Menu" where electronic calibration and adjustments are performed and to get to it, I inserted a wire between pins 8 and 9 of the ACC2 jack and powered up the radio while holding the N.R. and LSB USB keys and having done this, a new menu appeared.  On a hunch, I quickly moved to menu #18 - the adjustment for the 100 watt power level.

What is supposed to happen is that if you key the radio, it will transmit a 100 watt carrier on 14.2 MHz, but instead, I got about 60 watts, and checking the related settings for 50, 25, 10 and 5 watts, I got very low power levels for each of those as well.  To rule out an amplifier failure, I went back to the 100 watt set-up and pressed the DOWN button, eventually getting over 135 watts of output power, indicating that there was nothing wrong with the finals, but rather that the entire "soft calibration" procedure would have to be followed.

Starting at the beginning of the procedure which begins with receiver calibration, I found everything to be "wrong" in the software calibration, indicating that either it was improperly done, or the original calibration had somehow been lost and replaced with default values.  I checked a few of the hardware adjustments, but found them to be spot on - the exception being the main reference oscillator, which was about 20 Hz off at 10 MHz, which I dialed back in, chalking this up with aging of the crystal.

During the procedure, I was reminded by a few peculiarities - and noticed some likely errors, and here they are in no particular order:

  • Many of these menu items are partially self-calibration, which is to say that you establish the condition called out in the procedure and push the UP or DOWN button.  For example, on menu item #16 where the Squelch knob is calibrated, one merely sets it to the center of rotation, the voltage is shown on the screen in hexidecimal, and you press the button and the displayed value is stored temporarily in memory.
  • I'm a bit OCD when it comes to S-meter calibration, preferring my S-units to be 6 dB apart, S-9 to be represented by a -73dBm signal as noted by the IRU specifications, and for "20 over" to actually be "20 over S-9", or around -53 dBm.  The procedure in the manual - and the radio itself doesn't permit this, exactly.
    • To set the "S1" signal level (menu item #3) would require a signal level -121 dBm, but the receiver's AGC doesn't track a signal below around -113 dBm.  Instead, I noted the no-signal level on the display when menu #3 was selected and then set the signal level to an amplitude that just caused the hexidecimal number to increase and then pushed the button, setting "S1" to be equivalent to the lowest-possible signal level to which the AGC reacts.
    • To set the "S9" signal level (menu item #4) I set the signal generator to -73dBm and pressed the button.
    • To set the "Full scale" level (menu item #5) I set the signal generator to -23 dBm and pressed the button.  If you have followed the math, you'll note that "Full Scale" - which is represented as "60 over" should really be -13 dBm, but I observed that the AGC seemed to compress a bit at this signal level and the "20 over" and "40 over" readings came out wrong:  Using a level of -23 dBm got the desired results.
    • NOTE:  The service menu forces the pre-amp to be enabled when doing the S-meter calibration (e.g. you can't disable it when in the service menu) so the S-meter calibration only holds when the pre-amp is turned on.
  •  For setting menu item #1, "ALC Voltage" I was stumped for a bit.  It mentions measuring "TP1" - but this is not the "TP1" on the transmitter board, but rather the TX/RX unit (the board underneath the radio).
  • I noticed that if step #7 was followed to set the 100 watt power level, it was difficult to properly set menu items 23-28 (the "TGC" parameters).  These adjustments set to 100 watts, but if you have already set menu item #18 at 100 watts, you can't be sure that you've properly done it.
    • The work-around is that prior to step #6 in the procedure that you go to menu item #18 and adjust for higher than 100 watts - say, 125 watts.  If this is done, you can adjust menu items 23-28 (noting that menu #27 is adjusted out-of-order in procedure step #6) to 100 watts.
    • Once procedure steps 6, 7 and 8 are done (but skipping the adjustment for menu #18 in step 7) you can go back to menu #18 and adjust for 100 watts.
  • For procedure steps 16 and 17, I didn't have a 150 ohm dummy load, but I did have several 50 ohm loads, so I put three of them in parallel - which yields 16.67 ohms, which is also a 3:1 VSWR - and completed these steps.  It's worth noting that Yaesu uses 16.67 ohms for the equivalent step in its alignment procedures.  To set the "40 watts" called out in step 17 I used the front-panel power meter, which would have already been calibrated in the procedure.

The result:

As mentioned, the "hardware" calibration seemed to be fine and only the "soft" calibration was off and after following this procedure, the tuner worked exactly as it should.  What I suspect was occurring was a combination of the the output power being too low to calculate an SWR (e.g. setting the radio to "5 watts" yielded less then 2) and that the SWR meter calibration itself was incorrect and that this combination of factors prevented the tuner from being able to find a match.

Since the repair, the TS-570 has been used several times per week and it is working just as it should!

This post stolen from ka7oei.blogspot.com


Saturday, April 30, 2022

Implementing the (functional equivalent of a) Hilbert Transform with minimal overhead

I recently had need to take existing audio and derive a quadrature pair of audio channels from this single source (e.g. the two channels being 90 degrees from each other) in order to do some in-band frequency conversion (frequency shifting).  The "normal" way to do this is to apply a Hilbert transformation using an FIR algorithm - but I needed to keep resources to an absolute minimum, so throwing a 50-80 tap FIR at it wasn't going to be my first choice.  

Another way to do this is to apply cascaded "Allpass" filters.  In the analog domain, such filters are used not to provide any sort of band-filtering effect, but to cause a phase change without affecting the amplitude and by carefully selecting several different filters and cascading them.  This is often done in "Phasing" type radios and this is accomplished with 3 or 4 op amp sections (often Biquad) cascaded - with another, similar branch of op-amps providing the other channel.  By careful selection of values, a reasonable 90 degree phase shift between the two audio channels can be obtained over the typical 300-3000 Hz "communications" bandwidth such that 40+ dB of opposite sideband attenuation is obtainable.


One tool that allows this to be done in hardware using op amps is Tonne Software's  "QuadNet" program which is an interactive tool that allows the input and analysis of parameters to derive component values - see http://tonnesoftware.com/quad.html .

I wished to do this in software, so a bit of searching let me to an older blog entry by Olli Niemitalo of Finland, found here:  http://yehar.com/blog/?p=368  which, in turn, references several other sources, including:

This very same same technique is also used in the "csound" library (found here) - a collection of tools that allow manipulation of sound in various ways.

My intent was this to be done in Javascript where I was processing audio real-time (hence the need for it to be lightweight) and this fit the bill.  Olli's blog entry provided suitable information to get this "Hilbert" transformation working.   Note the quotes around "Hilbert" indicating that it performs the function - but not via the method of a "real" Hilbert transform in the sense that it provides a quadrature signal.

The beauty of this code is that only a single multiplication is required for each channel's filter - a total of eight multiplications in all for each iteration of the two channels - each with four sections - something that is highly beneficial when it comes to keeping CPU and memory utilization down!

As noted above, this code was implemented in Javascript and the working version is represented below:  It would be trivial to convert this to another language - particularly C:

* * *

Here comes the code!

First, here are the coefficients used in the allpass filters themselves - the "I" and the "Q" channels being named arbitrarily:

// Biquad coefficients for "Hilbert - "I" channel
  var ci1=0.47940086558884;  //0.6923878^2
  var ci2=0.87621849353931; //0.9360654322959^2
  var ci3=0.97659758950819; //0.9882295226860^2
  var ci4=0.99749925593555; //0.9987488452737^2
  // Biquad coefficients for "Hilbert" - "Q" channel
  var cq1=0.16175849836770; //0.4021921162426^2
  var cq2=0.73302893234149; //0.8561710882420^2
  var cq3=0.94534970032911;  //0.9722909545651^2
  var cq4=0.99059915668453;  //0.9952884791278^2

Olli's page gives the un-squared values as it is a demonstration of derivation - a fact implied by the comments in the code snippet above.

In order to achieve the desired accuracy over the half-band (e.g. half of the sampling rate) a total of FOUR all-pass sections are required, so several arrays are needed to hold the working values as defined here:

  var tiq1=[0,0,0];  // array for input for Q channel, filter 1
  var toq1=[0,0,0];  // array for output for Q channel, filter 1
  var tii1=[0,0,0];  // array for input for I channel, filter 1
  var toi1=[0,0,0];  // array for output for I channel, filter 1
  var tiq2=[0,0,0];  // array for input for Q channel, filter 2
  var toq2=[0,0,0];  // array for output for Q channel, filter 2
  var tii2=[0,0,0];  // array for input for I channel, filter 2
  var toi2=[0,0,0];  // array for output for I channel, filter 2
  var tiq3=[0,0,0];  // array for input for Q channel, filter 3
  var toq3=[0,0,0];  // array for output for Q channel, filter 3
  var tii3=[0,0,0];  // array for input for I channel, filter 3
  var toi3=[0,0,0];  // array for output for I channel, filter 3
  var tiq4=[0,0,0];  // array for input for Q channel, filter 4
  var toq4=[0,0,0];  // array for output for Q channel, filter 4
  var tii4=[0,0,0];  // array for input for I channel, filter 4
  var toi4=[0,0,0];  // array for output for I channel, filter 4


The general form of the filter as described in Olli's page is as follows:

 out(t) = coeff*(in(t) + out(t-2)) - in(t-2)

In this case,  our single multiplication is with our coefficient being multiplied by the input sample, and from that we add our output from two operations previous and subtract from that our input value - also  from two operations previous.

The variables "tiq" and "toq" and "tii" and "toi" refer to input and output values of the Q and I channels, respectively.  As you might guess, these arrays must be static as they must contain the results of the previous iteration.

The algorithm itself is as follows - a few notes embedded on each section

  tp0++;        // array counters
  if(tp0>2) tp0=0;

// The code above uses the modulus function to make sure that the working variable arrays are accessed in the correct order.  There are any number of ways that this could be done, so knock yourself out!

// The audio sample to be "quadrature-ized" is found in "tempa" - which should be a floating point number in the implementation below.  Perhaps unnecessarily, the output values of each stage are passed in variable "di" and "dq" - but this was convenient for initial testing.

  // Biquad section 1
  di=ci1*(tii1[tp0] + toi1[tp2]) - tii1[tp2];

  dq=cq1*(tiq1[tp0] + toq1[tp2]) - tiq1[tp2];

  // Biquad section 2

  di=ci2*(tii2[tp0] + toi2[tp2]) - tii2[tp2];

  dq=cq2*(tiq2[tp0] + toq2[tp2]) - tiq2[tp2];

  // Biquad section 3

  di=ci3*(tii3[tp0] + toi3[tp2]) - tii3[tp2];

  dq=cq3*(tiq3[tp0] + toq3[tp2]) - tiq3[tp2];

  // Biquad section 4

  di=ci4*(tii4[tp0] + toi4[tp2]) - tii4[tp2];

  dq=cq4*(tiq4[tp0] + toq4[tp2]) - tiq4[tp2];

// Here, at the end, our quadrature values may be found in "di" and "dq"

* * *

Doing a frequency conversion:

The entire point of this exercise was to produce quadrature audio so that it could be linearly shifted up or down while suppressing the unwanted image - this being done using the "Phasing method" - also called the "Hartley Modulator" in which the quadrature audio is mixed with a quadrature local oscillator and through addition or subtraction, a single sideband of the resulting mix may be preserved.

An example of how this may be done is as follows:

  i_out = i_in * sine + q_in * cosine;
  q_out = q_in * sine - i_in * cosine;

In the above, we have "i_in" and "q_in" - which are the I and Q audio inputs, which could be our "di" and "dq" samples from our "Hilbert" transformation and with this is an oscillator with both sine and cosine outputs (e.g. 90 degrees apart).

These sine and cosine value would be typically produced using an NCO - a numerically-controlled oscillator - running at the sample rate of the audio system.  In this case, I used a 1k (1024) entry sine wave table with the cosine being generated by adding 256 (exactly 1/4th of the table size) to its index pointer.

If I needed just one audio output from my frequency shifting efforts, I could use either "i_out" or "q_out" so one need not do both of the operations, above - but if one wanted to preserve the quadrature audio after the frequency shift, the code snippet shows how it could be done.

* * *

Does it work?

Olli's blog indicates that the "opposite sideband" attenuation - when used with a mixer - should be on the order of -43 dB at worst - and actual testing indicated this to be so from nearly DC.  This value isn't particularly high when it comes to the "standard" for communications/amateur receivers where the goal is typically greater than 50 or 55 dB, but in casual listening, the leakage is inaudible.

One consequence of the attenuation being "only" 43 dB or so is that if one does frequency shifting, a bit of the local oscillator used to accomplish this can bleed through - and even at -43 dB, a single, pure sine wave can often be detected by the human ear amongst the noise and audio content - particularly if there is a period of silence.  Because this tone is precisely known, can be easily removed with the application of a moderately sharp notch filter tuned to the local oscillator frequency.

This page stolen from ka7oei.blogspot.com


Sunday, February 27, 2022

High power Tayloe (a.k.a. Wheatstone) absorptive bridge for VSWR indication and rig protection.

Figure 1:  The completed absorptive VSWR bridge.
Last year, I was "car camping" with a bunch of friends - all of which happened to be amateur radio operators.  Being in the middle of nowhere where mobile phone coverage was not even available, we couldn't resist putting together a "portable" 100 watt HF station.  While the usual antenna tuner+VSWR meter would work fine, I decided to build a different piece of equipment that would facilitate matching the antenna and protecting the radio - but more on this in a moment.

A bit about the Wheatstone bridge:

The Wheatsone bridge is one of the oldest-known types of electrical circuits, first having been originated around 1833 - but popularized about a decade later by Mr. Wheatstone itself.  Used for detecting electrical balance between the halves of the circuit, it is useful for indirectly measuring all three components represented by Ohm's law - resistance, current and voltage.

Figure 2:  Wheatstone bridge (Wikipedia)
It makes sense, then, that an adaptation of this circuit - its use popularized by Dan Tayloe (N7VE) - can be used for detecting when an antenna is matched to its load.  To be fair, this circuit has been used many decades for RF measurement in instrumentation - and variations of it are represented in telephony - but  some of its properties that are not directly related to its use for measurement that make it doubly useful - more on that shortly.

Figure 2 shows the classic implementation of a Wheatstone bridge.  In this circuit, balance of the two legs (R1/R2 and R3/Rx) results in zero voltage across the center, represented by "Vg" which can only occur when the ratio between R1 and R2 is the same as the ratio between R3 and Rx.  For operation, that actual values of these resistors is not particularly important as long as the ratios are preserved.

If you think of this is a pair of voltage dividers (R1/R2 and R3/Rx) its operation makes sense - particularly  if you consider the simplest case where all four values are equal.  In this case, the voltage between the negative lead (point "C") and point "D" and points "C" and "B" will be half that of the battery voltage - which means the voltage between points "D" and "B" will be zero since they must be at the same voltage.

Putting it in an RF circuit:

Useful at DC, there's no reason why it couldn't be used at AC - or RF - as well.  What, for example, would happen if we made R1, R2, and R3 the same value (let's say, 50 ohms), instead of using a battery, substituted a transmitter - and for the "unknown" value (Rx) connected our antenna?

Figure 3:  The bridge, used in an antenna circuit.

This describes a typical RF bridge - known when placed between the transmitter and antenna as the "Tayloe" bridge, the simplified diagram of which being represented in Figure 3.

Clearly, if we used, as a stand-in for our antenna, a 50 ohm load, the RF Sensor will detect nothing at all as the bridge would be balanced, so it would make sense that a perfectly-matched 50 ohm antenna would be indistinguishable from a 50 ohm load.  If the "antenna" were open or shorted, voltage would appear across the RF sensor and be detected - so you would be correct in presuming that this circuit could be used to tell when the antenna itself is matched.  Further extending this idea, if your "Unknown antenna" were to include an antenna tuner, looking for the output of the RF sensor to go to zero would indicate that the antenna itself was properly matched.

At this point it's worth noting that this simple circuit cannot directly indicate the magnitude of mismatch (e.g. VSWR - but it can tell you when the antenna is matched:  It is possible to do this with additional circuitry (as is done with many antenna analyzers) but for this simplest case, all we really care about is finding when our antenna is matched.  (A somewhat similar circuit to that depicted in Figure 3 has been at the heart of many antenna analyzers for decades.)

Antenna match indication and radio protection:

An examination of the circuit of Figure 3 also reveals another interesting property of this circuit used in this manner:  The transmitter itself can never see an infinite VSWR.  For example, if the antenna is very low resistance, we will present about 33 ohms to the transmitter (e.g. the two 50 ohm resistors on the left side will be in parallel with the 50 ohm resistor on the right side) - which represents a VSWR of about 1.5:1.  If you were to forget to connect an antenna at all, we end up with only the two resistors on the left being in series (100 ohms) so our worst-case VSWR would, in theory, be 2:1.

In context, any modern, well-designed transmitter will be able to tolerate even a 2.5:1 VSWR (probably higher) so this means that no matter what happens on the "antenna" side, the rig will never see a really high VSWR.

If modern rigs are supposed to have built-in VSWR protection, why does this matter?

One of the first places that the implementation of the "Tayloe" bridge was popularized was in the QRP (low power) community where transmitters have traditionally been very simple and lightweight - but that also means that they may lack any sophisticated protection circuit.  Building a simple circuit like this into a small antenna tuner handily solves three problems:  Tuning the antenna, being able to tell when the antenna is matched, and protecting the transmitter from high VSWR during the tuning process.

Even in a more modern radio with SWR protection there is good reason to do this.  While one is supposed to turn down the transmitter's power when tuning an antenna, if you have an external, wide-range tuner and are quickly setting things up in the field, it would be easy to forget to do so.  The way that most modern trasmitter's SWR protection circuits work is by detecting the reflected power, and when it exceeds a certain value, it reduced the output power - but this measurement is not instantaneous:  By the time you detect excess reflected power, the transmitter has already been exposed - if only for a fraction of a second - to a high VSWR, and it may be that that brief instant was enough to damage an output transistor.

In the "old" days of manual antenna tuners with variable capacitors and roller inductors, this may have not been as big a deal:  In this case, the VSWR seen by the transmitter might not be able to change too quickly (assuming that the inductor and capacitors didn't have intermittent connections) but consider a modern, automatic antenna tuner full of relays:  Each time the internal tuner configuration is changed to determine the match, these "hot-switched" relays will inevitably "glitch" the VSWR seen by the radio, and with modern tuners, this can occur many times a second - far faster than the internal VSWR protection can occur meaning that it can go from being low, with the transmitter at high power, to suddenly high VSWR before the power can be reduced, something that is potentially damaging to a radio's final amplifier.  While this may seem to be an unlikely situation, it's one that I have personally experienced in a moment of carelessness - and it put an abrupt end to the remote operation using that radio - but fortunately, another rig was at hand.

A high-power Tayloe bridge:

It can be argued that these days, the world is lousy with Tayloe bridges as they are seemingly found everywhere - particularly in the QRP world, but there are fewer of them that are intended to be used with a typical 100 watt mobile radio - but one such example may be seen below:

Figure 4:  As-built high-power Tayloe bridge

Figure 4 shows a variation of the circuit in Figure 2, but it includes two other features:  An RF detector, in the form of an LED (with RF rectifier) and a "bypass" switch, so that it would not need to be manually removed from the coax cable connection from the radio.

In this case, the 50 ohm resistors are thick-film, 50 watt units (about $3 each) which means that they are capable of handling the full power of the radio for at least a brief period.  Suitable resistors may be found at the usual suppliers (Digi-Key, Mouser Electronics) and the devices that I used were Johanson P/N RHXH2Q050R0F4 (A link to the Mouser Electronics page is here) - but there is nothing special about these particular devices:  Any 50-100 watt, TO-220 package, 50 ohm thick-film resistor with a tolerance of 5% or better could have been used, provided that its tab is insulated from the internal resistor itself (most are). 

How it works:

Knowing the general theory behind the Wheatstone bridge, the main point of interest is the indicator, which is, in this case, an LED circuit placed across the middle of the bridge in lieu of the meter shown in  Figure 1.  Because RF is present across these two points - and because neither side of this indicator is ground-referenced, this circuit must "float" with respect to ground.

If we presume that there will be 25 volts across the circuit - which would be in the ballpark of 25 watts into a 2:1 VSWR - we see that the current through 2k could not exceed 25 mA - a reasonable current to light an LED.  To rectify it, a 1N4148 diode - which is both cheap and suitably fast to rectify RF (a garden-variety 1N4000 series diodes is not recommended) along with a capacitor across the LED.  An extra 2k LED is present to reduce the magnitude of the reverse voltage across the diode:  Probably not necessary, bit I used it, anyway.  QRP versions of this circuit often include a transformer to step up the low RF voltage to a level that is high enough to reliably drive the LED, but with 5-10 watts, minimum, this is simply not an issue.

While there are many examples of this sort of circuit - all of them with DPDT switches to bypass the circuit - every one that I saw wired the switch in such a way that if one were to be inadvertently transmitting while the switch was operated, there would be a brief instant when the transmitter was disconnected (presuming that the switch itself is a typical "break-before-make") that could expose the transmitter to a brief high VSWR transient.  In Figure 3, this switch is wired differently:

  • When in "Bypass" mode, the "top" 50 ohm resistor is shorted out and the "ground" side of the circuit is lifted.
  • When in "Measure" mode, the switch across the "top" 50 ohm resistor is un-bridged and the bottom side of the circuit is grounded.

Figure 5:  Inside the bridge.
Wired this way, there is no possible condition during the operation of the switch where the transmitter will be exposed to an extraordinarily high VSWR - except, of course, if the antenna itself is has an extreme mismatch - which would happen no matter what if you were to switch to "bypass" mode.

An as-built example:

I built my circuit into a small die-cast aluminum box as shown in Figure 5.  Inside the box, the 50 ohm resistors are bolted to the box itself using countersunk screws and heat-sink paste for thermal transfer.  To accommodate the small size of the box, single-hole UHF connectors were used and the circuit itself was point-to-point wired within the box itself.

Figure 6:  The "switch" side of the bridge.
For the "bypass" switch (see Figure 6) I rescued a 120/240 volt DPDT switch from an old PC power supply, choosing it because it has a flat profile with a recessed handle with a slot:  By filing a bevel around the square hole (which, itself was produced using the "drill-then-file" method) one may use a fingernail to switch the position.  I chose the "flush handle" type of switch to reduce the probability of it accidentally being switched, but also to prevent the switch itself from being broken when it inevitably ends at the bottom of a box of other gear.
On the other side of the box (Figure 7) the LED is nearly flush-mounted, secured initially with cyanoacrylate (e.g. "Super") glue - but later bolstered with some epoxy on the inside of the box.
It's worth noting that even though the resistors are rated for 50 watts, it's unlikely that even this much power will be output by the radio will approach that in the worst-case condition - but even if it does, the circuit is perfectly capable of handling 100 watts for a few seconds.  The die-cast box itself, being quite small, has rather limited power dissipation on its own (10-15 watts continuous, at most) but it is perfectly capable of withstanding an "oops" or two if one forgets to turn down the power when tuning and dumps full power into it.  It will, of course, not withstand 100 watts for very long - but you'll probably smell it before anything is too-badly damaged!

As on might posit from the description, the operation of this bridge is as follows:

  • Place this device between the radio and the external tuner.
  • Turn the power of the radio down to 10-15 watts and select FM mode.
  • Disable the radio's built-in tuner, if it has one.
  • If using a manual tuner, do an initial "rough" tuning to peak the receive noise, if possible.
  • Switch the unit to "Bridge" (e.g. "Measure") mode.
  • Key the transmitter.
  • If you are using an automatic tuner, start its auto-tune cycle.  There should be enough power coming through the bridge for it to operate (most will work reliably down to at about 5 watts - which means that you'll need the 10-15 watts from the radio for this.) 
  • If you are using a manual tuner, look at both its SWR meter (if it has one) and the LED brightness and adjust for minimum brightness/reflected power.  A perfect match will result in the LED being completely extinguished.
  • After tuning is complete, switch to "Bypass" mode.
 * * *
This page stolen from ka7oei.blogspot.com