The instant that the line voltage crosses the zero axis
in a positive direction, the signal at B1 goes from 1 to 0.
When the oscillator reaches the decision point for B1, it
will select ‘yes’ for B1=0 and proceed downward in the
flow chart.
In the next step (Flag=0?), the answer will again be yes
because the flag had been reset while B1 was high.
In the next steps, the flag will be set and the X register
loaded with 0 (which is the start of the sine wave table in
memory). This effectively restarts the oscillator at the top
of memory and at zero degrees of angle.
The oscillator will proceed to load that memory value
to the D/A converter, and then return to the top of the
flow chart to increment X and again go through the
synchronizer.
At that time, B1 will still be zero, so the process will
proceed downward through the flow chart. Now when it
reaches the decision point “Flag=0?,” the answer will be
‘no,’ the flow chart will bypass reloading the X register,
and no further action will be taken. This shows how the X
register is reloaded only once on the falling edge of B1
(equivalent to the positive slope zero crossing of the AC
waveform). When the AC line eventually goes negative, B1
will return to 1 and the flag will be reset, thereby
preparing for another cycle.
To summarize, the synchronizer reloads the X register
with its zero phase setting on every falling edge of the
square wave at B1, thereby forcing the waveform to restart
in synchronism with the line.
Adjusting the Phase of the
Synchronized Signal
Any phase relationship between the oscillator and line
can be created by loading a memory location between 0
and 255 when the line crosses zero. The number selects
at which point in memory and thereby what phase of the
oscillator sinusoid shall coincide with the zero crossing of
the line voltage. The photo in Figure 2 shows a small
phase difference between the line and the oscillator. This
can be corrected by loading a number other than 0 at the
falling edge of B1. Loading 10 instead of 0 corrects the
phase discrepancy. The signals are now synchronized
exactly in phase and with no visible distortion as shown in
Figure 8.
Hardware and Test Setup
Figure 9 shows the complete oscillator board. The
microcontroller (MC9S08SE4) is the 28-pin DIP IC on
the right side of the board. Further to the right is the
six-pin optocoupler (4N35). I like using DIP packages
wherever possible because they’re accessible to
humans. The lead spacing is 0.1 inch which is fine for
hand soldering.
SMD packages start at 0.050 and go down to
0.01 lead spacing which is impossible to solder by
hand. If there’s any doubt about an IC, the DIP
sockets allow quick and easy replacement without
damage to the board.
The TO-220 packages on the left side of the board
are voltage regulators. On a new board, I first remove
all ICs and check the ±5V supplies. This assures that
the ICs will get correct power and I don’t wind up
with a board full of dead chips due to power supply
problems.
The six-pin programming header is located slightly
44 April 2017
FIGURE 8. Signals are synchronized and in
phase. Line (yellow) is at 59.79 Hz. Oscillator
is at 60.007 Hz. Synchronizer uses 10 instead
of 0 as the restarting memory location.
FIGURE 9. The ‘9S08-50/60/400’
oscillator board.