Sunteți pe pagina 1din 3

e-blocks

projects

E-blocks DCF Clock


Ported onto Elektor PICee and
supporting three time zones
Albert van Bemmelen

BEGIN
Connection Point
C:
Input DCF
A4 ->
DCFin
Decision
If
DCFin =
1
?
Yes

No
Wait for start pulse
again, until Pulse

Delay

Jump to Connection Point

150 ms

Input DCF
A4 ->
DCFin
If still Pulse then logic 1.
200 ms = "1", 100 ms =...
Decision
If
DCFin =
1
?
Yes

No
Calculation Signbit

Calculation Signbit

Signbit = 0

Signbit = 1
Output Sync LED on
1
-> A2

Output Sync LED off


0
-> A2

A:
Input DCF
A4 ->
DCFin
Decision

No
Wait for pulse end.
Pulse has ended.

Calculation
second = sec...

END

Figure 1. Macro 2 plays a major role in the software.

76

Having successfully completed a number of lesser projects using


Flowcode, I decided to try a much more ambitious project: a DCF
Atomic Clock Time and Date information Display, which also involved
reading and processing pulses in a very exact manner.
Although several assembler programs seem to exist, none of my
Flowcode-generated PIC examples ever worked on my own PIC
based boards. Even the Elektor PICee board [1] with the Conrad
Electronics DCF module never worked as a DCF clock. The same
DCF module is now used with this project.
I also wondered if Flowcode 3.0 could help me again in this attempt
to make this PIC software myself. As it turned out, the simulator
helped by producing and debugging a perfectly working DCF atomic
clock receiver program in no time (pun intended). A fully functioning
Flowcode program is described (and supplied as a free download)
as convincing proof of my attempts.

Research it first!

Connection Point

If
DCFin =
0
?
Yes

Heres how the author used Flowcode to develop PIC


software for a DCF-controlled clock suitable for the CET,
CET1 and CET+1 time zones. Dispelling the myth that
Flowcode has no use outside the E-blocks environment,
the end result was cheerfully ported to the famous
Elektor 2002 PICee development board.

Jump to Connection Point


A

The first thing I did before making my first Flowcode program was
examining the PIC input port schematic, because that is the only
way the signals of the outside world get inside the micro. When
used as an input port, all ports RA0 through RA4 (plus RA5 when a
PIC16F88 is used) and RB0 through RB7 are normally pulled down
to ground (logic0) by a 4k7 resistor. When a switch on a port line is
pressed, it will connect through via a 390- resistor to the positive
(+5V) supply voltage. This then represents a logic1. The only thing
we need to know in addition is what signal we are going to connect
to the selected port true or inverted logic. Also, when using the
inputs as digital entry points we need a transistor to act as a switch
driven by the logic1 or logic0 signal applied to its base. Here, that
signal comes from the DCF clock module. Alternatively you can press
a switch yourself at the right moment and keep it depressed for the
right amount of time (as in the Flowcode PC DCF simulator).
Level conversion may be required in front of the PIC inputs, and of
course we need to make sure that the frequency of the timecode sig-

elektor - 12/2007

nal can be detected by the ports used.


On the PIC16F88 device, the RA port
lines can also be used as analogue inputs using an internal analogue/digital converter. Assuming a swing of 5V
the resolution is 5/1024 (210) or about
4.9mV.
Flowcode has an essential advantage in allowing software to be easily
ported to another PIC type or another clock frequency afterwards. Here,
a PIC type 16F88 was first used with
the Multiprogrammer board running at
19.6608MHz, but the PIC device and
clock frequency can easily be changed
to suit your requirements. The lowest crystal frequency tested with this
project is 6.144MHz.

