Electronic Design

RISC Controller Backs Frequency Counter

Frequency measurement, often vital to design engineers, is the driving force behind this idea. Here, an AVR RISC controller-based circuit can measure the frequency of digital signals. It employs the PC as a user interface and sends the measurement results back to the PC through the serial port.

The user interface connects to the PC's serial port at a rate of 9.6 Mbits/s—8 data bits, 1 stop bit, and no parity (Fig. 1). The heart of the circuit, the AT90S2313 AVR RISC controller, operates at a 4.000-MHz crystal clock frequency. It counts the pulses on its PB2 input pin over the user-selectable counting period of 0.1, 1, or 10 seconds. At the end of the counting period, the accumulated count is sent to the PC in the form of four hexadecimal numbers (16 bits), followed by ASCII code for linefeed and carriage return. Until the user resets the system, the process continues.

At power on, the interface sends a message over the serial line, prompting the user to select a counting period via the keyboard (Fig. 2). Pressing 0, 1, or 2 selects a 0.1-, 1-, or 10-s counting period, respectively. If any other key is pressed, the 10-s counting period is selected by default. A terminal emulator program (VTERM under DOS prompt) is used to communicate with the interface. Similar Windows programs, such as HyperTerminal, are also effective. The data being sent by the interface can be piped to a text file for later analysis. For data plotting, Windows-based Microsoft Excel or Linux/Unix-based Gnuplot can be employed.

To download the listings, click Download the Code.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish