Binary to Decimal Machine

color=blue>
Binary to Decimal Machine Binary to Decimal
Machine




Submitted by:
Dennis Schmitt
Curtis Stovall
Seth Bell




ME307
Mechatronics
Colorado State University
December 9, 2003 Table of Contents
Table of Contents...................................................................................................................... i
List of Figures.......................................................................................................................... ii
List of Tables .......................................................................................................................... iii
List of Tables .......................................................................................................................... iii
Design Summary ..................................................................................................................... 1
Design Details.......................................................................................................................... 4
Functional Diagram ............................................................................................................. 6
Device Pictures .................................................................................................................... 7
Software Flowchart............................................................................................................ 14
Electrical Schematics......................................................................................................... 15
Input/Output Map .............................................................................................................. 17
Project Costs ...................................................................................................................... 18
Appendix A Software ......................................................................................................... 19
Appendix B Mechanical Schematics .................................................................................. 23



i List of Figures
Figure 1 Binary to Decimal Machine.............................................................................................. 2
Figure 2 LEDs and LCD with Initial Message .............................................................................. 2
Figure 3 LCD Message After Start Button is Pushed..................................................................... 3
Figure 4 LCD Display with Decimal Guess ................................................................................... 3
Figure 5 Functional Diagram.......................................................................................................... 6
Figure 6 Inside Main Control Box.................................................................................................. 7
Figure 7 Close-up of Main Circuit Board....................................................................................... 7
Figure 8 Rear View of Front Panel ................................................................................................. 8
Figure 9 Side View of Remote Board and LED's........................................................................... 8
Figure 10 Side View with Control Box in Place............................................................................. 9
Figure 11 Front Panel...................................................................................................................... 9
Figure 12 Keypad.......................................................................................................................... 10
Figure 13 Keypad 15 Pin D-Sub Connector ................................................................................. 10
Figure 14 Photo Sensor and Motor ............................................................................................... 11
Figure 15 Front View of Motor Drive Assembly ......................................................................... 11
Figure 16 Top View of Motor and Dispensing Assembly............................................................ 12
Figure 17 Motor Drive Assembly Components............................................................................ 12
Figure 18 Keypad, Control Box, and Motor/Sensor Connectors.................................................. 13
Figure 19 Computer to Control Box Programming Interface....................................................... 13
Figure 20 Software Flowchart ...................................................................................................... 14
Figure 21 15-Pin D-Sub Connector for Keypad ........................................................................... 16
Figure 22 Initial Concept of Front Panel ...................................................................................... 23
Figure 23 Initial Concept of Drive Mechanism ............................................................................ 23
Figure 24 Schematic of Layout Drawing for Sheetmetal ............................................................. 24
Figure 25 Schematic of Layout for Front Panel............................................................................ 24
Figure 26 Schematic for Motor/Sensor/Drive Shaft Assembly .................................................... 25
Figure 27 Custom Drive Shaft ...................................................................................................... 25
Figure 28 Drive Gear Example ..................................................................................................... 26

ii List of Tables

Table 1 Input/Output Map for Electrical Schematic..................................................................... 17
Table 2 Project Cost Sheet............................................................................................................ 18

iii Design Summary
The project is designed as a learning toy with a reward for determining the correct answer
(see Figure 1). The object is to represent a random number, from 1 to 255, in binary form by
using eight LEDs. The user enters the decimal form of the number using a keypad. The users
guess is displayed on an LCD as the guess is entered. Once the guess is entered, by pressing the
enter key, the guess would then be compared to the actual number. If the guess matches the
actual number, a motor activates, turning a shaft to the gumball machine that releases a gumball
or candy. If the guess does not match the actual number, a digital sound module is activated and
a sound is played through a speaker. The program then starts over and asks the user to press the
start button.
The program is controlled by a Microchip brand PIC microcontroller. The PIC generates a
random 16-bit number that is converted into an 8-bit number by the software. The program then
turns on the corresponding outputs for the LEDs. This displays the number in binary (1
corresponding with a lighted LED and 0 with an unlighted LED). The LCD then displays a
message prompting the user to enter a guess (see Figures 2 and 3). The user then enters a guess
with the keypad (see Figure 4). The program allows for three digits to be entered and then looks
for the enter button. It also allows the entered digits to be cleared from memory when the clear
button is pressed. The program stores the number in an array as three separate digits and then
turns them into one number when the enter button is pressed. This number is compared to the
randomly generated number. As stated before, if the numbers match the motor for the gumball
machine is activated. The motor is geared so that one revolution of the motors shaft will make
the gumball machine give out one gumball. This corresponds to a gearing ratio of 3:1; three
revolutions of the motor shaft will produce one full revolution of the dispensing wheel. When
the motor has made one revolution, a photo sensor is used to detect a metal flag attached to the
shaft and this input to the PIC stops the motor. If the numbers entered do not match the stored
number, a pulse is sent to the digital playback module, which will play the sound once.


1
Figure 1 Binary to Decimal Machine


Figure 2 LEDs and LCD with Initial Message

2
Figure 3 LCD Message After Start Button is Pushed


Figure 4 LCD Display with Decimal Guess


3 Design Details
As the f