How it works
To be able to follow the discussion below, you should have the Flowcode
program found in download # 07509411.zip on your screen or on paper.
After receiving a no-pulse interval of
about 1000ms (2050ms), during
the 60th second of every received DCF
minute the LCD will synchronise with
the correct time, day, month, year readout. The value displayed on the right of
the display gives the currently received
bit value of the DCF information during
every second. ( for a 0; ^ for a 1).
Every minute, the Flowcode-programmed PIC receives 59 of these
bits (the 60th second is represented
by a pause) representing BCD coded
values.
In order to keep the Flowcode software
simple and easy to debug, and also to
keep the main program uncluttered, at
least three separate program parts are
used. Macro1, called DCF_Synchronize,
takes care of the synchronisation in the
60th second. A second Macro called
Getbit receives a new bit value every
second and converts any 100-ms pulse
length into a logic 0, and any 200-ms
pulse length into a logic 1. Macro2,
shown in Figure1, also waits until the
pulses are ended before the program
continues with, for instance increasing
the Seconds counter, or adjusting its
value when value 61 is reached. And
last but not least, the DCF_Array[] will
also be filled here with the measured bit
value of that last second. After exactly
59 received seconds, the time/date is
distilled from the discrete bit values in
order to put the correct information on
the clock readout.
It will be obvious that its essential for
this second macro to function flawlessly, since even if Synchro starts prop-

12/2007 - elektor

erly, Getbit still tests for a correct 100ms or 200-ms pulse every second. Every wrong bit will automatically mean
incorrect displayed data, especially
when seconds run out of sync. Using the software approach described,
only AM disturbance at the 77.5-kHz
receiving frequency can cause real
problems.
A third macro fills the LCD in such a
way that all data from the 59-second
time telegram is displayed correctly.
In the Main program, finally, youll find
the BCD conversion math algorithms
that convert every bit value correctly
for every item and calculate it to the
associated decimal values.
In the first Flowcode version I wrote,
a parity check was missing no real
disaster because it was immediately
obvious when any received data was
wrong. Moreover, after synchronizing
again to DCF it was usually okay the
next minute (-la-minute!). A simple
even-parity bit check is implemented
in the latest version of the software.

Figure 2. Clock, date and DCF reception readout


(on PICee board).

come on with active-High DCF signal.


Similarly, an A2 port LED will light up
when Signbit is logic High.
Take care! Neither ports A7 nor A1
seemed to function well as a DCF sync
error LED indicator output. Port A4
nevertheless functions splendidly for
this function, in real life and in PC simulation mode. The A4 LED automatically goes out after about 60seconds
when the DCF time signal is successfully captured.
The readout on the 162 LC display
looks as follows (Figure2):

Three time zones

ST 23:22:12 Thu ^
26 Apr 2007 .DCF

I had no trouble making a working


Flowcode DCF CET clock. But adding
CET-1 and CET+1 modes was a whole
different matter. This is because the
German DCF 77.5kHz transmission
only contains CET (= GMT + 1 hour)
information while it can be picked up
(though not constantly) as far as the
Polish-Russian border and the Irish
West coast. A discussion of the software adaptations necessary to allow for three time zones is found in
the supplementary document available free of charge from the Elektor
website.

On the readout, WT is shown for


winter time; .DCF when synchronized, ERR if there is poor or no DCF
reception.
The day of the week, Sun, Mon, Tue
Sat is in BCD code values 7, 1, 26.
In case of parity (receiving-) errors the
next lines will be displayed:
Hour WRONG or Minute WRONG on
line 1; D/M/Y WRONG + ERR on line
2 (or a combination of these).

The setup for E-blocks

Flowcode did it

When using the E-blocks Multiprogrammer board, A0 will be the DCF


signal input port. An A0 port LED will

This project like no other revealed the


power of Flowcode Professional the
only problem as I see it could be with

PIC_9/
B3

PIC_8/
B2

N.C.

N.C.

N.C.

N.C.

LCD/
RS

LCD/
EN

LCD/
D3

LCD/
D2

LCD/
D0

LCD/
D1

PIC_2/
RA3

PIC_1/
RA2

PIC_9/
B3

PIC_8/
B2

PIC_6/
D0

PIC_7/
D1

E-Blocks mode

PICee mode

075094 - 12

Figure 3. To make the Elektor February 2002 PICee Development Board E-blocks compatible, datalines D0-D3 to the LCD have to be
broken. This is effectively done by setting the centre and right-hand jumper blocks to the up position. The low position allows you
to revert to the original PICee mode.

77

projects

e-blocks

pulses that are too fast to be detected


by the input ports of a PIC programmed
using Flowcode!

