Electronics

Components

Blue LEDs

Capacitive Touch Sensor

Hall Sensor (Linear + Latch)

Reflective IR Sensor

Jumbo Indicator LEDs

L298N Motor Driver

12V Maxon DC Motor

IRLZ34N MOSFETs

74ACT244 Octal Buffer

PIC32MX170F256B

74HC595 Shift Register

Slider Potentiometer

Soundboard

SPST Switch

MAX7219 LED Dot Matrix Display

Full Schematic

Components

The microcontroller for this project was a PIC32MX170F256B, connected to a SNAP programmer via the MPLAB X IDE. Bypass capacitors were placed between Vcc and GND to minimize noise. Peripheral connections are shown above. 

A 74HC595 8-bit serial-parallel shift register was used to control a set of 6 blue LEDs that indicated time elapsed since the welcome state. Each Q pin of the shift register is connected to the base of an NPN transistor, which powers an LED in series with a current-limiting 62-ohm resistor. 3 pins lead to the master PIC which corresponds to the SRCLK, RCLK, and DATA lines. The 6 LEDs represent a binary number between 0 and 63, with 1 corresponding to a lit state and 0 off. 

An L298N dual H-bridge motor driver was used to drive a 9V Maxon DC motor, which spun the rubber driver wheel. The L298N requires a 5V logic supply, a 12V power supply, as well as 2 input pins from the PIC and an enable pin to enable PWM. Flyback diodes are not shown in the schematic because the breakout L298N board we used already incorporated it. 

A Honeywell SS49E linear hall sensor was used to determine when the door was closed/open, corresponding to the transition to/from idle to active states. The hall sensor was attached to the chassis of the cabinet, sitting flush with a magnet embedded into the door during the closed state. The hall sensor, with a supply voltage of 5V, produces a signal near 5V when the door was closed (magnetic field was detected), and dips in voltage when the magnetic element is removed. The output voltage of the SS49E was fed into a LM339AN comparator with hysteresis, producing a digital output of either 5 or 0V, into pin RB11 of the PIC. 

A capacitive touch sensor was used to trigger the starting/stopping of the spice rack. 

A Honeywell SS461A digital hall effect latch was used to detect new spices as the rack rotated. The new spice detection mechanism works exactly like a rotary encoder - 2 magnets, each of opposite polarity, are mounted at 90 degree intervals on the diameter of the spice rack, corresponding to the location of the spice baskets. As the spice wheel rotates, the presence of 2 opposing magnetic fields creates a square pulse that is interpreted as a new spice. 

A reflective IR sensor was used as the non-tactile component project requirement. The IR sensor achieves the same functionality as the capacitive touch sensor - a gesture or wave starts the spice wheel, and a subsequent gesture toggles it off to stop spinning. The IR sensor is powered by 3.3V, and produces a linear output swing between 0 and 3.3V which is then fed into hysteresis to produce a digital HI/LO for pin RB3 of the PIC.

An LED Matrix was used for all text display purposes. The LED matrix communicates with the PIC and a 74ACT244 octal buffer via SPI protocol. The PIC lines for CS, Clk, and Data are fed into an octal buffer which boosts the signal, and communicates with the LED matrix via the DM_Display HAL. 

An Adafruit soundboard was used to play a "ding" sound when the spice wheel stopped rotating, to satisfy the audio requirement of the project. 

Jumbo indicator LEDs were used to signal different states. When the door of the cabinet is closed, the state machine immediately goes into Idle mode, which corresponds to the yellow LED turning on. When the spice wheel is spinning, the green LED turns on, and the stopped state of the spice wheel corresponds to the red LED turning on. Only 1 indicator LED is on at a time. All 3 are controlled by separate PIC pins that connect to the base of an NPN transistor. A current limiting resistor is used in series with the LEDs. 

A slider potentiometer was used to control the speed and direction of the spice wheel. The slider was mounted vertically on the front left of the cabinet chassis, where moving the slider up corresponds to increasingly faster clockwise motion, and moving the slider all the way down corresponds to increasingly faster counterclockwise motion.