This project centers around a system with two PIC32MX170F256B microcontrollers. The first, designated as the leader PIC (U5), is at the heart of the operation. It processes inputs from a variety of digital and analog sensors and orchestrates the overall functioning of the system. This includes managing a main finite state machine (FSM), controlling both a cereal and a timer servo, sending pulses on 3 pins to the second PIC, driving the LEDs, and taking inputs from buttons, distance sensors, microphones, and potentiometers. The second microcontroller, known as the follower PIC (U3), works in tandem with the leader. It primarily handles the control of the LCD panel 1602A, taking cues from the leader PIC.
Powering this setup are two 3.3V breadboard power supplies, which energize the microcontrollers, sensors, and a red LED. Additionally, the 5V outputs from these power supplies are connected to the LCD panel 1602A and a green LED. For components requiring more power, such as the timer and cereal servo and the active buzzer, an external 5V power supply connected to wall outlets is utilized.
The project incorporates a variety of sensors to interact with its environment. This includes the HW-201 opto-reflective sensor for detecting bowl placements, a 10k ohm potentiometer for dial amount selection, a microphone amplified with a MAX4466 for enhanced audio input, and three buttons (red, blue, and latching) for dial set instruction and cereal type selection. To ensure smooth operation and minimize electrical noise, bypass capacitors are placed across power and ground rails for all IC components.
Ears Sensing Bell Ring
A microphone chip with MAX4466 amplifier integrated is sourced from Amazon. It has gain set to 30 by turning screw on the chip and incorporates in a fixed DC offset of 1.65V. The signal output from the microphone is passed through a comparator circuit with hysteresis built in using LM339. The large and the small thresholds for the comparator circuits are 1.8789V and 1.4025V respectively. The circuit turns periodic analog signal into digital ones if peaks stay higher than 1.88V and zeros if troughs stay below 1.40V. The main Pic controller runs microphone checkers that count how many transitions have been received and will only send loud sound detected event if the number of transitions detected exceed pre-set thresholds.
LCD Panel Circuits
The QC1602A LCD panel is driven in 8 bit modes with DB0~DB7 data pins connected to outputs from 74ACT244 driver. The line driver's output is controlled by RB2~RB4 and RB11~RB15 pins on the second PIC U3 controlled by values read on its RA2~RA4 pins. QC1602A's pin3 is connected to a rotary 10k potentiometer to enable screen contrast adjustment. The RS pin, held high when writing characters to the display and low during initialization, and the E pin, held high when the module is enabled, are controlled by a separate 74ACT244 line driver taking inputs from the second PIC U3. QC1602A's pin 16 and pin 15 are the positive and negative terminals of the backlight LED of the LCD display and should be connected to 5V (through 220ohm resistor to limit current) and the common ground respectively.
Cereal and Timer Servos
There are two servos used in the machine, the smaller MG90D to turn dial and show passage of time and the more powerful HX5010 to turn the spinner on the cereal dispenser. The MG90D is directly controlled by 3.3V PWM signal output from the primary U5 PIC's RB12 pin while HX5010 has its PWM inputs connected to another 74ACT244 line buffer that bumps the PIC's PWM control on pin RB15 to 5V.
LED Circuits
There are two LEDs used in the machine, a red LED rated at Vf=2.2V and an current of 20mA and a green LED rated at Vf = 3.2V and an current of 20mA. N-FETs 2N7000 are used to drive the two LEDs with their gates connected to pins on the same 74ACT244 line driver that controls the PWM0 for the cereal dispensing servo.
Button Press Circuits
There are three buttons used in our "cereal killer", a red (top left) and a blue (bottom left) momentary button for cereal type selections and a latching button (top right) to be pressed when the user finishes adjusting the dial for amount. All three buttons use the same circuits that utilizes RC time constants for hardware debouncing (credit to: prelab0) and are connected to the primary main PIC U3 as digital inputs.
Analog Sensors
There are two analog sensors used in our system, a HW201 opto-reflective sensor (left) and a 10k rotary potentiometer (right) powered by 3.3V breadboard supply. The former is used to inform when a cereal bowl has been placed and the latter is used to allow users to select the amount of cereal they want. Both are connected to the primary U3 PIC as analog inputs.