circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

June 2005, Issue 179

Precision Frequency Meter
Cypress PSoC High Integration Challenge 2004 Contest Winner


HARDWARE ESSENTIALS

My frequency meter’s circuitry is simple (see Figures 1 and 2, page 22). All the fun stuff is inside the Cypress CY8C27443 microcontroller, which contains configurable digital and analog blocks as well as a CPU. It’s all designed with a development environment that enables you to select block functions, route connections between the blocks, and write the firmware in C language.

(Click here to enlarge)

Figure 1—The system is simple. All the complexity is in the PSoC configuration and software.

 

(Click here to enlarge)

Figure 2—The CY8C27443-based system includes interfaces, an LCD, three buttons (sharing the LCD display signals), and an RS-232 converter.

Figure 3 shows what’s inside the CY8C27443 PSoC. All of its available resources are in play. In fact, the two modes of operation are necessary because there are insufficient resources in the CY8C27443 to concurrently monitor the radio broadcast for the time pips and measure the frequency. (Doing so would probably push the limits of the processor’s resources.)

(Click here to enlarge)

Figure 3—Logic blocks count and capture clocks, measure the temperature sensor signals, and provide a debug port. An analog block amplifies the radio audio. The comparators digitize the signal in both Time and Frequency modes.

Switching between the operating modes requires a few changes in the hardware’s configuration. However, reloading a complete configuration is undesirable because it would require you to reset the reference clock counter (the counter to count clocks from hour to hour). Instead, only a few key routes must be changed in the hardware. The actual nature of each block remains the same.

A 12-V plug pack supplies the frequency meter’s power (see Figure 4). The pack drives an 8-V regulator, which in turn drives a 5-V regulator to power the CY8C27443 and LCD. The 5-V regulator drives a 3-V regulator to power the temperature sensors and radio. The 3-V regulator drives the 2.8-V regulator in the crystal oven to power the reference oscillator.

(Click here to enlarge)

Figure 4—The power supply and crystal oven are extremely important. The entire reference oscillator environment (including power supply and output buffer) is temperature-controlled.

 

I included the 8- to 5-V step because a 5-V reference oscillator was originally supposed to be used. The oscillator needed its own regulator mounted in the oven in order to generate a constant voltage. I knew too much voltage drop across the regulator would generate too much heat, and that would affect the oven’s performance. So, I used 8 V for a 3-V regulator drop. I subsequently found a better oscillator, so the 8-V supply turned out to be unnecessary. I didn’t need to remove it though.

The temperature sensors require 1.8 to 3.6 V, so I included a 3-V regulator, which also matches the radio voltage because the radio normally takes two 1.5-V cells. The 3-V supply to the internal oven sensor also powers the reference oscillator. A 2.8-V low dropout (LDO) regulator provides a constant voltage to the oscillator.

I connected a standard 2 × 16 LCD module to port 2 on the CY8C27443. The meter’s buttons require only one dedicated input because they otherwise share the LCD outputs. All of the LCD lines except LCD_E are wired to the buttons header. When LCD_E is held low, the LCD isn’t affected. Each button is wired from the button input via a diode to the LCD line. As a result, if you press a button when the LCD line is low, it will pull the button input (which is normally pulled up) low. I could have used up to six buttons, but I needed only three. The software sets the LCD lines high and then pulls each one low. It then examines the button input to see if the button is active.

I implemented a serial transmit-only port to assist with software debugging and to enable event logging. A MAX232 converter, which converts the TTL serial output from the CY8C27443 to RS-232 levels, is wired to a DE9 connector for a direct connection to a PC serial port. The port transmits at 38,400 bps.

A highly accurate 16.3676-MHz, temperature-compensated Rakon IT5305BE oscillator serves as the reference clock. It supplies the system clock (sysclk) to the CY8C27443. An internal circuit measures the device’s temperature and appropriately pulls the oscillator’s frequency. The selected device was good, with a specified stability of ±0.5 ppm, but I wanted better. So, I mounted the oscillator in a crystal oven along with a 2.8-V voltage regulator (also at a constant temperature to ensure that temperature changes don’t affect the supply voltage) and an output buffer (to ensure that oscillator output loading doesn’t affect stability). The oscillator is also mounted on a temperature sensor. This enables the temperature to be monitored for the purposes of logging.

The output of the oscillator is a 1.5-V near sine wave. The output buffer is a 74HC14 gate. The oscillator output voltage levels aren’t suitable for this gate, so the output is AC-coupled through a capacitor and then biased to 1.3 V. The entire assembly is mounted on standoffs on the crystal oven’s lid (see Photo 2).

(Click here to enlarge)

Photo 2—The oscillator circuitry is fairly simple. The green PCB is the temperature sensor. I mounted the oscillator vertically on the left-hand side. The IC in the rear is the 74HC14 buffer.

The crystal oven provides a constant temperature environment for the oscillator. It consists of a small die-cast box surrounded by insulation. Attached to the case are a temperature sensor and resistors (heaters). The latter are powered directly from the 12-V supply (no regulator). The resistor values were chosen for a slow heat up. This provides enough heat and also helps minimize overshoot for a simple control system. It also ensures that the system won’t melt down if the software crashes with the heater on!

To control the oven, the CPU simply reads the case’s temperature and turns on the heaters when it’s below the desired temperature (45°C). Because of the lag in heat response, there’s some ripple in the case temperature (approximately ±0.3°C). However, the internal temperature measured at the oscillator doesn’t exhibit this ripple. This is the result of the slow thermal response between the case and oscillator PCB, which is mounted in the center of the case and not closely thermally tied to it.

Temperature measurement involves Maxim MAX6677 devices, which output the temperature as a PWM signal with the duty cycle proportional to the temperature. Thus, the accuracy of temperature measurement isn’t dependent on other references such as the voltage. The sensor supply voltage has an effect, but it’s insignificant when you’re using a standard regulator over normal temperature ranges. The actual temperature isn’t important. What matters is that the crystal oscillator remains at a constant temperature.

Digital PSoC blocks measure the sensor output duty cycle. An 8-bit PWM block provides a gating signal. The block is clocked by the sensor signal (about 2 kHz) and set up to give a low signal for 100 sensor output cycles. The low PWM output is gated with the sensor input and the inverted sensor input to produce two Enable signals, one for the high counter and another for the low counter. These 8-bit counters count the number of VC2 clocks (set to system clock divided by four). The counter overflow ISRs extend the counter’s ranges to 24 bits.

The PWM compare ISR is processed at the end of the 100 sensor cycles. This records the outputs from the two counters (TempHigh and TempLow) and resets the counters for the next cycle. Note that using the PWM block’s low output enables the PWM compare interrupt to activate just after the gating cycle. Using the high output and terminal count interrupt doesn’t work because the interrupt occurs before the high output has finished. The software uses the TempHigh and TempLow values to calculate the sensors’ temperatures. To select between the two available sensors, the input multiplex register is controlled directly. Only the oven case temperature controls the oven. The sensor temperature is measured only to be displayed and indicate that the oscillator is at temperature.