Over to the PICee board


hardware matters
The later version is an adaptation for
the Elektor PICee board. Here, port
RA4 will be the DCF input after a small
hardware modification of the PICee
LCD. Port A5 is now assigned to the
DCF Error LED, and port A2 still can
be used as the Signbit value indicator.
The PICee setup has been successfully
tested at a frequency of 6.144MHz.
The PICee board be modified to accept
the Flowcode-programmed PIC processor. Why, how? Normally, programmed
PICs are not exchangeable between
the E-blocks Multiprogrammer and
the Elektor PICee dev board, although
theyre both quite ordinary PIC programmers! The crux: The PICee board
sends out its LCD data 8-bits wide. By
contrast, the E-blocks Multiprogrammer board employs 4-bits wide LCD
communications.
Now Flowcode 3.0 is unable to address
its LCD using Port-A and Port-B bits simultaneously it employs PortB exclusively. The PICee board uses both
port A and port B to address the LCD.
The two systems can be married
by placing three double-pole toggle
switches arranged as 6 jumpers above
and under the PICee LCD. The drawing in Figure3 illustrates the method.
Also disconnect the LCD printed copper connections in accordance with the
drawing. It may be very handy when
all new jumpers are fitted in parallel
with the LCD (from East to West) so
they will be easily recognised as they
differ from the direction of original
jumpers (North to South).
Theres plenty of space on the PICee
board, see Figure4. Fourteen lightduty wires are installed in such a way
that the jumpers for the E-blocks compatible position all point in the same
direction (to the left, assuming the LCD
on the PICee board is at the bottom of
the card pointing downwards; with the
component-side showing). The standard PICee position is: to the right. Note
that not all pins are wire-connected
pins but theyre still needed as jumper
holders and serve logistic simplicity.
Disconnect the following copper connections to the PIC socket of the PICee
board:

78

Figure 4. This area between the LCD and the LED array at the edge of the 2002 PICee board is suitable for installing the additional
jumper blocks to select between E-blocks and PICee mode.

Pins 1 (Pic_RA2) and 2 (Pic_RA3)


Pins 8 (Pic_RB2) and 9 (Pic_RB3). The
four broken connections are now the
P(ole)-contact wires of the first two
23 changeover jumpers.

Flowcode adaptations for PICee


In Flowcode, if a PIC program using a
clock frequency of 19.66MHz is converted to, for instance, about 4MHz
without changing the Delay blocks,
then Flowcode will very likely propose
a change. Without this change in the
timing of the Delay blocks, the DCF
clock wont work as expected! The
DCF Flowcode clock works perfectly
with any clock between 19.6608MHz
and 6.144MHz, but not without changes at around 4MHz.
The Flowcode software adjustments relate to the LCD configuration window:
all PortB settings must be changed as
follows
Data1
Data2
Data3
Data4
RS
Enable

Port B must change to bit 4;


Port B must change to bit 5;
Port B must change to bit 6;
Port B must change to bit 7;
Port B must change to bit 3;
Port B must change to bit 2.

have to rearrange all LCD data lines on


the PICee board to adapt to Flowcode
and the E-Blocks Multi-programmer
settings. Using the jumper blocks you
can switch back and forth between EBlocks and PICee mode with the
power supply switched off, right?

Conclusion and freebies!


Thanks are due to Matrix Multimedia
for their fabulous Flowcode Professional version 3.0 software. It is one of
the fastest, reliable, and not to forget
highly user-friendly (PIC) microprocessor simulators that helps any enthusiast to create and realise things that
he/she never imagined possible (and
all in a very short time)!
The Flowcode program for the clock
project may be downloaded as file #
075094-11.zip from the Elektor website. A free, supplementary archive file
# 075094-21.zip contains a Word document in which the author presents the
software revision history, the way he
implemented three time zones and the
design of a DCF Generator, not forgetting photographs and screendumps.
Well worth having a look at.
(075094-I)

These changes do not affect Flowcode


in any way because we just use as
many Port bit connections as we did
before. These small changes have an
important advantage in that we do not

Reference
[1] PICee Development System,
Elektor Electronics February 2002.

elektor - 12/2007

S-ar putea să vă placă și