|
For my Senior Design Project in Computer Interfacing, I took a bare-bones toaster oven and added a digital interface. In addition to preserving the original functions of the oven, several features were added:
Contents: Operating Instructions Main Menu Cook Programming Mode Ringtone Menu Wi-Fi Block Diagram Description Schematic Circuit Operation Software Function Ringtone Programming Audio Samples The Main Menu consists of six parts, five of which can be accessed and manipulated.
The Ringtone Menu allows selecting from eight preset ringtones. Default is set to "Single Beep". When accessing the Ringtone Menu this will play. Pressing DOWN will toggle through "Simple Beep", "2001 1", "2001 2", "2001 3", "Frequency Increase", "Simpsons", and "Billie Jean", playing each one in turn. Pressing UP will toggle through the same ringtones in reverse. To select a given ringtone, simply press SELECT when it finishes playing. The toaster oven will automatically connect to a configured Wi-Fi network. Once connected, a scheduled cook program may be modified or cleared from anywhere with internet access. To do so, run the "Toaster Oven" application and follow these steps:
All functions of the toaster oven are controlled by the Arduino microcontroller. The microcontroller constantly communicates with the LCD Keypad to display current information and to receive keypad input from the user. A thermocouple is mounted in the oven. The voltage this reads gets amplified by the amplifier, and is read in by the microcontroller. The microcontroller uses this information to display the current temperature, to turn on and off two relays which control the two burners inside of the oven, and to turn on and off a relay which controls the fan. The microcontroller sends a signal to the buzzer to play ringtones whenever an alarm is activated.
The Wi-Fi shield connects to the internet, which allows the user to modify certain program settings. The program used to make these modifications is a client-side html, which is served by the microcontroller through the Wi-Fi shield. Power to the entire system is supplied by 120V AC wall power with two leads. This signal is split three ways. Two of the wires from this split from one of these leads connect to the upper and lower burners in the oven, which then run through relay 2 and relay 1 respectively, and back to the other lead of the wall power. Relay 1 and relay 2 are controlled by the digital output on pins A2 and A3 on the microcontroller, respectively. The third wire from the split of one of these leads connects to one terminal of a 12V DC 1A power supply. The other terminal of this power supply connects back to the other lead of the wall power. This power supply powers the rest of the system. The 12V power then splits three ways. The first lead powers the 12V fan through relay 4, which is controlled by digital output on pin A1 on the microcontroller. The second lead powers the buzzer. It connects to the positive terminal of the buzzer, which operates best at ~12V and 7mA. The negative terminal of the buzzer then runs to the emitter of the BJT transistor. The collector of the transistor connects to ground. The base of the transistor is controlled by digital output on pin A4 on the microcontroller through a 56kΩ resistor to supply ~70uA. The transistor has a Beta value of about 100, which allows ~7mA to flow through the buzzer.
The third lead from the 12V power supply powers a fixed 9V voltage regulator, which powers the rest of the system. The 9V regulator is used to nullify the effects that the fan and buzzer have on the rest of the system when turning off and on. The second lead powers the amplifier for the thermocouple. The third lead powers an adjustable voltage regulator. A 100Ω resistor is connected from Vout to Vadj on this regulator, and a 150Ω resistor is connected from Vadj to ground, which supplies ~3.1V to the AREF pin on the microcontroller. The hot junction of the thermocouple is mounted inside the oven. The cold junction positive lead connects to pin 1 on the thermocouple amplifier, and the negative lead connects to pin 14. Pins 1, 4, and 7 of the amplifier are grounded. Pins 8 and 9 are connected together, and run to analog input pin A5 on the microcontroller. The amplifier provides ~10mV/°C output to the microcontroller. Using the default analog reference of 5V would allow readings up to ~500°C: well above 232°C, the maximum operating temperature of the oven. Because the microcontroller reads 1,024 values for analog input, supplying 3.1V to the AREF pin allows greater precision when reading temperature values. The Wi-Fi shield stacks directly on top of the microcontroller. Pins 4, 7, 10, 11, 12, and 13 are used for communication between these two devices, and so cannot be used by other devices. The microcontroller uses pins RX0 and TX1 for Serial communication. These pins cannot be used by other devices when Serial communication is desired
The LCD Keypad uses pins 4, 5, 6, 7, 8, and 9 to communicate with the microcontroller. To avoid pin conflicts with the Wi-Fi shield and Serial communication, these are connected to pins 2, 3, 5, 6, 8, and 9 on the microcontroller, respectively. In the code, the LCD Keypad constructor was modified accordingly. The LCD Keypad uses a 5-stage voltage divider to communicate keypad presses to the microcontroller on analog input pin A0. However, the voltages which it outputs are in reference to 5V. Because the AREF of the microcontroller was changed to ~3.1V, a simple voltage divider using two 10kΩ resistors is used between the Keypad output and microcontroller input. This supplies voltages within range of the reference input voltage, but with slightly lower input values than the Keypad library is written for. In the code, the LCD Keypad reference values were adjusted to compensate. This is a very rough outline of how the different pieces of code operate and work together.
In music, as you may know, the pitch of a sound that we hear is a result of its frequency. The human ear is able to detect from about 20 to 20,000 vibrations per second, or Hertz (Hz). Concert A, for example is defined as 440 Hz. Any sound that is repeated or vibrates at 440 cycles per second will sound like an A. When I bought the buzzer that was used in this project, I had initially intended to simply use it to beep when an alarm needed to be sounded. However, once I had it hooked up, I decided to have some fun with it.
To have the buzzer play concert A, it would be necessary to turn it on and off 440 times per second. This would correspond to a cycle time of 1/440 = 0.0022727s, or 2.27ms or 2,273us. So if I had the buzzer cycle through a loop, turning on for half the cycle time, followed by off for half the cycle time, it should play an A. I wrote some simple code to test this, something like:
#define A 440; // so I can use A instead of having to type in 440 each time
In theory this should have produced an A for a duration of 1 second, and for all my tone-deaf ear knew it did, except that it sounded a little muddy. It occurred to me that because the buzzer makes a distinct pitch by itself when it is turned on, I may be hearing that pitch resonating along with the pitch of the "A". To minimize this effect, I reduced the amount of time the buzzer was on during each cycle:
for (int i=0; i<A; i++) { This indeed worked much better. I next tried to play an octave of a major scale, starting on C at 262 Hz and ending on C at 523 Hz, using code similar to above for each note. It sounded okay, but even my inept ear could tell that it wasn't quite right. I looked online for assistance, but all posts about controlling pitch using an Arduino microcontroller yielded results which were similar to what I had just done. Then something occurred to me. In theory, based on the delay times, each cycle of the above code should take 1/440 of a second to execute, but this completely neglects the amount of time for each line of code to execute. Executing each command (for, digitalWrite, delayMicroseconds) may take time which is significant compared to the cycle time. I tested this by holding the note out for what theoretically should have been 30 seconds, measuring the start time and end time. Indeed the time elapsed was closer to 31 seconds than 30. So I adjusted the cycle time by raising the "frequency" of A. I did so until I had a value which resulted in the note being held out for almost exactly 30 seconds (30.008s). The new frequency wound up being 452Hz instead of 440Hz. I then repeated this procedure for each note in my octave (and later for each note in a two octave range). I was now able to play a major scale which sounded perfect! Note: for reference for anyone who may wish to make music with an Arduino Rev3 Uno, here are the results:
I next decided to try to see if I could get the buzzer to play some chords. I knew that it would be impossible to have the buzzer simultaneously play two or three notes, but if the notes could be quickly arpeggiated, it may create the illusion of simultaneity. I programmed the buzzer to play a C for 10 cycles, followed by an E for 10 cycles, followed by a G for 10 cycles. The result sounded like a chord, but the arpeggiation was clearly noticeable. I reduced the number of cycles until it sounded reasonably like a chord, which occurred at about 4 cycles. The result was still slightly less than ideal, but passed well enough for a chord. My musical genius brother then suggested that perhaps the chord sounded off because 4 cycles would equate to different lengths of time for different notes. For example, within the same octave, 4 cycles of a G would take 1 1/2 times as long to complete as 4 cycles of a C. I was planning on using 3-note chords with a 1, 5, 10 positioning, so I wrote code that had the root cycle 4 times, the fifth cycle 6 times, and the third (up an octave) cycle 10 times, so that each note would have approximately equal duration. The result (in my opinion) was quite good. One last thing I wanted to try with the buzzer was to gradually increase its frequency. This would illustrate a couple of things. First, if the frequency started below 20Hz, the transition from a pulse to a pitch should be able to be heard. Second, as the frequency increased from 20Hz to 20kHz, the pitch should rise from the low end of the audible range to the high end of the audible range. In my opinion the result of this was quite good as well. Single Beep Simple Beep 2001 1 2001 2 2001 3 Frequency Increase Simpsons Billie Jean |