U 0712076
U 0712076
U 0712076
projects
BEGIN
Connection Point
C:
Input DCF
A4 ->
DCFin
Decision
If
DCFin =
1
?
Yes
No
Wait for start pulse
again, until Pulse
Delay
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
A:
Input DCF
A4 ->
DCFin
Decision
No
Wait for pulse end.
Pulse has ended.
Calculation
second = sec...
END
76
Research it first!
Connection Point
If
DCFin =
0
?
Yes
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
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.
ST 23:22:12 Thu ^
26 Apr 2007 .DCF
Flowcode did it
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
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.
Reference
[1] PICee Development System,
Elektor Electronics February 2002.
elektor - 12/2007