How It Works


    Below details how all the components were combined to implement the Smart Fan.  For more information on how each component was interfaced with the FPGA, please refer to the parts page.

Handling User Input via Nintendo 8 Controller

    User input from the Nintendo 8 Controller is divided into two categories: START Button Controls and Direction/Fan Controls.  Start Button Controls are features which require the START in combination with other buttons: START for Power On, START + A for Power Off, and START + B for Setting Recall.  This input is handled by IRQ1 interrupt handler.  When the START button is pressed by itself or in combination of A or B, this will trigger the IRQ1 interrupt in which the interrupt determines the function of the device to perform.  For Direction/Fan Controls, these inputs come from the pressing of the direction pad, SELECT, A, and B buttons.  These inputs are handled by the Timer 1 interrupt. Unlike the Start Button Controls, the Timer 1 interrupt is independant of the state of the Nintendo 8 controller pad.  The Timer 1 interrupt occurs in hundreths of a second and reads the register that holds the state of the controller.  After reading the register, the interrupt determines the location to rotate the servos and the state to set the fans.  Finally, the interrupt writes values to the registers controlling the servos and fans which causes the resultant horizontal and vertical rotations and turning on and off of fans on the Smart Fan.

Handling User Input via Pushbutton S1

    When the pushbotton S1 is pressed, it genereates an IRQ7 interrupt which performs the Setting Save functionality.  The IRQ7 interrupt handler saves the current horizontal and vertical locations as well as the on or off state of each individual fan into memory.   When Setting Recall is initiated, the Smart Fan will return to the state specified during the Setting Save.

Automatic Tracking

    At power up the fan peforms a calibration scan of the surrounding environment.   The Timer 2 interrupt is used to read the ultrasonic ranger registers periodically.   Since the Smart Fan hardware is designed to constantly enable the ultrasonic rangers, the Timer 2 interrupt simply reads the registers to determine the most updated values detected by the ultrasonic rangers.

  At every horizontal direction, the Smart Fan saves the distance read from the ultrasonic rangers into memory.  This surrounding profile remains in the Smart Fan until power down.   When the Smart Fan is in automatic mode, it continuously sends ultrasonic signals out in front of it and compares the distance readings to the profile it made at power on.   By comparing the current distance readings and the past distance readings, the Smart Fan can detect changes (usually an indication of the user present) to its surroundings.  The Smart Fan follows the user by continuously polling the distance values from the ultrasonic rangers and comparing them to calibration values.  Since there are two ultrasonic rangers, the Smart Fan can detect the changes between the two ultrasonic rangers.  If a user moves to the left, the left ultrasonic ranger should detect a greater amount of change than the right ultrasonic ranger and vice-versa.   Depending on which ultrasonic ranger detects the greatest amount of change, the Smart Fan will rotate towards it.

Status Display on 7-segment LEDs

    The Real-Time Clock interrupt is used to constantly generate the status of the Smart Fan onto the two 7-segment LED display.  At every second, the RTC interrupt handler displays part of the status message onto the display.  The message is shifted left at every interrupt to produce a scrolling effect.  The available messages displayed are "OFF", "Au-On", and "Au-OFF".  "OFF" refers to the state when the Smart Fan is powered down.  "Au-On" refers to the state when the Smart Fan is powered on AND Automatic mode is on.  "Au-OFF" refers to the state when the Smart Fan is powered on AND Automatic mode is off (Manual mode is on).