High Precision Frequency Counter using GPS (Part2)

Following from previous posting I have connected a STM32F429i-DISC1 board to us UBLOX NEO-6M GPS module (see https://www.ebay.co.uk/itm/313603433572) and programmed a 32 bit counter in capture compare mode running at 80MHz.

STD32f429i-Disc1 with NEO-6M GPS as timer
NEO-6M GPS with PPS triggering counter

After the GPS settled I recorded a number of counts varying by +-200 using the inbuilt 8MHz crystal.

This is far too much jitter, at present i t is uncertain if the reason is

  1. Crystal frequency variation due to quality of crystal
  2. Crystal frequency variation due to supply voltage
  3. STM32 PLL stability.

I will first attempt to attach a better crystal. The STM32F429 accepts an external input from 4MHz to 26MHz. From RS components I considered a 24Mhz TCXO https://uk.rs-online.com/web/p/tcxo-oscillators/2499379 but I only wanted one, so ended up buying o e of these from ebay https://www.iqdfrequencyproducts.com/products/pn/LFTCXO075797Reel.pdf.

I’ll update on stability when it arrives.

I will provide the eclipse project for the board firmware. It includes UI, GPS serial communications and timer programming. All running under FreeRTOS.

High Precision Frequency Counter using GPS

To recalibrate my ageing HP 3850A spectrum analyser I needed a 6 digit frequency counter. After looking at buying a used device I realised that the purchase and calibration would cost me £300 plus, and constant recalibration would be required.

I had a STM32F407 controller laying around, and a MBLOX GPS module, and wondered if the PPS (pulse per second) signal could be used to provide an accurate frequency reference and I could create a decent frequency counter based on this?

Using a 32 bit counter synchronised by the PPS GPS signal, we can get an accurately calibrated count. Using clever software we can use the initial count value, and could average readings to further improve accuracy.

From the MBLOX data sheet the PPS signal is accurate to 30nS, this is 0.06 parts per million (ppm) giving a good 7 digits accuracy.

The two measurement techniques are:

  1. Use a calibrated counter and trigger reading on rising/falling edge of incoming signal, for frequencies below a suitable break point (TBD).
  2. Count incoming pulses and use PPS to get count, the upper frequency is limited to the maximum counter speed.

Triggering on edge of incoming signal

Measuring a 20KHz signal using with a 80MHz counter clock would give a count of 4,000 initially, giving 3.5 digits accuracy, but averaging over 100 counts would give 4,000.00, 6 digits accuracy. This would only take a 1/200th of a second. Averaging over 1000 counts would happen in a 1/20th of a seconds giving 4000.000 6.5 digits accuracy.

40KHz would give a count of 2,000, but if counting for 1 second we got 40,000 in a second, which is far slower. The averaging technique can be used, resetting if there is a significant frequency change up to about 50 KHz.

Choice of board

STM32F407 on the STM disc-1 development board has a LCD display and USB, and two 32 bit counters. TIM 2 and TIM 5. These have a maximum clock of about 80MHz. The touch display would allow user input configuration to be trivial. I picked up my development board for £32 – bargain. All that would be required is a small case, input filtering and buffering of the measured source and attachment of the GPS receiver.

It may be necessary to use an external GPS antenna TBD. See part 2…

HiFi Amplifier Thermal Design Considerations

When designing ultimate high fidelity audio amplifiers thermal stability and cooling become a huge issue. Here I consider a design of a class AB amplifier with a MOSFET output driver stage.

The amplifier is designed to deliver approximately 100W undistorted, this will require a +-45V supply rail. To drive the MOSFET’s a higher supply voltage is required. In this design I have chosen 55V, the driver stage draws 19mA, equating to 2W of power per channel. In addition the output MOSFET’s will require a residual bias current of 60mA, consuming 5.4W. This amounts to 7.4 watts idle per channel, 15W in total at idle.

There is little we can do to reduce this, clever standby logic can reduce this by disabling the output driver when no signal is present, but when in use, and when under a 20W load for example 30W of heat will need to be dissipated.

Passive cooling is preferred over fan noise, an almost perfect high fidelity system be pointless if a fan is producing noise in the background. Passive cooling is vulnerable to poor airflow so thermal monitoring and shutdown is mandatory in such systems to ensure when, for example a record sleeve is placed over the amplifier it does not overheat.

The thermal stability of the output stage also needs careful design, in classical MOSFET output stages the idle bias current is chosen to be the point at which the device is thermally stable. An example of this are the Exicon ECX10N20 devices (see datasheet) where the Vgs temperature coefficient is zero at 110mA and increases beyond this point. Sadly 110mA is far too high, so additional temperature compensation is required to stabilize the devices at a lower idle bias point. The negative temperature coefficient at higher currents protects against short circuit and high temperature failure making these devices extremely rugged:-

Exicon Bilateral MOSFET Vgs vs Temperature
Exicon Bilateral MOSFET Vgs vs Temperature

Using such devices has yielded classical MOSFET amplifier designs which have passed the test of time. An Hitachi power MOSFET design was included in their design guides in 1985 which was the basis of the Maplin Electronics 75W amplifier:-

Hitachi 100W MOSFET Amplifier
Hitachi 100W MOSFET Amplifier

I built a pair of similar amplifiers which sounded great and were bomb proof, continuing to work for over 20 years.

A similar output stage, which turns a current source into a bias voltage that is thermally stable is shown below:-

Simple Current to Voltage Source Follower MOSFET output
Simple Current to Voltage Source Follower MOSFET output

Transistor Mounting

The heat-sink will have a cooling ability defined as a thermal resistance (^{\circ}C/W). This can only be achieved if the transistor junction is perfectly thermally coupled to the heat-sink.

Unfortunately there are other thermal resistances between the actual transistor junction and the heat-sink, which can be reduced to a transistor junction to case resistance and a case to heat-sink resistance:-

heatsink mounted transistor thermal model
Thermal Model of Heatsink mounted Transistor

The thermal capacitance C_j is small compared with C_{case}, but the value of R_{th} for the  junction to the case is fairly large. It is important to reduce the value of the thermal resistance between the case and heat-sink to maximise the heat-sink capacity.

The table below shows the typical thermal resistance of different materials:-

MaterialElectrical InsulationThermal Resistance Wm-1°C-1CostNotes
Mica4500 volts/mm0.528HighRequires silicon paste
Sil-Pads700 volts/mm1.0MediumEasy to use
Kapton0.9-1.5HighAges under high temperatures

Kapton is used in many designs, but suffers with lower thermal conductivity and stability over time. Using mica with thermal compound is expensive, difficulty and messy, but is the best solution. For ultimate high fidelity designs we will use mica washers and thermal compound.

Care must be taken not to contaminate any connections with silicon thermal compound as (i) it prevents reliable soldering and (ii) it eventually leads to connector failure if contaminating any connectors.

The final piece of the puzzle is the use of a Vbe multiplier to set the MOSFET bias point. This design has been used in most high fidelity amplifiers to provide some -Ve thermal compensation into the output stages and allow the bias voltage to be easily adjusted:-

Vbe Muliplier
Vbe Multiplier (Bias servo)

Often R1 or R2 is variable to adjust the bias point of the output FET’s and the transistor is bolted to the output heat sink close to the output devices. The Vbe offset voltage drops as temperature rises ensuring voltage Vce is inversely proportional to the temperature.

The use of a variable resistor for r1/r2 vastly affects reliability and can contribute towards distortion caused by non linear effects in carbon tracks. It is often better to use a select on test approach using fixed metal film resistors. This approach has been adopted in this design.

Finally, the choice of heat sink material is to be considered. It is clear that copper is a far better conductor of heat:-

Thermal Conductivity of Metals

MaterialThermal Conductivity Wm^{-1}K^{-1}Notes
Aluminium237Surface oxidation also increases contact resistance
Copper401Copper is rarely 100% pure - so often this figure is slightly smaller
Steel (carbon 1%)43
This table compares the thermal conductivity of common metals used in electronic equipment

From here copper seems ideal. In this design a large copper plate will conduct heat away to the chassis which will be covered in a large aluminium heat sink. Aluminium is far stronger and easier to machine into complex heat sink shapes.