Group Members: Emy Egbogah, Mel Lumague, David Ng, Nitin Parimi, Ben
Talbot
Additional Features
This student application note allows future EE552 students to implement a 12 hour clock.
The 12 hour clock was originally created by the "Smart Alarm Clock" project.
We have added some new features to make the clock more versatile:
1.
Precise Timing with the Addition of a seconds counter.
The 12 hour clock runs on a 2Hz clock, so the system clock must be divided in order to achieve the needed slow clock of 2 Hz.
To add seconds to the hour clock, two extra 4 bit signals and a seconds counter variable were added. The two signals, num1_secs and num2_secs, represent the first and second digits of a second, respectively (ie 12:00:XX).
The seconds counter is used to time the increment of the seconds. The counter is incremented on each slow clock until it reaches a value of 2 ( 2 samples/sec * 1 sec = 2 samples). When the counter is equal to 2, it is reset to zero and the seconds are incremented in the same manner as the minutes in the hour clock.
*Note:
Based on project clock requirements, some parameters used to design the
hour clock may be different. The "Smart Alarm Clock" project recommended
using a counter value of 120 (2 samples/sec * 60 sec = 120 samples) to increment
the minutes. For some reason, using that counter value provided us with a
large skew between the 24 clock time and real time (3 : 2 ratio). We found
that using a value of 60 provided the most accurate results (1: 1 ratio).
2.
Setting the Time
We used one dip switch and two pushbuttons to set the time. The set_clock signal was assigned to the dipswitch and used to enable time setting. When the set_clock signal is asserted, the clock is stopped and the user is able to set the minutes and hours of the clock using the two pushbuttons. In order to use the pushbuttons effectively, they must be debounced. The link for the debouncer is given in the `files' section.
3. Further Modifications
The setting of the AM/PM indicator was corrected from
the "Smart Alarm Clock" project. In the case that the time changes to 12:00,
the AM/PM is set
appropriately.
How to instantiate the 12 hour clock:
slow_clkdiv : component clkdiv
generic map (Divisor => clock_divider)
--number used to divide clock down to 2 Hz
port map(
fast_clock => clock,
reset => inv_reset,
slow_clock => slow_clock
);
timedisplay : time_display
GENERIC MAP (
clk_per_sec => clk_per_sec
)
PORT MAP (
clock
=> clock, --fast clock
slow_clock
=> slow_clock, --2Hz clock
reset
=> inv_reset,
am_pm_in
=> am_pm_in,
am_pm_out
=> am_pm_out,
set_clock
=> set_clock, --set clock toggle
button1
=> button1, --increment minutes
button2
=> button2, --increment hours
num1_bcd_out => num1,
num2_bcd_out => num2,
num3_bcd_out => num3,
num4_bcd_out => num4,
num1_secs
=> num1secs,
num2_secs
=> num2secs
);
The Time Format
num4_bcd_out num3_bcd_out : num2_bcd_out num1_bcd_out : num2_secs num1_secs AM/PM