Introduction: Automatic Shut Down Wireless Mouse (Prototype)
Disclaimer: This is a prototype and will make your wireless mouse “wired”. Further, depending on your mouse, it may lose its ability to slide across the table/mousepad.
For our final project in CPE 133 Digital Design at Cal Poly, The Group Formerly Known as Queen presents a “wireless” mouse that shuts down when it hasn’t been used over a given time constraint. While brainstorming ways to save the Earth, we realized that we always forget to turn off our wireless mice. This wastes the batteries in our mice, leading to a need for more batteries to be produced and, more importantly, an excess of waste in the form of the used up batteries. We believe that wireless mice should contain an automatic shut down feature in order to prevent this waste. This project proves that this feature is both possible and feasible.
GitHub Source Code:
Youtube Video of Prototype:
- The Group Formerly Known as Queen
- Ignacio DeAnquin (Electrical Engineering, email@example.com)
- Brandon Kelley (Computer Engineering, firstname.lastname@example.org)
- Alan Nonaka (Electrical Engineering, email@example.com)
- Anthony Velasquez (Computer Engineering, firstname.lastname@example.org)
- (We are all second-years at California Polytechnic State University, San Luis Obispo)
Step 1: How Our Design Works
By combining VHDL code with a Basys 3 FPGA we were able to maintain the integrity of the wireless mouses's power circuit while incorporating the ability to shut down after the programmed time constraint.
From a software standpoint, the project is essentially a finite state machine with 3 states: active, standby, and off. The circuit is in the active state when the mouse is outputting data in the form of movement, scrolling, or clicking, or when the reset button triggers a reset. The circuit is in the standby state when there's no data being output by the mouse and it has been this way for less than the time constraint. It is still possible for the mouse to output data and this will result in the circuit returning to the active state. The mouse is receiving power during both of these states. The final state, the off state, is reached by allowing the mouse to be in standby for longer than the given time constraint. In this off state, the mouse is not drawing any power, conserving the life of the batteries. While in this state it is impossible for the mouse to output any data and therefore a reset of the system is required, implemented in the form of a button press. We implemented this FSM in VHDL and edited in the Vivado Webpack version 2014.4.
From a hardware standpoint, one button, one header, and the female USB port were used on the Basys 3 board. The button was included to reset the system from the off state to the active state. The USB port was included to read the mouse's data, thus requiring the wireless mouse's USB receiver to be plugged into this port rather than the computer. The header was connected to a breadboard which we used to both demonstrate the mouse's data input and the states, in the form of three LEDs, and control the mouse's power through a transistor. Ideally, we would include a female to 2 male USB splitter in order to prove the mouse still works on the computer monitor, however it was difficult for us to find and buy this part within the given time constraint.
Step 2: Materials
There are obviously substitutes to the materials listed below, however this is what we used:
- Computer with Vivado Webpack version 2014.4
- Basys 3 Circuit board and micro-USB cable
- PS/2 wireless mouse
- Jumper wires
- LEDs (green, yellow, and red) and Resistors
- NPN Transistor
- Compression software to unzip the file included with our VHDL and XDC files
Step 3: The Code
All of our VHDL and XDC code is included in the attached zip file. Feel free to use this code or base your own off of ours, however please give credit where credit is due. Further we recommend opening and editing the VHDL for this project in the Vivado Webpack version 2014.4, a free software. We coded in this version and our Basys 3 board is designed to work on the Vivado Design Suite. Through this environment, the code can be uploaded straight to the Basys 3 board.
Alternatively if you would like to try to implement your own code and want a general guideline of what we did, or if you need a further understanding of our code, here's another description of the files. Our code is divided into 3 VHDL files and a single XDC file.
The Environmental Mouse file is a higher level file that calls upon logic from the other two files. This module controls the power of the PS/2 mouse, shutting it off if it is found to be inactive. It calls upon clk_div2 to slow the clock signal and upon Nascounter to count the time passed and determine the state. This file inputs the button value and the mouse's PS/2 data value. It outputs, through the PMOD header, the led and mouse power values.
The file clk_div2 is not our own and was written by Bryan Mealy. This file slows the clock signal to a more usable frequency for our purposes. As is commented on line 38, we made a single edit. By decreasing the max_count integer, we increased the clock's frequency from its previous given value allowing the mouse's input data to be read at a high enough frequency for every day use. By further decreasing this value, the frequency of the clock can be increased.
The file Nascounter determines what state the circuit should be in. It does this by reading the mouse's PS/2 input and counting the clock signals. As the files stand right now, the time constraint of the standby state is set to 6 seconds. Within the off state check, on line 68, the value can be changed in order to achieve a different standby length of time. (Note: changing the frequency in clk_div2 will also change the time constraint.) This file passes all outputs back to Environmental Mouse.
The XDC file Environmental Mouse Basys 3 Constraints is a modified version of the Basys 3 Master Constraints file. We edited it down to only contain the lines we needed for this project. This includes the middle button on the Basys 3 board, the USB input, the PMOD header JA, the clock signal, and the voltage configuration.
The unedited Basys 3 Master Constraints File can be found at:
Github link to source code:
Step 4: The Hardware
In order to accommodate the peripherals used by the Basys board, a number of hardware assembly steps are necessary. This includes setting up three LEDs and the mouse to receive input from the FPGA board.
Start by connecting the red LED. Do this by wiring a jumper wire from PMOD header JA pin 1 (the top-right port) into the breadboard. Then, connect the positive end of the LED to the line in the breadboard where the jumper was just placed. Finally, connect the negative end through a 1kΩ resistor to the ground of the breadboard.
In a very similar way, connect the yellow and green LEDs using the second and third ports on the PMOD header. These ports are the two directly to the left of the one previously used. Afterward, connect the negative of the breadboard to the GND port on the PMOD header.
The configuration for providing power to the USB mouse involves the use of an NPN transistor, a dual triple A battery pack and leads connected to the power inputs of the mouse. To start, place the transistor in its own section of the breadboard. To the base of the transistor, connect a jumper that connects into the fourth port of the JA PMOD header (the port directly two the left of the three previously used). To the collector of the transistor, connect the positive end of the battery pack. Ground the negative end of the battery pack on the breadboard. To the emitter of the transistor, connect the positive mouse lead. Ground the negative end of the mouse to the breadboard.
At this stage, the project is now assembled and ready for programming!
Step 5: The Final Outcome
At this point you should have a fully functioning project. The three states are displayed via LED: green for active, yellow for standby, and red for off. Further the mouse fully shuts down when in the off state, which can be observed on most wireless mouses as it no longer lights up. Pressing the middle button on the Basys 3 board resets the system back into the active state.
Potential modifications include, but are not limited to, editing the timing constraint of the standby condition, including an LED for the power output, and adding a female to 2 male USB splitter. By editing the clock cycle counter within Nascounter (or the frequency of the clock cycle, not recommended) you can change the standby time. We had it set to 6 seconds to demonstrate that the prototype does work to our peers and professors in the short amount of time we had to present. Another idea is to include an LED that powers on when the mouse is receiving power. This could potentially be useful if your wireless mouse doesn't light up when it is receiving power. It can also be another tool to demonstrate that the prototype works, however it ultimately should only be on when either the active or standby LED are on. Finally, by using a proper USB splitter, the mouse's PS/2 data stream can still be sent to the computer, allowing the mouse to retain all of its functionality and providing an even more concrete demonstration of the system working as the mouse can be observed on a computer monitor.
Step 6: But It's Just a Prototype...
As previously stated, this project does result in a prototype of our system. Because of this, without a USB splitter the mouse is essentially rendered useless as its data stream is not sent to the computer. Further, the wireless mouse is now wired to the Basys 3 board. Ultimately, the prototype is an impractical solution, however it demonstrates the capabilities of this system and can be produced in a practical fashion.
For this system to be practical, the entire circuit must fit within the wireless mouse. In today's day and age of minuscule electronics this is definitely possible. We believe that all of the circuitry can be contained within the mouse, leaving the only external portion to be the reset button. This can be tied to the mouse clicks that are, obviously, already a part of the mouse. The logic would allow for a transition from the off state to the active state if a mouse click occurs and there's a connection established with the USB input. This will prevent the mouse from being on at unwanted times.
We have no concrete numbers on how much of a benefit the Earth will experience from this feature being implemented on wireless mice, however it will cut down on the waste of batteries caused by people leaving their wireless mice on when not in use.
Thank you for checking out our project. We hope you enjoyed reading it and maybe even built our prototype. We hope that this prototype opens your eyes up to the waste caused by leaving wireless mouses on while unused. We believe that companies can start implementing this feature in order to save the world one mouse at a time.
-The Team Formerly Known as Queen