Project Overview

The HP Z3816A provides high accuracy frequency and time outputs that can be used for a variety of purposes. By disciplining the internal oscillator with a satellite receiver, the Z3816A provides 10MHz,19.6608 MHz and 1 PPS outputs (synchronized by GPS to UTC) via connections on the rear panel (For more information on the HP Z3816 and the similar HP Z3801A see Bill Jones' website (www.realhamradio.com).

In order to obtain the time or modify parameters, a connection is required to a PC or external terminal device via an RS232 serial interface. PC programs (see HP Sat Stat, gps.exe) are available that handle the communications with the Z3816A and provide an easy to use interactive display on a standard windows PC. However, this requires a dedicated PC connected to the Z3816A if continuous time output is desired.

In the article below, I describe a project I recently completed that replaces the PC with a small, inexpensive, easy to assemble and use, microprocessor based unit that provides a continuously updated time display and allows the user to enter HP Z3816A or Z3801A commands directly via a extendable simple user interface.

The Z3816A Auxiliary Display Unit (ADU) is built around a Parallax BS2 sx Stamp microprocessor (www.parallaxinc.com), a Scott Edwards (www.seetron.com) two-line by sixteen character display, a Maxim 233A RS232 interface IC (www.maxim-ic.com) and other miscellaneous hardware. A Stamp BASIC application provides the software interface between the ADU and the Z3816A. The project is described below:

Hardware Overview:

I chose the Parallax BS2 sx microprocessor from Parallax since it is easy to program, is reasonably inexpensive, and I used it for other similar projects in the past. The project will function equally well with the standard BS2 microprocessor, with no logic or programming changes (the timing constants used for output to the Z3816A and LCD display must be modified, however these values are included in the program). All components are standard off-the-shelf electronics, and the total for the project is between $75 and $100 depending on the microprocessor and LCD characteristics. The entire project is housed in a plastic case slightly smaller than the Z3816A.

Circuit Design

The BS2 sx is powered from a standard +5 volt 1 amp voltage regulator, which is connected to an external 9-volt wall-wart DC transformer. Using an external +5 volt regulator bypasses the low current on-board voltage regulator supplied with the BS2 sx and provides additional current for future expansion.

Because the BS2 sx serial input and output ports operate at TTL levels, and the HP Z3816A operates at true RS232 voltages, an external interface is required for voltage translation between the two devices. For this interface I used the Maxim 233A which handles two TTL and two RS232 devices, and requires no external components to operate. The Maxim 233A accepts TTL inputs on the transmit line from the BS2 sx and converts these TTL signals to RS232 levels for the Z3816A. It also receives RS232 levels from the Z3816A and converts them to TTL levels for the BS2 sx.

For this application, the BS2 sx transmits on output port 2 (pin 7) using the Z3816A communication default parameters (9600 baud, no parity, 8 bit data, 1 stop bit) and receives on input port 3. The BS2 sx and Z3816A is connected to channel 2 of the Maxim 233A (channel 1 is unused). The BS2 sx Port 2 is connected to T2IN (pin 1) on the MAX233A. This channel corresponds to Pin 18 (T2OUT) on the MAX233A. Pin 18 on the MAX233A connects to the receive pin 2 on the Z3816A (9 pin RS232 D-Shell Connector). The response from the Z3816A is sent on pin 3 of the RS232 connector, which connects to pin 19 (R2IN) that corresponds to pin 20 (R2OUT) on the MAX233A. Pin 20 from the MAX233A is then connected to Input Port 3 (pin 8) on the BS2 sx. Note that for the MAX233A to operate properly the following pins must be connected: pin 12 to pin 17; pin 11 to pin15; and pin 10 to pin 16. Specifications for the MAX233A can be found at: http://pdfserv.maxim-ic.com/arpdf/MAX220-MAX249.pdf

In addition to connectivity to the HP Z3816A, the BS2 sx is also connected to two momentary contact switches, an LCD two line by 16-character display panel and a LED, which flashes once per second.

The LED panel is used to display the local or UTC time, and the time zone offset from UTC. The LED display panel used is the Scott Edwards Electronics BPI-216 Supertwist 2x16 LCD with Backpack-Protocol Serial Interface. The Backpack-Protocol Serial Interface allows a three-wire (+5v, serial data, and ground) connection between the BS2 sx and the display. Specifications for the display can be found at: http://www.seetron.com/pdf/bpi_bpk.pdf. Output to the display is via serial output port zero on the BS2 sx (pin 5). Output to the display is via serial output port zero on the BS2 sx (pin 5).

There are two momentary push buttons connected to the BS2 sx on input ports 5 and 6 (pins 10 and 11). These are active high switches connected from +5v through 10k ohm resistors to ground. During program execution, the BS2 sx reads the and branches to a program location based on the state of the switch (press on not-pressed) at the time the button instruction executes. Button-One, connected to input port 6 (Stamp pin 11) is used to change states from the "Display Time State" to "Command Input State" and back. Button-Two, connected to BS2 sx input port 5 (Stamp pin 10) is used to scroll through the various time zones (from 0 to 23).

The final hardware component is a single red LED located on the front panel. This LED flashes once per second, and is synchronized to the beginning of each second. Since the LED is under program control, the flash is delayed by the execution time of the program, which checks for the second change in software before turning on the LED. The LED is connected to output port 4 (Stamp pin 9) and is on for 100 milliseconds each second. The LED connects to ground through a 470-ohm resistor.

Software

The BS2 sx software application provides two main functions. First it provides the logic to request the time from the Z3816A, parse the output from the Z3816A and display the the time on the LED display panel. Second, it provides an input capability for sending commands to the Z3816A to change its operating characteristics. The program operates in three distinct states: Initialization, Time Display, and Command Input.

During the Initialization State, the ADU initializes all variables and waits one second for the LCD to stabilize. The program then sends the following command to the HP Z3816A: ":ptim:tcod:cont 0". This command changes the state of the Z3816A from constant time sending to a send/receive protocol. Sending the command ":ptim:tcod:cont 1" returns the 3816A to continuous time transmit mode (this function has not implemented by this application). The return code or time-out notice is displayed following the transmission of this command. Once the return code has been displayed, the application transitions to the Display Time State.

In the Display Time State, the application operates in a loop performing the following functions: First, the program transmits the time request to the Z3816A: ":ptim:TIME?" The program then captures the response (up to 11 bytes) from the 3816A. All commands sent to the Z3816A are terminated with a carriage return, and all messages transmitted from the Z3816A terminate with a carriage return. The Z3816A transmits time in the following format: leading zeros are truncated; hours, minutes and seconds all begin with a plus sign followed by either one or two digits of time. A comma separates hours and minutes, and seconds are terminated with a carriage return. For example, 03:12:02 is sent as: +3,+12,+2CR, and midnight (00:00:00) is send as: +0,+0,+0CR (where CR is a carriage return).

Following the time request (:ptim:TIME?), a serial input command is issued to receive the time from the Z3816A. The input is read into a twelve-byte character string. The time character string is parsed and converted to binary hours, minutes and seconds for display and further processing. Once converted, the time is displayed on line one of the LCD display panel using the serial output command from output port 0 (pin 5). Unless the user presses Button-One, the program will remain in the Time Display State indefinitely.

In the Display Time State, the application constantly reads the time from the Z3816A and displays it on the LCD panel. In addition, the application flashes an LED once each second. This is accomplished by comparing the seconds variable on each iteration of the main processing loop to the seconds value on the previous iteration of the loop. If the seconds variable has changed, the LED is turned on for 100 milliseconds.

Changing the application from the Display Time State to the Command Input state is accomplished by pressing Button-One. Pressing Button-One again changes the application back to the Display Time State. The application accomplishes this state change by monitoring the state of Button-One in the main processing loop using the Stamp "Button" instruction. The Button command senses the switch closure and transfers program control to the Command Input logic.

Whenever the application senses Button-One has been pressed, the application suspends the time display and transitions to the Command Input State by displaying the Time Zone Input Screen. The screen allows the user to enter a time zone number between 0 and 23 with zero corresponding to UTC. By pressing Button-Two, the time zone increments one unit each time the button is pressed. When the time zone reaches 24 it is reset to zero and processing continues. When the user has selected the appropriate time zone (indicated on line 2 of the display), pressing Button-One will convert the input to a plus or negative number (first 12 time zones moving west from Greenwich are converted to negative, 13 through 23 remain positive after subtracting 12. For example, EST is UTC -5 and EDT is UTC -4. They are entered into the application as 5 and 4 respectively.

The input buttons can be programmed to transmit any command to the Z3816A. Currently, only the "Change Time Zone" command has been enabled. Once the time zone has been captured, the program returns to the Display Time State. In addition to the time display, Line 2 now displays the time zone offset from UTC. This is only displayed if the time zone was changed by the program.