Introduction: FPGA LED FSM
Overview:
Design Engineers: Ryan Ortiz, Chris Harlow, Dalton Wunderlich, and Ramon Crespo
This project was completed as part of a CPE 133 class as a final project.
This FPGA is wired up to both an infrared motion sensor as well as an LED.
The way this project works is when the motion sensor detects motion (can adjust sensitivity) it sends out a high to the Basys- 3 board. When the board receives the high signal, an external LED turns on and a counter based upon a slowed down clock is activated within the board and continues until the motion sensor stops sending a high signal, i.e. no more motion is detected. Once no more motion is detected, the BCD display runs through the calculations necessary to calculate the power used by the led during the time it was on. The BCD then displays that value on the display and holds until a manual reset is hit. The LED uses about 6 milliwatts per second so that is the multiplier used with the number received from the counter to extract the amount of power used during a single demo. Limitations of this device is that the board cannot count above 15 seconds due to it being a 4 bit counter. It can only count and multiply 4 bit numbers.
Step 1: Hardware
The hardware needed for this project include the following
- Digilent Basys 3 Board
- Transistor
- wires
- LED
- Bread Board
- Bread board jumper wire
Step 2: Programming
We wrote the code in VHDL through the software Vivado. If you are interested in this software, feel free to click the link below to learn more.
Step 3: Black Box
Here is our black box diagram which should be useful in seeing how the overall circuit works. As you can see there is a lot of moving parts it's important to get a good idea of the circuit design. What is called the fan in the black box diagram is actually the LED.
Attachments
Step 4: Additional Purchases
The motion sensors that we used for this project can be found here.
http://www.amazon.com/Qunqi-HC-SR501-Pyroelectric-...
Additionally you will need to solder wires from the breadboard to the motion sensor if you need a soldering kit we recommend this one.
http://www.amazon.com/Neiko%C2%AE-40494A-Soldering...
A good wiring kit can be found here.
Step 5: Download the File
Above is the code for all the different modules for this project download the file and copy/paste to your Vivado design suite. All the different modules should be located under sources. The XDC file that you will need to declare the port map is included
Step 6: XDC Master File
This file will be necessary in enabling the correct components of the board. By creating the Port map, the Basys-3 board will be able to work properly.
Step 7: Description of Each Module
The code isn't too complicated basically we have a lot of modules all utilized in one parent file.
Fan Project
- all of the modules brought together
FSM Machine
- Controls the state it is in
- 2 states, led on, led off
D Flip Flop (dff)
- basic D Flip Flop design see link for more info
http://www.ee.surrey.ac.uk/Projects/Labview/Sequen...
Controller
- Controls the register in determining when to shift digits and overall assists with the multiplier
Register
- shifts the digits when adding
Adder
- Part of the multiplier which adds two four bit numbers
Multiplier
- Incorporates counter, adder, shift register to multiply and then outputs value to display
- takes counter value and multiples by value of power used per second of LED ( display in value of 10^-4 Watts)
Seven Segment
- displays multiplied number (from multiplier) which is the power used by the LED during the time it was on
Counter
- counts the number of clock cycles the LED is on/motion is detected
Clock Divider
- slows down the clock to a more human appropriate speed
Step 8: Wiring
In addition to wire this this correctly, follow the picture in addition to the instructions below
- The signal goes out from the basys-3 board and into the base of the transistor
- the ground of the LED is in the collector of the transistor
- the emitter of the transistor goes to the ground strip
- the positive side of the LED goes to the power strip
- breadboard to basys-3 board
- the signal out of the sensor goes into the basys-3 board
- Lastly, power and ground of the sensor are also on the power strip
Step 9: Sources
Some resources we have utilized from other places to bring a better instructable to you include the following
- http://www.ee.surrey.ac.uk/Projects/Labview/Seque...
this is where we bring more information regarding the D Flip Flop brought to you courtesy of the University of Surrey
Also, some of our code was provided to us by previous professors and is noted so by the name of the engineer at the top of the source code.