The personal website of Scott W Harden
August 3rd, 2019

USB Frequency Counter

I built a frequency counter with a USB interface based around a 74LV8154 32-bit counter, FTDI FT230XS (USB serial adapter), and an ATMega328 microcontroller. I've used this same counter IC in some old projects (1, 2, 3, 4, 5) this time I decided to I design the circuit a little more carefully, make a PCB, and use all surface-mount technology (SMT).

The micro USB port provides power and PC connectivity, and when running the device sends frequency to the computer every second. All the parameters can be customized in software, and source code is on the USB-Counter GitHub page.

I also added support for a 7-segment LED display. The counter works fine without the screen attached, but using the screen lets this device serve as a frequency counter without requiring a computer. This display is a MAX7219-driven display module which currently runs for $2 each on Amazon when ordered in packs of 5.

Precision Frequency Measurement

One advantage of this counter is that it is never reset. Since this circuit uses 32-bit counter IC, and every gate cycle transmits the current count to the computer over USB. Because every input cycle is measured high precision measurements of frequency over long periods of time are possible. For example, 1000 repeated measurements with a 1Hz gate allows frequency measurement to a precision of 0.01 Hz.

Internal or External Gating

An optional external 1PPS gate can be used for precise timing. The microcontroller is capable of generating gate cycles in software. Precision is limited to that of the TCXO used to clock the microcontroller (2.5 PPM). For higher-precision gating a resistor may be lifted and an external gate applied (e.g., 1PPS GPS signal).

TCXO Driving a Gate in Software

By clocking the microcontroller at 14.7456 MHz with a temperature-compensated crystal oscillator (TCXO) I'm able to communicate with the PC easily at 115200 baud, and with some clever timer settings and interrupts I'm able to toggle an output pin every 14,745,600 cycles to produce a fairly accurate 1PPS signal.

Maximum Counting Frequency

According to the SN74LV8154 datasheet the minimum expected maximum input frequency (fMAX) is 40 MHz. To count higher frequencies, a high-speed prescaler could be added to the input to divide-down the input signal to a frequency this counter can range. This was [discussed]() in the original issue that kicked-off this project, and Onno Hoekstra (PA2OHH) recommended the SAB6456 divide-by-64/divide-by-256 prescaler which supports up to 1 GHz input frequency. However, present availability seems to be limited. A similar chip, or even a pair of octal flip-flops that work in the GHZ range could achieve this functionality.

Design

By populating one of two input paths with components this device can serve as a sensitive frequency counter (with a small-signal amplifier front-end) or a pulse counter (with a simple 50 ohm load at the front-end).

Optional RF Amplifier Front-End

An optional amplifier front-end has been added to turn weak input into strong square waves suitable for driving the TTL counter IC. It is designed for continuously running input, and will likely self-oscillate if it is not actively driven.

This simulation shows a small 1 MHz signal fed into a high impedance front-end being amplified to easily satisfy TTL levels. The 1k resistor (R3) could be swapped-out for a 50 Ohm resistor for a more traditional input impedance if desired. LTSpice source files are in the GitHub repository in case you want to refine the simulation.

Components

PCB

Changes from rev 1.0

  • improved RF amplifier design
  • alternate path to bypass RF amplifier
  • corrected counter pin connections
  • free a MCU pin by making the status LED the gate
  • add a header for the serial LED display
  • run MCU at 14.7456 MHz
    • allows much faster serial transmission
    • no longer accepts external 10MHz reference
    • may still accept external gate
  • added screw holes
    • they're floating (not grounded) - should they be grounded?
  • switched to micro USB (from mini USB)

Build Notes

  • didnt have 27 ohm resistors. used 22 ohm.
  • I used a 500mW rated R15
  • I used a 500mW rated R13
  • make hand solder version of usb
  • make oscillator fit less awkwardly
  • Add a 7805 so 12V can be applied or USB. Use a 78L33 (not the reg on the FTDI chip) to power everything else.
  • This device doesn't work when plugged into a wall USB cord (power only, no data). It seems an active USB connection is required to cause the 3.3V regulator (built into the FTDI chip) to deliver power. The next revision should use a discrete 3.3V regulator.
  • For a standalone (LED) device no USB connection is needed. Make a version that accepts 12V and displays the result on the LED. Make the optional external gate easy to access. Break-out the TX pin so PC logging is still very easy.

Resources

Markdown source code last modified on January 18th, 2021
---
title: USB Frequency Counter
date: 2019-08-03 21:15:00
tags: circuit
---

# USB Frequency Counter

