Introduction: Basys 3 Alarm Clock
Our project creates an alarm clock using the Basys 3 FPGA board, an Arduino, and a speaker driver board. The user is able to input the current time to the board using 11 input switches on the Basys 3 and lock in the value using the middle button on the board. The user can then enter the alarm time using the same switches but press the left button to lock in the alarm time. If the wrong time is entered, the reset button (top button) can be pressed and the current clock time and alarm time will be set to 00:00. The user can then start the clock using the leftmost switch and turn on the alarm using the next switch. When the alarm is turned on, the alarm clock will make a sound when the clock time and set alarm time match.
Step 1: Black Box Diagram
We began our project by drawing a black box diagram to visualize the inputs and outputs needed in our program. The following inputs for our program such as 5-bit input (Hour_in) were initialized to specify the 24-hour time, 6-bit (Min_in) input to display up to 60 minutes, a reset (Rst_b) button to allow the user to change their time input, a 1-bit input (alm_en) which loads the alarm input, a 1-bit input (alarm_sw) to turn off alarm clock when it is activated, a 1-bit input (e_sec) that controls when the counter of seconds will run, a 1-bit input (Led_btn) that sets the current time, and lastly a 1-bit input (clk) that controls the time displayed by the Basys 3 board. The outputs are the (alm_on) which sends the signal to the Arduino, the sseg output that displays the input time on the Basys 3, and the anode output that controls where inputs are displayed on the seven segments display.
Step 2: Slow Clock
The slow clock or clock_div2 file creates a clock whose frequency is 2 hz. If we feed this clock to our seconds counter, the seconds value will increase by one every second. The slow clock is used to create a reliable clock signal that changes from low to high once per second.
Step 3: Counter
Component Counter ( minutes and seconds):
The basic function of minutes and seconds is that they are counters. The minutes counter takes in input (Vin) which is signal from inputs (Min_in), and then counts until reaches the desired input inputted. The seconds only takes in input of switch(e_Sec) since it can't be displayed on the seven segment, and counts in the background once the switch is high '1'. They both output there value to (Qout) , and then it is stored in (data) that sends it to SSEG which is done in the linking file. Also, when minutes and seconds reach the values of 59 it resets, and the output of them is ‘1’ in order to increment minutes/hour. It also can mapped with a reset(rst_b) to their inputs.
Step 4: Counter Hour
Component Counter Hour
Similarly,to the component counter of the minutes and seconds the hour component takes in input s such as (Vin) which is a signal from linking file input (Hour_in), and has outputs that are linked in same manner the minutes and seconds. When the count value of hour reaches 24 00 it resets to 00 00.
Step 5: Alarm
The alarm .vhd file is made up of d-flip-flops which are storage devices that can store digital data. The alarm file is used to store the time at which the alarm will be activated. To store the data of hours (5 bit input) and minutes (6 bit input) we must stamp out 11 d-flip-flops within our alarm file. To do this, we must first import the logic governing the operation of d-flip-flops and map the components. Each of the 11 d-flip-flops will store one bit of data from the inputs and allow the data to be mapped to the outputs of the alarm file. Because d-flip-flops store data, we are able to use the data at a later point in time even if the input switches have been changed.
Step 6: Universal Seven Segment Display Driver
The universal seven segment display driver receives the inputs from the clock and clock set and is able to output them to the seven segment display on the board. The driver is able to output two separate counts on the board at one time. We used this function to display both the hour time and the minute time separately. The seven segment display is only able to activate one number at a time therefor the sseg file must use multiplexing to display all numbers of the time simultaneously. The boards clock signal is fed into the sseg to keep the correct time for multiplexing. A binary to binary coded decimal encoder is necessary to convert the inputs to the file to a form that can be output to the seven segment display. The final output of the sseg file is mapped to the seven segment display and the correct time is shown on the display.
Step 7: Link File
The link file connects all other aspects of the program and maps the signals to their correct location. Each component is brought in and instantiated within the file. Signals are used to transfer data from one component to the other. The port mapping will follow the black box diagram listed above. The link file also holds the logic that governs when the alarm is activated. Most of the project will already be finished by this point. The remaining work is routing each signal to the appropriate location.
Step 8: Arduino
The arduino is used to activate the speaker as well as control the tone and duration of the note played through the speaker. The arduino reads a digital signal from the Basys 3 board. When this signal is high, the arduino will output a PWM signal controlling the tone and duration of the alarm. The output signal from the arduino connects to the input signal of a speaker driver board which increases the volume of the speaker. The arduino does this process very fast repeating many times per second.
Step 9: Cable Routing
The arduino and Basys 3 board must be physically connected to transfer signals between the boards. The first cable to wire will be the from the ground pin of the JA PMOD of the Basys 3 to the ground pin of the arduino. Next connect a wire from pin 1 of the JA PMOD of the Basys 3 to digital pin 7 of the arduino. Next, connect two ground pins from the arduino to the ground pins of the speaker driver. Next, connect the 3.3 V output of the arduino to the Vcc pin of the speaker driver. Next, connect digital pin 9 of the arduino to the In pin of the speaker driver.