Introduction: FPGA Trip Light
While recent advances in technology have made our world more connected and accessible than ever before, these same advances have illuminated the severity of a growing global crisis: the depletion of our planet’s natural resources. Thus, the dire need for the conservation of these resources has precipitated the creation of technology aimed at accomplishing such a goal.
In an attempt to contribute to this most noble of causes, our team designed the Trip Light, as part of a final project for our CPE 133 (Introduction to Digital Design) class at Cal Poly San Luis Obispo.
The Trip Light conserves energy by turning off a light-switch once all of the people in a room have left. The Trip Light accomplishes this with a series of laser diodes and phototransistors configured with a Basys 3 FPGA and a small servo. The laser diodes and phototransistors act as “trip-wires,” and provide input to the Basys 3 as to whether a person has entered or exited the room. The Basys 3 then keeps a count of the people in the room, only outputting to the servo when the number of people in the room is zero. Ultimately, when everyone has left the room, the servo, which is also powered by the Basys 3, is activated to turn the light-switch off until the “trip-wires” detect that someone has entered the room.
The following instructions will guide a user through the construction of a low-level prototype of our intended design. This prototype does not include a servo, any VHDL related to servo output or operation, or any sort of physical system to attach the Trip Light to an actual light switch. The modified version of our intended design was due to both time and money constraints as this was designed for a class final project with a finite deadline.
The following instructable will guide anyone through the completion of a low-level prototype of this project. While it will be easier for those with some sort of previous experience with VHDL, such a skill set is not necessarily required as this project can be completed by anyone of any skill level.
All introductory material aside, let’s begin!
Step 1: Gather Required Materials
Before beginning, you may need to install the Vivado Design Suite to open and edit the provided VHDL files that control the Trip Light.
Additionally, the following parts are required:
33 ohm Resistors x 2
Step 2: Black Box Diagram
This diagram shows the overall functionality of the Trip Light, and how each of the internal components are connected.
The inputs are listed on the left, and the outputs on the right.
- S1: External input from sensor 1
- S2: External input from sensor 2
- Reset: Resets counter back to 0
- M_On: Manual override to turn LED on
- M_Off: Manual override to turn LED off
- Clk: The board's internal clock signal
- Sign: Input to the seven segment display
- Valid: Input to the seven segment display
- S_Count: A signal to delay sensor detection for better function
- LED: On-board LED representing the lights in the room
- States: On-board LED's L3-L7 representing internal signals of the board for debugging
- Anodes: The On/Off controls for the seven segment display digits
- SEG: Determines which number is represented on the seven segment display
Additionally, the two following images are state diagrams of the finite state machines that we used. They model the sequence of logic based on various inputs and internal signals.
Step 3: Prepare VHDL
The following VHDL files are provided for your use in completing this
project. Some of the VHDL modules provided were acquired from our professor, and appropriately credited to their original designers, and some of them we designed ourselves. We welcome you to attempt our project, and use any of the modules provided in the following instruction set for whatever purposes you deem necessary, with the simple request that you credit either us or the original designer.
Additionally, each VHDL file has been thoroughly commented as a means of further explaining our design.
Constraints file courtesy of:
Seven Segment Display driver module, provided by our professor, Dr. Danowitz, and courtesy of Bryan Mealy.
Step 4: Prepare Electronic Hardware
Once you have gathered all of the parts there is only some simple assembly required.
Note: Both of the breadboards are wired the exact same way, which is why we only give one set of wiring directions. The only difference between the two breadboards is that they are connected to opposite sides of the Basys 3.
First, let's wire the breadboard to the Basys 3. You can accomplish this by connecting a jumper wire from one of the outer vertical columns of the breadboard (labeled in orange) to any one of the power pins on the Basys 3 (labeled in red). Next, we have to connect another jumper wire from any one of the ground pins on the Basys (labeled in green) to one of the other outer vertical columns on the breadboard (labeled in black).
Now, we are going to connect the resistors as shown in the resistor wiring diagram. The colors correspond to the following resistances:
Yellow = 1 kilo-ohm
Blue = 100 ohm
Brown = 33 ohm
Once all of the resistors have been added, we are going to place the LEDs in their proper places. The grey lines correspond to the IR emitter (the blue-ish diode) and the light green lines correspond to the IR detector (the clear LED). It is important to note that LEDs are polarized, meaning that they have a positive and a negative end. The longer end of the LED is the positive end, so be sure to orient them as shown by the black pluses (+) and minuses (-) in the diagram.
Finally, the last step in the wiring process is to complete our circuits with jumper wires, as shown by the dark blue lines in the final complete wiring diagram.
Basys 3 Pinout diagram courtesy of:
Breadboard image courtesy of:
Step 5: Prepare Trip Light Housing
As you can see in the following photo, for our prototype we affixed the LEDs to long wires and then taped them to small pieces of wood to ensure that they were level and straight across from each other.
Have fun and be creative about how you choose to house your Trip Light. However, we will stress that it is essential the LEDS be exactly level with one another to ensure signal accuracy.
Step 6: Generate .bin File
In order to have the Basys board retain the program that we have created, rather than deleting it every time you turn the board off or disconnect it from your computer, we can generate a .bin file rather than the usual bitstream.
For instructions on how to do so, check out this tutorial from Xilinx.
Step 7: Light Trip Instructions
1) To simulate a person entering a room, trip both of the infrared detector emitter pairs, in the direction shown.
2) To simulate a person exiting the room, trip the emitter and detectors in the opposite sequence as the direction shown.
NOTE: For safety reasons, people must wait approximately 2 seconds between people entering and exiting the room.
Note: If everything is working properly, when the sensors are tripped for a person entering the room the counter on the display of the Basys board should increment up by 1. Contrastingly, when the sensors are tripped for a person exiting the room, the counter should increment down by 1.
Step 8: Additional Information
The Trip Light was created by Nyssa Backes, Chad Carlson, Cailey Kamm, and Warren Van Velkinburgh as part of a final project for CPE 133 at Cal Poly San Luis Obispo. If you have any questions, comments, or suggestions please feel free to contact us.
Thank you for reading and enjoy your Trip Light!