**I built a frequency counter with a USB interface** based around a [74LV8154](https://www.ti.com/lit/ds/symlink/sn74lv8154.pdf) 32-bit counter, FTDI [FT230XS](https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT230X.pdf) (USB serial adapter), and an [ATMega328](https://www.microchip.com/wwwproducts/en/ATmega328) microcontroller. I've used this same counter IC in some old projects ([1](https://swharden.com/blog/2011-03-14-frequency-counter-finished/), [2](https://swharden.com/blog/2011-02-12-wideband-receiver-works/), [3](https://swharden.com/blog/2011-02-09-minimal-radio-project-continues/), [4](https://swharden.com/blog/2011-02-04-frequency-counter-working/), [5](https://swharden.com/blog/2011-01-28-home-brew-transceiver-taking-shape/)) this time I decided to I design the circuit a little more carefully, make a PCB, and use all surface-mount technology (SMT).

<div class="text-center img-medium">

[![](curved2_thumb.jpg)](curved2.jpg)

</div>

**The micro USB port provides power and PC connectivity,** and when running the device sends frequency to the computer every second. All the parameters can be customized in software, and source code is on the [USB-Counter GitHub page](https://github.com/swharden/USB-Counter). 

<div class="text-center">

[![](DSC_0132_thumb.jpg)](DSC_0132.jpg)

</div>

**I also added support for a 7-segment LED display.** The counter works fine without the screen attached, but using the screen lets this device serve as a frequency counter without requiring a computer. This display is a MAX7219-driven display module which currently runs for [$2 each on Amazon](https://www.amazon.com/s?k=max7219+segment) when ordered in packs of 5.

### Precision Frequency Measurement

**One advantage of this counter is that it is never reset.** Since this circuit uses 32-bit counter IC, and every gate cycle transmits the current count to the computer over USB. Because every input cycle is measured high precision measurements of frequency over long periods of time are possible. For example, 1000 repeated measurements with a 1Hz gate allows frequency measurement to a precision of 0.01 Hz.

<div class="text-center img-border img-medium">

[![](2019-08-04-output_thumb.jpg)](2019-08-04-output.png)

</div>

### Internal or External Gating

**An optional external 1PPS gate can be used for precise timing.** The microcontroller is capable of generating gate cycles in software. Precision is limited to that of the TCXO used to clock the microcontroller (2.5 PPM). For higher-precision gating a resistor may be lifted and an external gate applied (e.g., 1PPS GPS signal).

### TCXO Driving a Gate in Software

**By clocking the microcontroller at 14.7456 MHz with a temperature-compensated crystal oscillator (TCXO)** I'm able to communicate with the PC easily at [115200 baud](http://ruemohr.org/~ircjunk/avr/baudcalc/avrbaudcalc-1.0.8.php), and with some [clever timer settings](https://eleccelerator.com/avr-timer-calculator/) and interrupts I'm able to toggle an output pin every 14,745,600 cycles to produce a fairly accurate 1PPS signal.

### Maximum Counting Frequency

**According to the SN74LV8154 datasheet** the minimum expected maximum input frequency (f<sub>MAX</sub>) is 40 MHz. To count higher frequencies, a high-speed prescaler could be added to the input to divide-down the input signal to a frequency this counter can range. This was [discussed]() in the original issue that kicked-off this project, and [Onno Hoekstra (PA2OHH)](https://www.qsl.net/pa2ohh/) recommended the [SAB6456](https://doc.lagout.org/electronics/doc/ic_various/SAB6456.PDF) divide-by-64/divide-by-256 prescaler which supports up to 1 GHz input frequency. However, present availability seems to be limited. A similar chip, or even a pair of octal flip-flops that work in the GHZ range could achieve this functionality.

## Design

**By populating one of two input paths** with components this device can serve as a sensitive frequency counter (with a small-signal amplifier front-end) or a pulse counter (with a simple 50 ohm load at the front-end).

<div class="text-center">

[![](schematic_thumb.jpg)](schematic.png)

</div>

### Optional RF Amplifier Front-End

**An optional amplifier front-end** has been added to turn weak input into strong square waves suitable for driving the TTL counter IC. It is designed for continuously running input, and will likely self-oscillate if it is not actively driven.

<div class="text-center img-border">

![](front-end.jpg)

</div>

**This simulation** shows a small 1 MHz signal fed into a high impedance front-end being amplified to easily satisfy TTL levels. The 1k resistor (R3) could be swapped-out for a 50 Ohm resistor for a more traditional input impedance if desired. LTSpice source files are in the GitHub repository in case you want to refine the simulation.

<div class="text-center img-border">

![](front-end-wave.jpg)

</div>

### Components
* all passives are 0805 (~$1)
* [SBAV99WT1G SC-70 dual diode](https://www.mouser.com/ProductDetail/ON-Semiconductor/SBAV99WT1G?qs=%2Fha2pyFaduhs9dhfVWP8oT%252BsAj5t0ZSYddkb6PuTtd0%3D) 215 mA ($0.29)
* [14.7456MHz TCXO](https://www.mouser.com/ProductDetail/Fox/FOX924B-147456?qs=sGAEpiMZZMt8oz%2FHeiymADfzZKRiEXclvcmWd5jLzoM%3D) 2.5 PPM, 14.7456MHz ($2.36)
* [SN74LV8154](https://www.mouser.com/ProductDetail/Texas-Instruments/SN74LV8154PWR?qs=sGAEpiMZZMtdY2G%252BSI3N4aQvQNXOTGN6Ghdjz%252BkScFE%3D) ($0.99) TSSOP-20
* [FT230XS-R](https://www.mouser.com/ProductDetail/FTDI/FT230XS-R?qs=sGAEpiMZZMtv%252Bwxsgy%2FhiIaF6qCroMVR1i2pEQA5UpU%3D) ($2.04) SSOP-16
* [ATMega328](https://www.mouser.com/ProductDetail/Microchip-Technology-Atmel/ATMEGA328PB-AU?qs=sGAEpiMZZMvc81WFyF5EdrSRAEYMYvHlMc95YQj%2FArE%3D) ($1.38)
* [mini-USB jack](https://www.mouser.com/ProductDetail/CUI/UJ2-MBH-1-SMT-TR?qs=sGAEpiMZZMu3xu3GWjvQiLfiCTO8RP%252Bk%252BIiwpoT5qew%3D) ($0.49)
* [micro-USB jack](https://www.mouser.com/ProductDetail/Hirose-Connector/ZX62D-B-5PA830?qs=sGAEpiMZZMulM8LPOQ%252Byk6r3VmhUEyMLT8hu1C1GYL85FtczwhvFwQ%3D%3D) ($0.70)
* [SMA connector](https://www.mouser.com/ProductDetail/LPRS/SMA-CONNECTOR?qs=sGAEpiMZZMuLQf%252BEuFsOrkd7M7rmHNHidLMZ%2Ftb%252B0T1YCJLScw0qLA%3D%3D) ($1.08)
* [SPI-driven 8-digit 7-segment display module](https://www.amazon.com/dp/B07CL2YNJQ) ($13 for 4)


### PCB

<div class="text-center img-border">

[![](pcb-dsn_thumb.jpg)](pcb-dsn.png)

</div>

<div class="text-center">

[![](pcb-rndr_thumb.jpg)](pcb-rndr.png)

</div>

<div class="text-center img-border">

[![](DSC_0128_thumb.jpg)](DSC_0128.jpg)

</div>

### Changes from rev 1.0
* improved RF amplifier design
* alternate path to bypass RF amplifier
* corrected counter pin connections
* free a MCU pin by making the status LED the gate
* add a header for the serial LED display
* run MCU at 14.7456 MHz
  * allows much faster serial transmission
  * no longer accepts external 10MHz reference
  * may still accept external gate
* added screw holes
  * they're floating (not grounded) - should they be grounded?
* switched to micro USB (from mini USB)

### Build Notes
* didnt have 27 ohm resistors. used 22 ohm.
* I used a 500mW rated R15
* I used a 500mW rated R13
* make hand solder version of usb
* make oscillator fit less awkwardly
* Add a 7805 so 12V can be applied or USB. Use a 78L33 (not the reg on the FTDI chip) to power everything else.
* This device doesn't work when plugged into a wall USB cord (power only, no data). It seems an active USB connection is required to cause the 3.3V regulator (built into the FTDI chip) to deliver power. The next revision should use a discrete 3.3V regulator.
* For a standalone (LED) device no USB connection is needed. Make a version that accepts 12V and displays the result on the LED. Make the optional external gate easy to access. Break-out the TX pin so PC logging is still very easy.

## Resources
* [USB-Counter](https://github.com/swharden/USB-Counter) on GitHub
* [Revision 1.0 build notes](https://github.com/swharden/USB-Counter/tree/master/builds/1.0)
* [Revision 1.1 build notes](https://github.com/swharden/USB-Counter/tree/master/builds/1.1)
* [GitHub issue](https://github.com/swharden/AVR-projects/issues/1) where this topic was first discussed
July 31st, 2019

Upgraded Amplifier

The design is similar (CMOS buffer driving an IRF510) but I used perfboard to make this one and placed it in an enclosure. There's no low-pass filter on the amplifier itself, but I put a 30m low-pass filter in-line the coax before the antenna. It's currently outputting 20PPV into 50 ohms (1 watt).

Old Amplifier

New Amplifier

Right after hooking it up I saw my signal looking nice on the air:

AJ4VD Spotted in Ontario, Canada (VA3ROM)

AJ4VD Spotted in the Canary Islands (EA8BVP1)

Markdown source code last modified on January 18th, 2021
---
title: Upgraded Amplifier
date: 2019-07-31 21:00:00
tags: qrss, circuit
---

# Upgraded Amplifier

The design is similar (CMOS buffer driving an IRF510) but I used perfboard to make this one and placed it in an enclosure. There's no low-pass filter on the amplifier itself, but I put a 30m low-pass filter in-line the coax before the antenna. It's currently outputting 20PPV into 50 ohms (1 watt).

### Old Amplifier

<div class="text-center img-border">

[![](2019-07-30-old-amp_thumb.jpg)](2019-07-30-old-amp.jpg)

</div>

### New Amplifier

<div class="text-center">

[![](schematic_thumb.jpg)](schematic.png)

</div>

<div class="text-center img-border">

[![](2019-07-31-new-amp_thumb.jpg)](2019-07-31-new-amp.jpg)

</div>

Right after hooking it up I saw my signal looking nice on the air:

### AJ4VD Spotted in Ontario, Canada (VA3ROM)

<div class="text-center img-border">

[![](VA3ROM.1907311950.549006f9e5_thumb.jpg)](VA3ROM.1907311950.549006f9e5.jpg)

</div>

### AJ4VD Spotted in the Canary Islands (EA8BVP1)

<div class="text-center img-border">

[![](EA8BVP1.1907311940.821b800321_thumb.jpg)](EA8BVP1.1907311940.821b800321.jpg)

</div>
July 29th, 2019

SMT QRSS Spots

This page documents interesting grabs of the signal from my SMT QRSS Transmitter

2019-07-29

Nova Scotia, Canada (VE1VDM)

I was really strong on VE1VDM's grabber last night, but I found it interesting to see such a strong signal in the middle of the day (11AM).

Stack (average of 13 grabs)

2019-07-30

I spotted my signal across the Atlantic. It's pretty weak, but you can just make out the unique shape on EA8BVP's grabber in the Canary Islands (4,000 miles away).

2019-08-03

I spotted my signal in Sweden. This hint of my transmitter was captured by SA6BSS in Slutarp, Sweden at 12:30AM last night.

2019-09-02

I spotted my signal in Switzerland

Bill (W4HBK) emailed the QRSS Knights a grab of my signal from a KIWI SDR captured at HB9EHO in Ittigen, Switzerland.

Markdown source code last modified on January 18th, 2021
---
title: SMT QRSS Spots
date: 2019-07-29 21:00:00
tags: qrss
---

# SMT QRSS Spots

This page documents interesting grabs of the signal from my [SMT QRSS Transmitter](https://swharden.com/blog/2019-07-26-smt-qrss-design/)

## 2019-07-29

### Nova Scotia, Canada (VE1VDM)

I was really strong on VE1VDM's grabber last night, but I found it interesting to see such a strong signal in the middle of the day (11AM).

<div class="text-center img-border">

[![](VE1VDM.1907290830.35415d51dc_thumb.jpg)](VE1VDM.1907290830.35415d51dc.jpg)

</div>

### Stack (average of 13 grabs)

<div class="text-center img-border">

[![](VE1VDM.1907290940_thumb.jpg)](VE1VDM.1907290940.jpg)

</div>

## 2019-07-30

I spotted my signal across the Atlantic. It's pretty weak, but you can just make out the unique shape on EA8BVP's grabber in the Canary Islands (4,000 miles away).

<div class="text-center img-border">

[![](EA8BVP1.1907302050_thumb.jpg)](EA8BVP1.1907302050.jpg)

</div>

## 2019-08-03

I spotted my signal in Sweden. This hint of my transmitter was captured by SA6BSS in Slutarp, Sweden at 12:30AM last night.

<div class="text-center img-border">

[![](SA6BSS-AJ4VD_thumb.jpg)](SA6BSS-AJ4VD.jpg)

</div>

<div class="text-center img-border img-medium">

[![](globe_thumb.jpg)](globe.png)

</div>

## 2019-09-02

I spotted my signal in Switzerland

[Bill (W4HBK)](https://www.qsl.net/w4hbk/) emailed the [QRSS Knights](https://groups.io/g/qrssknights) a grab of my signal from a KIWI SDR captured at HB9EHO in Ittigen, Switzerland.

<div class="text-center img-border">

[![](HB9EHO_thumb.jpg)](HB9EHO.jpg)

</div>
July 26th, 2019

SMT QRSS Design

This page documents development of a voltage-controlled oscillator suitable for QRSS. Source code and PCB files are on https://github.com/swharden/QRSS-hardware

For QRSS it's convenient to have 2 frequency shift adjustments: a coarse one to set frequency (~200 Hz), and a fine one for FSK (5 Hz). I began with the design below allowing manual adjustment of coarse tuning, then an external input for fine tuning. Eventually I switched to a design where a single voltage controls tuning (coarse and fine). Many QRSS TX designs use a variable capacitor to set the coarse adjustment, but I don't like that design because it means you have to open your enclosure every time you want to shift frequency. If this is going to be ovenized, I'd love to close the box and do all the tuning electronically.

This design worked pretty well. Fixed capacitors (optionally populated) set the frequency so the crystal oscillates in the QRSS band. The coarse adjustment moves the signal around the QRSS band (100Hz). The fine adjustment is pulled high through a divider. Adjust R4 to control how wide the FSK can be.

Real varicap diodes definitely work better than reverse-biased LEDs. A reverse-biasd blue LED measured 60 Hz swing (with a lot of additional fixed capacitance in place to get near center frequency). Replacing this with a BB132 (I had to remove a 5pF cap to compensate) I got a swing of 159 Hz. That's more than double, and that's just one varicap. You can stack them in parallel. Real varicaps dont mind low voltage* I found out, so don't worry about avoiding that super low region like with the LED.

Eventually I stopped trying to separate fine and coarse frequency adjustments and just went with a single voltage for tuning. I can control voltage coarsely and finely using potentiometers, so I was happy to simplify the oscillator design by moving that complexity to the keyer/control system. This is the QRSS oscillator I came up with. It's just a Colpitts oscillator with an output buffer. Note that the buffer will self-oscillate if the oscillator stops, so on-off-keying should be achieved downstream of this circuit. These decisions are made with maximal frequency stability in mind.

I'm glad I used a SMA connector, but in hindsight I should have laid it out sideways because I couldn't close the lid.

Build Notes

  • I used BB132 for the varicap
  • I used 33P for C6
  • For C9 I used 33p (should be NP0)
  • For C11 I used 100p
  • For C10 and C12 I used NP0 120p caps

Ovenization

Ovenization is achieved using two power-resistors fixed to the metal enclosure. A thermistor fastened to the chassis provides temperature feedback. This chassis heater seems to be a winning design, as it is slow but stable. Having loose coupling between the PCB and the chassis is intentional. The whole thing is enclosed in a modestly insulative plastic enclosure. I'm very happy with this design!

Ovenization

QRSS Oscillators Need Ovens

My oscillator looks stable on time scales of minutes, but on time scales of hours it is obvious that it wobbles as my central air conditioning turns on and off. I could go nuts with Styrofoam, but a crystal oven (or chassis heater) is warranted.

Why I want a chassis heater (not a oven heater)

Some DIY QRSS ovens use resistors as the heater element and package the heater and temperature sensor against the crystal. While temperature stability of the crystal is good, I prefer to thermo-stabilize all frequency-determining components (capacitors and varactors) of the oscillator circuit. For this reason, I prefer a chassis heater.

Eventually I want a SMT PCB heater

When I get an oscillator I like using SMT parts, I'll try adding the temperature sensor and heater directly on the board. This is ideal for small PCBs. It would be cool if the board could thermo-regulate itself, then the oscillator would just need insulation, and the heater would require very low power.

Chassis Heater Design

This section documents my thoughts and experiments related to development of a chassis heater. Since I'll build the chassis heater inside an insulated container, I'll refer to it as a chassis oven.

Design

After running the numbers for a bunch of different power/resistor combinations, I decided to work with 50-Ohm power resistors. I'd love to have more 50-Ohm power resistors on hand to use for making dummy loads.

I settled on this part: 50 Ohm (+/- 1%) 12.5 watt resistor ($2.64)

Running 12V through a single resistor would burn 2.88W of power as heat. If we wanted more heat we could add additional resistors in parallel, but this should be okay.

Circuit

After the above considerations, this is what I came up with. I made it on a breadboard and it works well.

  • You can add multiple R4s in parallel for faster heating
  • I ended-up replacing the TIP122 (Darlington transistor) with an IRF510 (N-channel MOSEFET) for better linear operation (since the TIP122 has such high gain)
    • This works great and the IRF510 rests partially on once stabalized
    • The IRF510 gets hot! Maybe you can mount that to the chassis too?
  • You can supply it with dirty power and it doesn't seem to affect oscillator performance
  • I use a multi-turn potentiometer for RV1
  • R6 sets hysteresis
    • Large values promote squishy temperature control.
    • Small values will faster responses but may oscillate
    • Remove R6 for bang-bang operation
  • I suspect this design could be used as a crystal oven
    • Replace Q1 with a 2N2222
    • Replace R4 with a 680 Ohm 1/4-watt resistor (~17 mA, ~200 mW)

Photos

More Notes

I experimented more on 2019-08-31:

  • Switched to an LM335 (not a thermistor) super-glued to the chassis
  • I target 3.10 mV (310 Kelvin = 37C or 100F)
  • Can use LM7805 for op-amp and divider since we are using low voltages
  • A tip122 is cheaper than the IRF510 and works fine

Calculating power dissipation of a transistor heating a resistor

Consider a NPN with a collector tied to VCC (Vcc) and emitter dumping into a resistor (R) to ground. Let's say I'm driving a 50 Ohm resistor as a heater. How hot will the transistor get? Is my transistor beefy enough? To answer this I need to determine the peak power dissipation through a transistor into a resistive load.

We should assume the current flowing through the resistor (I) will be the same as the current flowing through the transistor.

// Ve is a function of R and I
Ve = R * I

// transistor voltage drop
Vce = Vcc - Ve

// power through the transistor
Pnpn = I * Vce

// substitute 
Pnpn = I * Vce
Pnpn = I * (Vcc - Ve)
Pnpn = I * (Vcc - (R * I))
Pnpn = (I * Vcc) - (I^2 * R)

// at peak power the first derivative of current is zero
Pnpn = (I * Vcc) - (I^2 * R)
d(Pnpn) = Vcc - (2 * I * R) = 0

// find the current through the resistor (= transistor) at peak power
Vcc - (2 * I * R) = 0
2 * I * R = VCC
Ipeak = VCC / (2 * R)

// substitute back into original equation
Pnpn = (Ipeak * Vcc) - (Ipeak^2 * R)
Pnpn = ((Vcc / (2 * R)) * Vcc) - ((Vcc / (2 * R))^2 * R)
Pnpn = (Vcc^2) / (2 * R) - (Vcc^2 * R) / (4 * R^2)
4 * R * Pnpn = 2 * Vcc^2 - Vcc^2
Pnpn = Vcc ^ 2 / (4 * R)
Pnpn = Vcc * Vcc / (4 * R)
Pnpn = Vcc * (I * R) / (4 * R)
Pnpn = Vcc * I / 4

// since the power through the resistor is
Pr = Vcc * I

// peak power through the NPN is 1/4 that through the resistor
Pnpn = Vcc * I / 4
  • If I drop 12V through a 330 Ohm resistor it passes 36.4 mA of current and dissipates 436.4 mW of power. This means the transistor will dissipate 109 mW of power at its max.
Markdown source code last modified on January 18th, 2021
---
title: SMT QRSS Design
date: 2019-07-26 21:00:00
tags: qrss, circuit
---

# SMT QRSS Design

This page documents development of a voltage-controlled oscillator suitable for QRSS. Source code and PCB files are on https://github.com/swharden/QRSS-hardware

**For QRSS it's convenient to have 2 frequency shift adjustments: a coarse one to set frequency (~200 Hz), and a fine one for FSK (5 Hz).** I began with the design below allowing manual adjustment of coarse tuning, then an external input for fine tuning. Eventually I switched to a design where a single voltage controls tuning (coarse and fine). Many QRSS TX designs use a variable capacitor to set the coarse adjustment, but I don't like that design because it means you have to open your enclosure every time you want to shift frequency. If this is going to be ovenized, I'd love to close the box and do all the tuning electronically.

<div class="text-center">

[![](varactor-tuning-aj4vd-v1_thumb.jpg)](varactor-tuning-aj4vd-v1.png)

</div>

**This design worked pretty well.** Fixed capacitors (optionally populated) set the frequency so the crystal oscillates in the QRSS band. The coarse adjustment moves the signal around the QRSS band (100Hz). The fine adjustment is pulled high through a divider. Adjust R4 to control how wide the FSK can be.

**Real varicap diodes definitely work better than reverse-biased LEDs.** A reverse-biasd blue LED measured 60 Hz swing (with a lot of additional fixed capacitance in place to get near center frequency). Replacing this with a BB132 (I had to remove a 5pF cap to compensate) I got a swing of 159 Hz. That's more than double, and that's just one varicap. You can stack them in parallel. Real varicaps dont mind low voltage* I found out, so don't worry about avoiding that super low region like with the LED.

**Eventually I stopped trying to separate fine and coarse frequency adjustments** and just went with a single voltage for tuning. I can control voltage coarsely and finely using potentiometers, so I was happy to simplify the oscillator design by moving that complexity to the keyer/control system. This is the QRSS oscillator I came up with. It's just a [Colpitts oscillator](https://en.wikipedia.org/wiki/Colpitts_oscillator) with an output buffer. Note that the buffer will self-oscillate if the oscillator stops, so on-off-keying should be achieved downstream of this circuit. These decisions are made with maximal frequency stability in mind.

<div class="text-center">

[![](qrss-oscillator_thumb.jpg)](qrss-oscillator.png)

</div>

<div class="text-center img-border">

[![](pcb-design_thumb.jpg)](pcb-design.png)

</div>

<div class="text-center">

[![](pcb-3d_thumb.jpg)](pcb-3d.png)

</div>

I'm glad I used a SMA connector, but in hindsight I should have laid it out sideways because I couldn't close the lid.

## Build Notes
* I used BB132 for the varicap
* I used 33P for C6
* For C9 I used 33p (should be NP0)
* For C11 I used 100p
* For C10 and C12 I used NP0 120p caps

<div class="text-center img-border">

[![](2019-07-26-a_thumb.jpg)](2019-07-26-a.jpg)
[![](2019-07-26-b_thumb.jpg)](2019-07-26-b.jpg)
[![](2019-07-26-c_thumb.jpg)](2019-07-26-c.jpg)

</div>

## Ovenization

**Ovenization is achieved using two power-resistors fixed to the metal enclosure.** A thermistor fastened to the chassis provides temperature feedback. This _chassis heater_ seems to be a winning design, as it is slow but stable. Having loose coupling between the PCB and the chassis is intentional. The whole thing is enclosed in a modestly insulative plastic enclosure. I'm very happy with this design!

## Ovenization

### QRSS Oscillators Need Ovens
My oscillator looks stable on time scales of minutes, but on time scales of hours it is obvious that it wobbles as my central air conditioning turns on and off. I could go nuts with Styrofoam, but a crystal oven (or chassis heater) is warranted.

### Why I want a chassis heater (not a oven heater)
Some DIY QRSS ovens use resistors as the heater element and package the heater and temperature sensor against the crystal. While temperature stability of the crystal is good, I prefer to thermo-stabilize all frequency-determining components (capacitors and varactors) of the oscillator circuit. For this reason, I prefer a chassis heater.

### Eventually I want a SMT PCB heater
When I get an oscillator I like using SMT parts, I'll try adding the temperature sensor and heater directly on the board. This is ideal for small PCBs. It would be cool if the board could thermo-regulate itself, then the oscillator would just need insulation, and the heater would require very low power.

### Chassis Heater Design

This section documents my thoughts and experiments related to development of a chassis heater. Since I'll build the chassis heater inside an insulated container, I'll refer to it as a chassis oven.

### Design

After running the numbers for a bunch of different power/resistor combinations, I decided to work with 50-Ohm power resistors. I'd love to have more 50-Ohm power resistors on hand to use for making dummy loads.

I settled on this part: [50 Ohm (+/- 1%) 12.5 watt resistor](https://www.mouser.com/ProductDetail/Vishay-Dale/RH01050R00FE02?qs=sGAEpiMZZMtbXrIkmrvidDNaDpN5VXc5nhpgDg1t8QQ%3D) ($2.64)

Running 12V through a single resistor would burn 2.88W of power as heat. If we wanted more heat we could add additional resistors in parallel, but this should be okay.

### Circuit
After the above considerations, this is what I came up with. I made it on a breadboard and it works well.

<div class="text-center">

[![](oven-aj4vd-resistor-heater_thumb.jpg)](oven-aj4vd-resistor-heater.png)

</div>

* You can add multiple R4s in parallel for faster heating
* I ended-up replacing the TIP122 (Darlington transistor) with an IRF510 (N-channel MOSEFET) for better linear operation (since the TIP122 has such high gain)
  * This works great and the IRF510 rests partially on once stabalized
  * The IRF510 gets hot! Maybe you can mount that to the chassis too?
* You can supply it with dirty power and it doesn't seem to affect oscillator performance
* I use a multi-turn potentiometer for RV1
* R6 sets hysteresis
  * Large values promote squishy temperature control. 
  * Small values will faster responses but may oscillate
  * Remove R6 for bang-bang operation
* I suspect this design could be used as a _crystal_ oven
  * Replace Q1 with a 2N2222
  * Replace R4 with a 680 Ohm 1/4-watt resistor (~17 mA, ~200 mW)
  
### Photos

<div class="text-center img-border">

[![](2019-07-26-d_thumb.jpg)](2019-07-26-d.jpg)
[![](2019-07-26-e_thumb.jpg)](2019-07-26-e.jpg)

</div>

### More Notes
I experimented more on 2019-08-31:

* Switched to an LM335 (not a thermistor) super-glued to the chassis
* I target 3.10 mV (310 Kelvin = 37C or 100F)
* Can use LM7805 for op-amp and divider since we are using low voltages
* A tip122 is cheaper than the IRF510 and works fine


### Calculating power dissipation of a transistor heating a resistor

Consider a NPN with a collector tied to VCC (`Vcc`) and emitter dumping into a resistor (`R`) to ground. Let's say I'm driving a 50 Ohm resistor as a heater. How hot will the transistor get? Is my transistor beefy enough? To answer this I need to ***determine the peak power dissipation through a transistor into a resistive load.***

We should assume the current flowing through the resistor (`I`) will be the same as the current flowing through the transistor.

```c
// Ve is a function of R and I
Ve = R * I

// transistor voltage drop
Vce = Vcc - Ve

// power through the transistor
Pnpn = I * Vce

// substitute 
Pnpn = I * Vce
Pnpn = I * (Vcc - Ve)
Pnpn = I * (Vcc - (R * I))
Pnpn = (I * Vcc) - (I^2 * R)

// at peak power the first derivative of current is zero
Pnpn = (I * Vcc) - (I^2 * R)
d(Pnpn) = Vcc - (2 * I * R) = 0

// find the current through the resistor (= transistor) at peak power
Vcc - (2 * I * R) = 0
2 * I * R = VCC
Ipeak = VCC / (2 * R)

// substitute back into original equation
Pnpn = (Ipeak * Vcc) - (Ipeak^2 * R)
Pnpn = ((Vcc / (2 * R)) * Vcc) - ((Vcc / (2 * R))^2 * R)
Pnpn = (Vcc^2) / (2 * R) - (Vcc^2 * R) / (4 * R^2)
4 * R * Pnpn = 2 * Vcc^2 - Vcc^2
Pnpn = Vcc ^ 2 / (4 * R)
Pnpn = Vcc * Vcc / (4 * R)
Pnpn = Vcc * (I * R) / (4 * R)
Pnpn = Vcc * I / 4

// since the power through the resistor is
Pr = Vcc * I

// peak power through the NPN is 1/4 that through the resistor
Pnpn = Vcc * I / 4
```

* If I drop 12V through a 330 Ohm resistor it passes 36.4 mA of current and dissipates 436.4 mW of power. This means the transistor will dissipate 109 mW of power at its max. 
  * A 2n7000 can handle this.
  * A [0.5W 0805 300 Ohm resistor](https://www.mouser.com/ProductDetail/Panasonic/ERJ-P06J331V?qs=sGAEpiMZZMu61qfTUdNhG4N%252BbAgO2H57MCL338q%2F2SU%3D) can handle this (Mouser # 667-ERJ-P06J331V)
July 21st, 2019

New QRSS Keyer

I'd like to use an interesting pattern that takes advantage of both FSK and OOK. I want it to be 5 Hz or less in bandwidth, and I want it to be unique and recognizable in cases where only a few seconds are spotted, but I don't want it to be so odd that it's annoying. I came up with something like:

Here's what it looks like on the air:

Microcontroller

ATTiny2313 programmed with C (source code)

GPS serial data parsing

To ensure the message transmits exactly at the 0:00 mark of every 10 minutes, the microcontroller is occasionally put into a "wait" mode where it continuously watches the GPS output (parsing the serial data that bursts out every second) and waits for the minutes digit to become zero before beginning a transmission.

Technical details: The output is 9600 baud serial data in NMEA format. A string buffer is filled as incoming characters are received. If the message starts with $GPRMC we know the 11th character is the ones digit of the minutes number in the time code. Waiting for the next ten minute rollover to occur is as easy as waiting until that character becomes zero.

$GPRMC,184130.00,...
^    ^     ^

The start of a time message looks like this. To identify $GPRMC we just need to match the $ and the C (indicated by the first two arrows above). We then know if we keep reading, we will arrive at the ones digit of the minutes number (the third arrow).

I have some notes on the Neo-6M here

FSK Circuit

I found this design very convenient. A potentiometer (RV1) sets center frequency to let me adjust where in the QRSS band I want to transmit.

The FSK input (which could be digital or analog) is 0-5V, expected to originate from a microcontroller pin. The keyer is programmed to transmits over the full 0-5V range.

The second potentiometer (RV2) sets the width of the FSK input. I adjust this to achieve a bandwidth of about 5 Hz.

The output is buffered, mixed, and sent to the oscillator module with coax.

Markdown source code last modified on January 18th, 2021
---
title: New QRSS Keyer
date: 2019-07-21 21:00:00
tags: qrss, circuit
---

# New QRSS Keyer

**I'd like to use an interesting pattern** that takes advantage of both FSK and OOK. I want it to be 5 Hz or less in bandwidth, and I want it to be unique and recognizable in cases where only a few seconds are spotted, but I don't want it to be so odd that it's annoying. I came up with something like:

<div class="text-center">

[![](pattern_thumb.jpg)](pattern.jpg)

</div>

Here's what it looks like on the air:

<div class="text-center img-border">

[![](WD4ELG-30.1907210830.d1c3ee1f06_thumb.jpg)](WD4ELG-30.1907210830.d1c3ee1f06.jpg)

</div>

### Microcontroller
ATTiny2313 programmed with C ([source code](https://github.com/swharden/QRSS-hardware/tree/master/builds/keyer/main.c))

### GPS serial data parsing
To ensure the message transmits exactly at the 0:00 mark of every 10 minutes, the microcontroller is occasionally put into a "wait" mode where it continuously watches the GPS output (parsing the serial data that bursts out every second) and waits for the minutes digit to become zero before beginning a transmission.

Technical details: The output is 9600 baud serial data in [NMEA format](https://www.gpsinformation.org/dale/nmea.htm). A string buffer is filled as incoming characters are received. If the message starts with `$GPRMC` we know the 11th character is the ones digit of the minutes number in the time code. Waiting for the next ten minute rollover to occur is as easy as waiting until that character becomes zero.

```
$GPRMC,184130.00,...
^    ^     ^
```

The start of a time message looks like this. To identify `$GPRMC` we just need to match the `$` and the `C` (indicated by the first two arrows above). We then know if we keep reading, we will arrive at the ones digit of the minutes number (the third arrow).

I have some notes on the [Neo-6M here](https://github.com/swharden/AVR-projects/tree/master/uBlox%20Neo-6M)

### FSK Circuit

I found this design very convenient. A potentiometer (RV1) sets center frequency to let me adjust where in the QRSS band I want to transmit. 

The FSK input (which could be digital or analog) is 0-5V, expected to originate from a microcontroller pin. The keyer is programmed to transmits over the full 0-5V range.

The second potentiometer (RV2) sets the width of the FSK input. I adjust this to achieve a bandwidth of about 5 Hz.

The output is buffered, mixed, and sent to the oscillator module with coax.

<div class="text-center">

[![](fsk-circuit_thumb.jpg)](fsk-circuit.jpg)

</div>

<div class="text-center img-border">

[![](2019-07-19-keyer_thumb.jpg)](2019-07-19-keyer.jpg)
[![](2019-07-19-modules_thumb.jpg)](2019-07-19-modules.jpg)
[![](2019-07-31_thumb.jpg)](2019-07-31.jpg)

</div>
Pages