117
UNIVERSITY OF TORONTO INSTITUTE FOR AEROSPACE STUDIES 4925 Dufferin Street, Toronto, Ontario, Canada, M3H 5T6 Candlelight Light Testing Machine: Mr. Black prepared by Team 63 Wednesday Qi Ran Liao (999848205) Lifu Zhang (999720280) Zhi Jin Zhang (999853911) prepared for Prof. M.R. Emami A technical report submitted for AER201 Engineering Design TA: Rehman Merali April 11 st 2014

INSTITUTE FOR AEROSPACE STUDIES - · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

Embed Size (px)

Citation preview

Page 1: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

UNIVERSITY OF TORONTO

INSTITUTE FOR AEROSPACE STUDIES 4925 Dufferin Street, Toronto, Ontario, Canada, M3H 5T6

Candlelight Light Testing Machine: Mr. Black

prepared by

Team 63 – Wednesday

Qi Ran Liao (999848205) Lifu Zhang (999720280)

Zhi Jin Zhang (999853911)

prepared for

Prof. M.R. Emami

A technical report submitted for AER201 – Engineering Design

TA: Rehman Merali

April 11st 2014

Lifu Zhang
Lifu Zhang
Lifu Zhang
Page 2: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

2

University of Toronto

Institute for Aerospace Studies

4925 Dufferin Street, Toronto, Ontario, Canada, M3H 5T6

Prepared By:

Team: 63

Qi Ran Liao (999848205)

Lifu Zhang (999720280)

Zhi Jin Zhang (999853911)

prepared for

Prof. M.R. Emami

TA: Rehman Merali

April 11st 2014

Lifu Zhang
Lifu Zhang
Lifu Zhang
Page 3: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

3

Acknowledgement We would like to express our gratitude to all the individuals who provided us support and encouragement. Without them, our journey could be much harder in AER201. We are deeply indebted to our supervisor, Professor Emami, and teaching assistant, Rehman Merali, who gave us insightful instructions and feedbacks throughout the design process. In addition, we are very grateful to our Engineering Science 1T6 classmates for their excellent suggestions and design expertise which helped us to overcome numerous problems encountered in the design process. Last but not least, we want to give our special thanks to our families; without their support, the project could not be completed.

Page 4: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

4

Abstract “Mr. Black” is an automaton that was designed and constructed by a team of three Engineering Science students over the past three months. This machine was built to test a tray of maximum 9 candlelights under the time constraint of 90 seconds. It is able to turn on and off the candlelights loaded in the tray, inspect the state of functionality of each candlelight, and identify the number of lights present in the tray. The states of functionality are LED turns on and flickers, LED turns on but does not flicker, and LED does not turn on. During the demonstration, “Mr. Black” correctly determined the states of 5 out of the 7 candlelights loaded in the tray, successfully identified the number of candlelights present, with a total operation time of 14 seconds, well under the 90 seconds time constraint. The complete design and construction process are described in this report, along with the description of the final prototype and supporting calculations. Overall system improvement suggestions, and other related information such as budget, background survey, and standard operating procedure are included as well.

Page 5: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

5

Table of Content Acknowledgement Abstract Symbols and Abbreviation Definition 1. Introduction 8 2. Perspective 9 2.1 Functional Decomposition and Background Survey 9 3. Objectives, constraints, criteria, AHP, DfX 14 3.1 Objectives 14 3.2 Stakeholders 14 3.3 Requirements 14 3.4 Constraints 14 3.5 Criteria 14 3.6 DFXs 14 3.7 AHP 15 4. Budget 16 5. Division of the Problem 17 5.1 Phase 1 Task Division 17 5.2 Phase 2 Task Division 18 5.3 Phase 3 (Integration) Task Division 19 6. Electromechanical Subsystem 19 6.1 Problem Assessment 19 6.2 Solution and Overview of the machine 19 6.3 Structural Frame 22 6.4 Detachable Tray 24 6.5 Switch Mechanism Module 26 6.6 Detection Mechanism Module 29 6.6.1 Wooden cover 29 6.6.2 Installation of sensors 30 6.7 Extra features of electromechanical system 31 7. Circuit Subsystem 34 7.1 Overview 34 7.2 Power Management Circuit 35 7.3 Actuator Circuit 36 7.4 LED Candlelight State Detecting Circuit 38 7.5 LED Candlelight Presence Detecting Circuit 40 7.6 Multiplexer Circuit 41 7.7 Supporting Calculations 43 7.8 Suggestions for Improvement of the Subsystem 43 8. Microcontroller Subsystem 44 8.1 Introduction 44 8.2 User Interface 44 8.3 Motor Control 49

Page 6: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

6

8.4 LED Functionality Inspection 51 8.5 Suggestions for Improvement of the Subsystem 53 9. Integration 55 9.1 Integration Phase I 55 9.2 Integration Phase II 56 9.3 Integration Phase III 57 10. Overall System Improvement Suggestion 58 11. Accomplished Schedule 59 12. Standard Operating Procedure 59 13. Conclusion 59

Page 7: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

7

Symbols and Abbreviations

Symbol Name

Common Ground

Diode

D.C. Motor

Photoresistor

Switch

Resistor

Transistor

DPDT Toggle Switch

PIC: stands for Peripheral Interface Controller, it is a 8-bit general-purpose microcontroller. Definitions Metal Chip: a small metal rectangular chip that is used to push candlelight switch. Switching Rod: a rod that contains mechanisms which are used to turn on/off candlelights. Presence Mechanism: a microswitch that closes the circuit when candlelight is present. Lid/Cover: where all of the photosensors and presence mechanisms are installed, and blocks ambient light. DFX: standards for “design for X”, and is a guideline that addresses a particular issue caused by, or affects some characteristics of an engineering product.

Page 8: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

8

1. Introduction LED candlelights are widely used in festive events, and a functional LED candlelight is capable of flickering during its operation. However, manual testing of candlelight’s functionality is tedious and may slow down the production process. As a result, this manufacturer is requesting an autonomous LED candlelight testing machine that is able to test a maximum number of 9 candlelights within 90 seconds for each operation. “Mr. Black” is an automaton that is designed to solve this LED candlelight testing problem. It stands out from other designs because of a number of distinct design features:

1. The machine parts are modular, so they can be easily repaired or replacement, enhancing its sustainability.

2. All the machines parts are fixed by nuts and screws, which make them easily to be adjusted.

3. The internal structures of the machine are completely enclosed by acrylic and cardboard walls, increasing its safety.

4. Simple circuitry with no logic gates. 5. Real date and time of each inspection are displayed on the LCD in the standby

mode. “Mr. Black” was designed and constructed for three months by the team of Qi Ran Liao, Lifu Zhang, and Zhi Jin Zhang who are responsible for electromechanical, circuit, and microcontroller subsystems respectively. Qi Ran Liao fabricated the tray, structure and frames, and incorporated the actuator required in the machine. Lifu Zhang assembled digital and analog electronics to connect the sensors and actuators to the microcontroller board. Zhi Jin Zhang wrote the program that controls the operation of the machine, and designed the user interface. The next four sections provide the relevant background information and perspectives pertaining to the design and problem solving approach. They also give an overview of project requirements including objectives, constraints, and criteria. Afterwards, the budget of the automaton and the division of problem are explained as well. Sections 6 to 8 present the subsystems, namely, electromechanical, circuit, microcontroller, in detail. The problems faced by each subsystem are assessed, and appropriate solutions are also explained. In the end of each section, suggestions for improvement of the subsystem will be provided. The rest of the sections show how the subsystems are integrated together to construct “Mr. Black”, as well as the detailed timeline and difficulties faced by the team during the integration phase. The description of overall machine and standard operating procedure are supplied.

Page 9: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

9

2. Perspective 2.1 Functional Decomposition and Background Survey To aid the conceptual design process, the task was functionally decomposed into simpler constituents so that the original task could be solved by integrating the smaller modules together. Each functionally decomposed component is considered distinct and separated from each other: 1. Opening and closing the switches of candlelights. 2. Detecting the number of candlelights present. 3. Inspecting the states of functionality of candlelights. 2.1.1 Opening and Closing LED Switches As stated in the RFP, the candlelights are first loaded into the tray with switches closed, and should be turned off when the tray is retrieved after the operation. Therefore, the automaton should be able to open and close the LED switches during its operation. The switch on a LED candlelight is small, and requires a translational horizontal motion to slide it back and forth. The mechanisms developed from either brainstorming or the existing designs in the industry to perform this function are described in the following sections. 2.1.1.1 Motor Board and Metal Chip This is a mechanism consisting of a board with gear teeth on one side and 18 metal chips (see Definitions) attached to the other, and a motor.

Figure 1: Motor Board Design

When the motor rotates the gear, it pulls the board sideways, making a translational motion. The metal chips are placed so that they will clamp on the two sides of a switch, and slide the switch horizontally as the board moves. One advantage of the design is that it is simple and intuitive. Nevertheless, the mechanism is not very efficient because it uses motor directly for translational motions, and it is not easy to produce precise gear teeth.

Page 10: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

10

2.1.1.2 Switch Test Machine by Makeblock Makeblock is a company that provides mechanical parts and electronics for building robots and various machines. This company has shared a video on Youtube to display one of its functional robots called the Switch Test Machine, which is used to turn a switch, similar to the one on a LED candlelight, on and off very fast. [2] This robot is composed of a motor, a rotating disk, and two metal shafts.

Figure 2: Switch Test Machine (red: rotating disk, green & orange: metal shaft)

As seen in Figure 2, the motor is used to rotate the disk (pointed by the red arrow), which in turn drives an intermediary metal shaft in a semi-linear fashion (pointed by the orange arrow). This intermediary shaft then pulls the longer metal shaft (pointed by the green arrow) back and forth; hence the transformation from rotary to linear motion is complete. The longer metal shaft, having acquired a horizontal motion, can slide the switch using two rubber heads attached to it. This design is considered as highly effective since it converts the rotary motion of a motor to a translational motion. Compared to using a motor directly for a horizontal motion, this is more efficient and feasible. Moreover, the whole mechanism is easy to manufacture, and requires no high precision machine works. However, the only concern for implementing such a design on the machine is that the weight and length of metal shafts may exceed the constraints posed by the RFP. 2.1.2 Detecting the Presence of Candlelights The RFP requires that the machine should detect the number of LED candlelights present in a tray. This is necessary since if a candlelight is not present in the tray and the machine does not have this information, it will mistakenly register this absence as the LED fail state where the LED does not turn on. Thus, detection of the presence of candlelights is vital to a fully functional automaton. 2.1.2.1 Force Sensitive Resistor (FSR) A force sensitive resistor detects the change in force or pressure applied to it, and as force increases, its resistance decreases. [1]

Page 11: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

11

Figure 3 Force Sensitive Resistor

To check the presence of candlelights, FSR can be attached to the switch sliding mechanism, and used as the point of contact with the switch. When a switch is opened or closed, the FSR touching the switch will experience a change in force applied to it; when a switch is absent, the FSR will experience no applied force, so its resistance will not change. The variations in resistance can be used to signal the presence of candlelights. FSR is easy to use and implement. But the resistor can wear out quickly in the process of hitting and sliding the switch, which reduces the durability of the test machine. 2.1.2.2 Photoelectric Sensor A photoelectric sensor is composed of an emitter and a receiver, where the emitter emits a beam of, often infrared, light, and depending on the amount of light received on the receiver, the sensor can detect the presence of an object. [3] The photoelectric sensors are widely used in the industry. [3] However, this kind of sensor is not suitable for the project due to its high price and apparent size. [4] 2.1.2.3 Detector Switch Switch sensors are used extensively in many areas of engineering. [1] One particularly interesting switch is the detector switch due to its simplicity and low-cost. [5] When a tray of unknown number of LEDs is loaded into the machine, the candlelights will press down the corresponding number of detector switches, and where the LEDs are absent, the switches will not be pressed. Thus the presence of candlelights is detected by distinguishing the states of detector switches. Another advantage of detector switch is that it can return to the un-pushed state easily, not requiring the operator to un-press it compared to other switches, for example, the on and off switch.

Page 12: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

12

2.1.3 Inspecting the States of Functionality of Candlelights The major function of the LED candlelight detecting machine as stated in the RFP is to inspect the states of functionality of the candlelights. The functional state of each candlelight is that the LED is turned on and starts flickering. Other two malfunction states include the LED is not turned on, or is not flickering when it is turned on. In order to inspect these three states, photosensors have to be used. There are three types of sensors can be utilized to detect light: photoresistor (Figure 4), phototransistor (Figure 5), and photodiode (Figure 6). 2.1.3.1 Photoresistor For a photoresistor, the presence of light will change its resistance. The brighter the light is, the less the resistance will be. [1]

Figure 4: Photoresistor

2.1.3.2 Phototransistor There are two types of phototransistors: two-lead and three-lead. For a two-lead phototransistor, the base is a light-sensitive surface area. In a three-lead phototransistor, the third lead helps to boost injected current to base, providing more sensitivity. [1]

Figure 5: Three-Lead Phototransistor

Page 13: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

13

2.1.3.3 Photodiode For a photodiode, it has an active area to absorb light. When light is absorbed, an electron-hole pair is formed. If the diode leads are connected, a reverse current will be generated. [1]

Figure 6: Photodiode

2.1.3.4 LED Electrical Test Module Designed by Chroma In the industry, LED testing machines are manufactured in different scales and can be found in the current market. An example among them is the LED Electrical Test Module designed by Chroma. [6] The dimensions of this module are 430 mm x 90 mm x 430 mm. The weight of the module is 10 kg. As for functionality, it has a great measurement accuracy but focuses more on high voltage and high power LED designs. Furthermore, this module is used in a LED-inline test system, whose dimensions are much larger than those stated in the constraints. [7] Also, it is designed for mass production applications. [7]

Figure 7: LED Electrical Test Module Designed by Chroma

Figure 8: LED-Inline Test System Designed by Chroma

Page 14: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

14

3. Objectives, constraints, criteria, AHP, DfX 3.1 Objectives

1. Test a tray of, maximum 9, LED candlelights in no more than 90 seconds. 2. Record the total number of candlelights, and the inspected functionality of each

candlelight. 3. Display the information on LCD screen.

3.2 Stakeholders

1. LED manufacturer: a. Defines the requirements and constraints b. Provides funding

2. Machine operator: a. Operates the testing machine b. Should not be harmed by the machine

3. Engineers a. Design and test the solution

3.3 Requirements

1. Autonomous, the operator is only allowed to place candlelights in the tray. 2. Includes a tray that can be separated from the machine and does not contain any electronic part; the tray must hold at least 9 candlelights. 3. Portable, without any required installation. 4. Includes an easily-accessible emergency STOP switch that halts all the

mechanical parts. 5. Each operation takes a maximum of 90 seconds.

3.4 Constraints

1. Maximum dimensions: 50 cm x 50 cm x 50 cm 2. Maximum weight: 6 kg 3. Maximum cost: $230 CAD 4. Maximum operation runtime: 90 seconds

3.5 Criteria

1. Cost (measured in $CAD): lower the better 2. Size (measured in cm^3): smaller the better 3. Weight (measured in kg): lighter the better 4. Simplicity (measured in number of moving parts): lower the better

3.6 DFXs The design team has determined the following DFX for guiding the conceptual design and solution selection process.

Page 15: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

15

Design for Efficiency Due to the constraints defined by the client, the operation runtime must be less than 90 seconds. As a result, the candidate solution must provide a correct testing of LED candlelights under this time limit. Design for Safety The automaton must not pose any hazard to its user, i.e. no sharp edges or exposed electrical wire. Design for Robustness The machine must be designed to be structurally stable and durable for a reasonable period of time. Design for Feasibility The construction of the machine should be feasible and does not require much work with high precision. 3.7 AHP For some parts of the machine, the following Pugh charts shows the decision making process involved in building the robot. Actuator Selection

Criteria Weight D.C Motor Stepper Motor

Cost 0.3 +1 -1

Simplicity of Circuit 0.3 +1 -1

Reliability 0.4 0 0

Total 1 +0.6 -0.6

Table 1: Pugh chart for actuator selection

Therefore D.C motor is a better solution. Tray Design Selection Criteria Weight Linear Tray Square Tray Circular Tray Cost 0.3 1 1 1 Ease of Fabrication 0.2 1 -1 -1 Reliability 0.3 1 1 1 Space occupation 0.2 0 1 1 Total 1 0.8 0.6 0.6

Table 2: Pugh Chart for tray design selection

Therefore, linear tray is a better solution for the problem.

Page 16: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

16

Photosensor Selection Criteria Weight Photoresistor Photodiode Phototransistor Cost 0.3 1 -1 -1 Simplicity of Circuit 0.3 1 -1 -1 Reliability 0.2 1 1 1 Response Time 0.2 0 1 1 Total 1 0.8 -0.2 -0.2

Table 3: Pugh Chart for photosensor selection

Therefore, photoresistor is a better solution for sensor selection. 4. Budget The budget listed below is calculated based on retail price. Mass production would decrease its cost.

Components Quantity Unit Price

1K Resistors 22 $0.02 3.3K Resistors 9 $0.02 5.6K Resistors 2 $0.02 Photoresistors 9 $1.75

TIP147 Transistors 2 $1.00 TIP142 Transistors 2 $1.00

CD4097 8 to 1 Multiplexer 1 $3.80 Microswitch 9 $0.10

USB Type A Female Port 1 $1.80 DC Motor 1 $25.00

1N4001 Diode 4 $0.21 Wires 200 $0.01

Soldering Wire 2 $1.40 Circuit Boards 8 $1.50

Computer Power Supply 1 $20.00 24-Pin Socket 1 $0.50 Toggle DPDT 1 $1.40

Devbugger Board with PIC16F877 1 $56.00 2.5m Aluminum L Channel 2 $10.00

1m x 1m Acrylic Board 1 $10.00 1/4'' x 3''x36'' AAA Balsawood 1 $2.00

4mm-30in x 36inPlaskolite Plastic sheet 1 $7.00 5'' x 36'' x 3/4'' Solid Pine Panels 1 $5.00

Page 17: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

17

Components Quantity Unit Price

Onward Narrow Butt Hinge 1'' 2 $1.50 Onward Safety Latch 2 $2.00

97x07 BC Aluminum L Bracket 20 $0.20 300g Acrylic Paint 1 $3.00

97x10 BC Aluminum L Bracket 10 $0.40 97x15 BC Aluminum L Bracket 4 $0.60

10 pieces per Pack 1/2 X 1/8'' Nuts & Bolts 7 $2.00 10 pieces per Pack 3/4 X 1/2''Ntuts & Bolts 1 $2.00

Total $227.79 Table 4: Budget Calculation Chart

The material listed above can be bought from the following three suppliers: Creatron, Home Hardware and Active Surplus. 5. Division of the Problem The design and construction process of “Mr. Black” was split into three phases. The first phase was the design phase where the team tried brainstorming and background surveys to generate various ideas of how the automaton should work and look like overall. The construction of individual subsystems took place during the second phase: the electromechanical, circuit, microcontroller member were each responsible for his components. However, all of the members offered help to each other whenever difficulties arose that could not be handled by individual efforts. During the last phase, integration phase, the circuit and microcontroller members worked with the electromechanical member to calibrate the placement of photosensors and microswitches. The microcontroller member worked with the circuit member to adjust the circuit configuration and code to accommodate the requirement of the machine. 5.1 Phase 1 Task Division

Task Member (s)

Design of Robot Mechanisms All

Design of Robot Appearance All

Table 5: Task division in phase I

Page 18: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

18

5.2 Phase 2 Task Division Electromechanical Subsystem

Task Member (s)

Acquire raw materials All

Force, power, and dimension calculations Electromechanical

Determination of actuator(s) Electromechanical

Fabrication of different electromechanical modules Electromechanical

Assembling different electromechanical modules Electromechanical

Table 6: Task division for electromechanical subsystem in phase II

Circuit Subsystem

Task Member (s)

Acquire electronics All

Voltage, current, electrical power calculations Circuit

Design circuits for photosensors, microswitches, DC motor, 8-to-1 multiplexer Circuit

Solder functional circuits Circuit

Table 7: Task division for circuit subsystem in phase II

Microcontroller Subsystem

Task Member (s)

Design of user interface Microcontroller

Design of algorithm for robot operation Microcontroller

Implementation and debugging program Microcontroller

Table 8: Task division for microcontroller subsystem in phase II

Page 19: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

19

5.3 Phase 3 (Integration) Task Division

Task Member (s)

Acquire necessary materials All

Modification of physical robot Electromechanical

Design of circuit configuration All

Adjustment of program Microcontroller

Calibration of photosensors and microswitches Circuit, microcontroller

Calibration of tray All

Table 9: Task division for integration in phase III

6. Electromechanical Subsystem 6.1 Problem Assessment The electromechanical subsystem is the most complicated subsystem in Mr. Black and its functionality is vital to the performance of the entire machine. The problem stated in the RFP introduces several difficulties to the design of this subsystem. First of all, the switch of LED candlelight is tiny, it extends only 2mm from the base plate of candlelight and the pressure required is reasonably high. Secondly, the precision in fabrication needs to be tolerated in the design. Lastly, the dimensions and weight must meet the constraints. To overcome these difficulties, careful consideration in design decision making is required. 6.2 Solution and Overview of the machine

6.2.1 Modules of Electromechanical system The design of the electromechanical system Mr. Black, as mentioned above, is to be as modular as possible. Hence, Mr. Black is consisted of 4 major modules that form the basis of its electromechanical system. They are: 1. Detachable tray 2. Structural frame 3. Switch mechanism module 4. Detection mechanism module. The picture that shows the overall structure of machine with each module labelled is shown in Figure 9.

Page 20: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

20

Fig.9 Overview of the electromechanical system

6.2.2 Description of Modules A general description of each module is summarized in Table 10.

Module Component Material Detachable Tray . Wooden Tray . Wood Structural Frame . Base Acrylic Board

. Aluminum Frame

. Central Acrylic Board

. User Panel Board

. Acrylic

. Wood

. Aluminum

Switch Mechanism Module

. DC motor

. Switching Rod

. Rod Stand

. Wood

. Aluminum

Detection Mechanism Module

. Wooden Cover

. Hinge

.Sensors

. Wood

Table.10: List of module with their corresponding components

Details of each module are described in later sections.

Page 21: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

21

6.2.3 Functionality of modules Functionality of each module and their interaction constitutes the overall functionality of the electromechanical subsystem. The functional breakdown of each module is listed in Table.11 and their interaction is shown in a schematic diagram shown in Figure.10.

Name of Module Functionality

Detachable tray It can be detached from the device via user input and its function is to holds a maximum of 9 LED Candlelight without any actuators and sensors installed on the tray.

Structural Frame The structural frame provides structural support to entire machine. It provides space to house circuit subsystem and microcontroller. Furthermore, it provides structural support to tray, switch mechanism module and detection mechanism module and hide them from users. Finally, it covers sharp edge and wires to increase safety.

Switch Mechanism Module

This module receives signal from circuit subsystem to activate its actuator (DC Motor) to turn on the Candlelights placed on the tray. In addition, it also provides structural support to the tray along with the structural frame.

Detection Mechanism Module

This module output signal to circuitry and microcontroller subsystem. It detects the presence of Candlelight via a microswitch and the status of LED via photoresistor.

Table 11: Summary of module’s functionality

Figure 10: Schematic diagram of interaction between each module

Page 22: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

22

6.3 Structural Frame 6.3.1 Overview The structural frame, which supports the entire machine, is solid-modeled and shown in Figure 11.

Figure 11: Solidworks Structural frame module.

6.3.2 Material Choice This module constitutes most of the weight and volume and it is critical in providing a rigid and robust support for other modules. Hence, aluminum and acrylic were chosen. According to the material property data sheet in appendix, aluminum has 4/5 the strength of iron but at the same time, 4 times lighter. Aluminum also has the highest strength to weight ratio among the available material in the market. Hence, aluminum-L-Channel was fabricated and assembled to form the structural frame. The base board is fabricated from acrylic board. The advantage of using acrylic is reducing the volume while providing enough strength to prevent stress/tensile failure (see supporting calculation section) 6.3.3 Acrylic Base Board It is a rectangular piece that has the following dimensions: 450mm X 360mm X 7mm. It provides anchor for the aluminum frame and prevents the aluminum frame to shear deform. In addition, it is where all the circuit boards are mounted to. All the mountings between acrylic base board to aluminum frame is done by 1/8’’ X ½ nut & bolt.

Page 23: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

23

6.3.4 Aluminum Frame This aluminum frame is assembled by 8 aluminum-L-channels. It holds and provides support to the wooden tray and user panel board. The aluminum-L-channel is assembled by using nuts & bolts of size ½’’ X 1/8. Such design would increase sustainability and operability since each part of the frame can be replaced easily. 6.3.5 Central Acrylic Board The central acrylic board provides structural support to the DC motor as well as part of the wooden tray. It separates the switch mechanism module from the circuit subsystem to prevent jamming and other unwanted intervention. It also blocks ambient light from interfering with photosensor. 6.3.6 Plastic Casing The case is made from the Plaskolite plastic sheet (Figure 12) The Plastic Casing hides circuit subsystem, switch mechanism module from users. Not only it protects mechanisms from unwanted interaction with environment, it also protects user by hiding sharp edges and high-current wire to increase the safety aspect of the design. In addition, the external face of casing can be decorated for aesthetic purpose and attach instruction for operation to increase usability.

Figure 12 the plastic casing which surrounds the machine

6.3.7 User Panel Board This acrylic piece holds the DevBugger (with keypad and LCD attached), emergency stop. This piece is where user input signal of operation via keypad and receives signal from LCD screen. It also has cover mounted to partially hide the DevBugger’s circuitry (which was indicated on the picture). In addition, it leaves a gap between the panel and

Page 24: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

24

the central acrylic to allow air flow to prevent over heating of circuit subsystem. It is shown in Figure 13.

Figure 13 the top view of user panel board

6.4 Detachable Tray

This module is the where user loads the candlelight. This detachable tray is made of wood. Wood is light and easy to shape and modify. In this case, the tray has to embrace each LED Candlelight and surrounds it such that it would not move when their switch is being pushed. Since a one-piece rigid tray is desired, wood is therefore the candidate material.

Figure 14: The detachable tray which holds Candlelight (Left), its solid model (Right)

Page 25: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

25

6.4.1 Dimensions

Figure 15 The engineering drawing of the detachable tray The numbers are in the unit of mm. This engineering drawing were done in the software Solidworks 6.4.2 Design Features

The wooden tray has 9 holes drilled compactly. This reduces the length of the machine to meet the constraints. In addition, it has small piece of aluminum under each hole to orientate the Candlelight into the right position hold it in place. The tray’s edges have been rounded so it fits into the structural frame smoothly.

Page 26: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

26

6.5 Switch Mechanism Module

6.5.1 Overview

Figure 16 Completed Switch Mechanism Module

The primary material used in this module are aluminum and wood. The design of this module is such that most components are pre-fabricated with little modification. For example, Metal L-Bracket, DC motor and gear mounting set constituted a major part of this component. 6.5.2 Actuator: Bipolar DC Motor

Figure 17 131:1 – 37D DC motor Plastic Gear with 2.2cm radius

The model of Bipolar DC motor is 131:1 – 37D Gear Motor bought in Creatron. It is shown in Figure 17 along with the gear it coupled. In order to provide enough torque as shown in the supporting calculation, its technical specification was looked up and list on Table 12.

Page 27: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

27

Parameters Value Shaft Diameter 6mm Gear Ratio 131:1 Free Run Speed 75rpm Stall Torque 200oz-in

Table 12 Specs of DC motor used in the mechanism

The mounting of DC motor and gear is accomplished by a pre-fabricated mounting set shown in Fig.18. The whole DC motor is elevated to the appropriate height by a block of wood. This block also anchors the motor stand via nails.

Figure 18 the mounting of gear and DC motor

6.5.3 Switching Rod

The switching rod is the key component of the switch mechanism module. This rod physically pushes the switch of Candlelight when the DC motor drives the rod’s rack. Aluminum piece is placed to protect the rod from wearing out. The switching rod has tiny aluminum pieces crazy-glued on the surface as the contact surface between the rod and switch. When the Candlelight is its correct orientation, the switch of it descend into the cavity indicated in Figure 19. When the pinion gear rotates, the switching rod moves laterally pushing the switches to their on/off position.

Page 28: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

28

Figure 19 Overview of switching rod

Figure 20 Engineering Drawing of the switching rod

6.5.4 Rod Stand

This mechanical component consisted of a clever arrangement of 97 X 20 L-brackets, ½ X 1/8’’ nuts & bolts, and aluminum-L-channel. This arrangement greatly increases the operability of the switch mechanism module since it can be easily calibrated. Its calibration process can be done by adjusting the nuts labelled in Figure 21. By adjusting the relative position of nut on the bolt (at the same time, it is the support of the aluminum-L-channel), the height of the entire rod stand can be adjusted. Consequently, the height of rod stand can adjust to touch the tray closely to enhance the reliability of this mechanism.

Page 29: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

29

Figure 21 Overview of Rod Stand

Figure 22 Dimension of Rod Stand Setting

6.6 Detection Mechanism Module 6.6.1 Wooden cover This cover installed microswitch and photoresistor. They are glued to 97X15 L-Bracket. It also has wooden diaphragms to prevent each candlelight from interfering with each other. In addition, it presses down the tray against the switching rod to increase the stability of the switch mechanism module. Its overview is shown in Figure.23.

Page 30: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

30

Figure 23 Overview of the detection mechanism module

Figure 24 Solid Model of Wooden Cover

The mounting of this module to the main frame is mediated by a hinge. This hinge allows smooth movement of cover along the desired axis. 6.6.2 Installation of sensors The installation of sensor is mediated by a modified L bracket in which an extra hole is drilled to allow passage of wiring. Microswitch and Photoresistor are glued on the bracket to secure their positions. After careful calibration, when the cover is closed manually by user, the microswitch will be pressed by candlelight and the photoresistor will be at a close proximity to the flickering LED. This is shown in Figure 25.

Page 31: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

31

Figure 25 the microswitch is glued to bracket, photoresistor is glued on the microswitch 6.7 Extra features of electromechanical system The electromechanical subsystem was designed for several extra features listed on RFP. 6.7.1 Operability and Sustainability The plastic casing’s front wall is movable and it is locked by a door latch. As a result, the circuit subsystem member of the team could easily reach in to replace and debug the circuitry. This is shown in Figure 26.

Figure 26 the door latch installed on the front plane

The rod stand, as mentioned above can be adjusted and calibrated easily if necessary. 6.7.2 Robustness and Durability The material choice in all the vital mechanism are rigid and durable. For instance, the entire frame is constructed with aluminum and acrylic which have a high elastic modulus. Also, the switching rod has aluminum sheet mounted to prevent wood from wearing out.

Page 32: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

32

In addition, the plastic casing ensures well air circulation within the machine to prevent overheating and at the same time protects the inner content from unwanted object getting in.

Fig.27 The aluminum frame and acrylic board increased rigidity of the machine

6.7.3 Aesthetic Black acrylic paint was applied to the outer surface of machine to increase the visual impact of the machine. In addition, the colour, black, also hides the edge where different parts meet and make it seems smoother. 6. 8 Supporting Calculation

6.8.1 Required Torque

Pw = power of motor ~ 12w N = # of rotation per minute ~ 70 Then the max torque provided by motor is given by:

T = (9.554)𝑝

𝑛 ~1.59 𝑁.𝑚 Fs = Force required for switching = 4.6N

Figure 28 Free Body Diagram

Page 33: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

33

Derived from approximated static equilibrium conditions, the critical radius, r is r = 1.59 N.m / [(9) (4.6N)] = 3.84cm Since r = 2.2cm < 3.84cm, the torque required for motor is < 1.59 N.m. 6.8.2 Maximum weight load of aluminum frame Since most of the weight is supported by the aluminum frame. Hence, it is important to check the maximum load of the aluminum frame. W =Maximum Weight of loading A = Supporting area S = Ultimate Tensile stress of aluminum = 110 x 106 N/m2

g = acceleration due to gravity = 9.8N/kg

Figure 29 Cross section of aluminum channel

A is determined by calculating the cross area of each aluminum and multiply by 4, Hence, A = 4[ (12x10-3m)(10-3m) + (11x10-3m)(10-3m)] = 92x10-6 m2

Hence W = SA/g = (110x106 N/m2)(92x10-6m2)/(9.8N/kg) = 1032kg This weight greatly exceeds the maximum weight constraints (6kg) so the choice of aluminum is rigid enough

6.8.3 Space allocation for base acrylic board Each circuit board has an approximated dimension of 7cm X 7cm ~ 49cm2

The base acrylic board is 31cm x 43cm ~ 1333cm2 Number of circuit boards that can be contained ~ 27 circuit boards However, since the power supply takes up space and the circuit boards are not perfectly square, so the 27 is an overestimated. But it still can contain up to 13 circuit boards if it is designed with a safety factor of 2.

Page 34: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

34

6.9 Suggestion for improvement of electromechanical subsystem

There is definitely room of improvement in the design of electromechanical subsystem. In order to increase the performance of the machine, the following future improvement should be consider:

1. The wire shown in Figure 23 should be wrapped with plastic pipe to prevent the wires from falling out when the machine is being moved.

2. Unused portion of circuit boards should be cut out to shrink the physical size circuitry. Hence the weight and dimension will decrease.

3. Tray should be labelled to guide user where they place the tray 4. Door handle should be installed on the top of the machine to increase mobility.

Since user can grab the machine more effectively and more intuitively. As shown in Figure 30

Figure 30 5’’ Door Latch

7. Circuit Subsystem 7.1 Overview The circuit subsystem is the primary connection between electromechanical and microcontroller subsystems. It not only has to provide enough power to drive the actuator and make each mechanical part achieve its function, but also has to make sure that the microcontroller can receive signals from each sensor correctly so that the microcontroller can send the right signal to perform its functionality. Therefore, the circuit subsystem is divided into the following parts to bring electromechanical and microcontroller subsystem together:

Page 35: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

35

1. Power Management Circuit:

x The power management circuit provides appropriate voltages for different circuit components of the robot.

2. Actuator Circuit: x This circuit receives the correct signals from the microcontroller so that it

can drive the actuator of the machine effectively.

3. LED Candlelight State Detecting Circuit: x This circuit detects the state of each LED Candlelight and sends the

correct signals to the microcontroller. x 9 copies of this circuit are produced for each LED Candlelight.

4. LED Candlelight Presence Detecting Circuit:

x This circuit detects the presence of the LED Candlelight and sends the signal back to the microcontroller.

x 9 copies of this circuit are produced for each LED Candlelight.

5. Multiplexer Circuit: x The multiplexer circuit is used to accommodate the limited amount of pins

in the microcontroller.

7.2 Power Management Circuit Problem Assessment In order to make the electromechanical, circuit and microcontroller subsystem work properly, appropriate voltages have to be used for each subsystem. To satisfy the need of different power requirement in each subsystem, the power management circuit has to solve the following problems:

1. Emergency Stop Functionality: Emergency stop functionality allows the power to be cut immediately for every component of the robot, terminating every single operation in the robot. It is also one of the constraints stated in the original RFP.

2. Different Output Voltages: Due to the design of the circuit subsystem and power requirement of the actuator and DevBugger board, steady 5V and 12V D.C. voltages have to used together to make the robot operate. 12V D.C. voltage has to be applied to the D.C. motor to achieve its full power, and 5 V D.C. voltage is required for DevBugger board, LED Candlelight state and presence detecting circuit, and the multiplexer circuit.

Page 36: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

36

Solution To solve the above problem, the following circuit is used to put emergency stop and different voltages together. This is shown in Figure 30, Figure 31 Figure 32

Figure 30: Power Management Circuit Schematic

Figure 31: Emergency Stop: DPDT Switch

Figure32: Power Management Circuit Board

Page 37: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

37

In this circuit, a computer power supply is used to generate 5V and 12V voltages. A DPDT toggle switch is used as the emergency stop as shown in Figure 31. The maximum current for this switch is 6A, which is much higher than the total current when the machine is operating. 5V and 12V voltages are connected to separate channels of the DPDT switch (Figure 30). As shown in figure, there are separate plug-in channels for 5V and 12V voltages. A USB Type A female port is connected to the 5V and common ground in order to power up the DevBugger by a USB cable. 5V is also used for LED Candlelight state and presence detecting circuits, and multiplexer circuit. The only component of the robot that uses the 12V voltage is the D.C. motor. 7.3 Actuator Circuit Problem Assessment The actuator circuit has to complete the following tasks in order to make the robot functional:

1. The actuator circuit must be able to drive the only actuator of the robot, D.C. motor, to move the switching mechanism to turn on the switches of each LED Candlelight.

2. Also, the circuit has to be able to take different signals sent from the microcontroller to drive the motor in forward and backward directions.

3. Because there is only one actuator in the robot, any motor driver IC is not allowed in the design of actuator circuit as stated in the original RFP.

Solution: H-Bridge Circuit for D.C. Motor In order to accomplish the tasks of the actuator circuit, an H-Bridge Circuit is used in the design.

Figure 33. Bipolar H-Bridge Schematic

Page 38: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

38

Figure 34. H-Bridge Circuit Board inside the Robot

Figure 33 shows the design of a bipolar H-bridge circuit for the D.C. Motor. The 12V voltage is used to power up the motor. The other two signals come from the microcontroller. The microcontroller can send a 5V signal either from the left or right of the two terminals as shown in Figure 33. The H-Bridge works in the following algorithm. Motion Left Terminal Right Terminal Stop 0 0 Moving Forward 1 0 Moving Backward 0 1

Table 13 Motion’s signal 7.4 LED Candlelight State Detecting Circuit Problem Assessment One of the main problems that the robot faces is how to check whether the LED Candlelight is working or not. In order to deal with the problem, a circuit examining the state of LED Candlelight has to achieve the following objectives:

1. The LED Candlelight state detecting circuit has to be able to check three states of the LED Candlelight: flickering state (working), always-on state (malfunctioning), and always-off state (malfunctioning).

2. The circuit also must send the detecting signal to the multiplexer circuit or microcontroller for state out-put.

Solution The solution of making the LED Candlelight state detecting circuit is shown in the following schematic:

Page 39: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

39

Figure 35: LED Candlelight State Detecting Circuit Schematic

Figure 36. Photoresistor and Microswitch Mounted on the Cover

As shown in Figure 35, the LED Candlelight consists of a photoresistor, a regular 3.3 kΩ resistor, 5V voltage, common ground, and 𝑉𝑜𝑢𝑡 connection to the microcontroller. It is simply a voltage divider circuit. The following equations explain the theory behind it:

𝑉𝑉 =

𝑅𝑅

For this particular circuit shown in Figure 33, the following equations hold 𝑉 + 𝑉 = 𝑉 = 5V

𝑉 = 𝑉

Page 40: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

40

The photoresistor is used as the light detecting sensor. When the intensity of the light changes, the resistance will change accordingly. As a result, the voltage signal sent to the microcontroller,𝑉 , will change if the light is flickering. In this way, the microcontroller can detect the flickering state of the Candlelight. According to the photoresistor used in the design, the resistance in darkness is around 1000 kΩ while it is only 200-300Ω when bright constant bright light is shining on its surface. Thus, when the LED Candlelight is in always-off state, the voltage sensed by the microcontroller 𝑉 will be very close to zero. On the other hand, when the LED Candlelight is in always-on state, 𝑉 will be a constant value depending on the brightness of the light. Because the machine is going to test nine LED Candlelight in total, and the photosenors are fixed on the cover, nine copies of this circuit are used. 7.5 LED Candlelight Presence Detecting Circuit Problem Assessment Another challenge that the robot encounters is how to detect the physical presence of the LED Candlelight. Only when the LED Candlelight is present in the robot, it is worth the time for the robot to check its state. Otherwise, the robot can skip checking the state of the light. In order to address this challenge, the LED Candlelight presence detecting circuit has to do the following work:

1. The circuit has to be able to sense the presence of the LED Candlelight either by sensor or switch to change the voltage in the circuit.

2. The circuit has to send the correct voltage signal to the microcontroller so that it can give the correct information on the user interface.

Solution The solution of making the LED Candlelight presence detecting circuit is shown in the following schematic:

Figure 37. LED Candlelight Presence Detecting Circuit Schematic

Page 41: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

41

The LED Candlelight presence detecting circuit consists of two 1 kΩ resistors, one microswitch, 5V voltage source and the common ground. The microswitch is the main mechanism that detecting the presence of the Candlelight. When the microswitch touches the Candlelight, it closes the circuit, sending a 5V signal to the microcontroller, which indicates that the Candlelight is present. When there is no Candlelight present, the microswitch touches nothing in the robot. As a result, the circuit is open, and no voltage signal is sent to the microcontroller, which indicates the absence of LED Candlelight. Because the machine is going to test nine LED Candlelight in total, and the microswitches are fixed on the cover, nine copies of this circuit are used. 7.6 Multiplexer Circuit Problem Assessment The model of PIC microcontroller used of the robot is PIC16F877. One of the limitation of using it for the design of this robot is the number of pins available. If nine LED Candlelight states detecting circuits and nine presence detecting circuits are used, the number of pins will not going to be enough. Therefore a multiplexer has to be used to accommodate the number of pins available. The multiplexer circuit has to achieve the following objectives:

1. It has to reduce the number of pins used for the PIC microcontroller.

2. It must be able to receive and send correct signals from and to the PIC microcontroller.

Solution: 2-bit 8-to-1 multiplexer The solution is to use a 2-bit 8-to-1 multiplexer. The circuit schematic is shown in the following figure 38.

Figure 38. Multiplexer Circuit Schematic

Page 42: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

42

Figure 39. Multiplexer Circuit Board in the Robot

The model of the multiplexer used is CD4097B. It requires 5V D.C. voltage to power up. Also, the INHIBIT pin should be grounded in order to let it function. The connection of this chip is shown in Figure 38. All of the X inputs are used for presence detecting circuits, and all of the Y inputs are used for state detecting circuits. The main feature of this multiplexer is that it selects a pair of X and Y inputs for each select input. Thus, the microcontroller can check each Candlelight’s presence and state at the same time. In order to selecting each pair of X and Y, the microcontroller send voltage signals to A, B and C on the multiplexer. Then, the outputs from the multiplexer are sent back to the microcontroller in COMMON X and COMMON Y indicated in Figure 38. The use of this multiplexer circuit greatly reduces the pin usage for state and presence detecting circuits. A comparison of number of pins used with and without it is shown below: Without the multiplexer circuit With the multiplexer circuit 9 photosensors: 9 pins 9 microswitches: 9 pins Total: 18 pins

Multiplexer circuit: 5 pins (3 pins for select input A,B and C + 2 pins for COMMON X and Y) Remaining one photosensor: 1 pin Remaining one microswitch: 1 pin Total: 7 pins

The number of pin used is reduced by 11, which accommodates the limited number of pins in PIC16 effectively.

Page 43: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

43

7.7 Supporting Calculations Power Calculations: Maximum Current:

x PIC16F877 Microcontroller: 30mA x H-Bridge Circuit: 200mA x Photosensor circuits: 9 x 2 mA = 18 mA x Microswitch circuits: 9 x 2 mA = 18 mA x Multiplexer circuit: 25 mA x Total: 291 mA

Maximum Power:

x 12V: 200mA x 12V = 2.4 W x 5V: 91mA x 5V = 0.455 W x Computer Power supply: 485 W

7.8 Suggestions for Improvement of the Subsystem There are several ways to improve the design of the circuit subsystem to make it more efficient: 1. Using potentiometer in the LED Candlelight state detecting circuit: the current design of this circuit consists of a constant 3.3 kΩ resistor in series with the photoresistor. Due to different proximities between the photoresistor and LED Candlelight in nine different spots, the threshold voltage of the flickering state is different for each spot. Therefore, during each operation, the microcontroller has to change the threshold voltage for ADC in order to check the flickering state. Using a potentiometer in this circuit can solve this problem because its resistance can be adjusted in the way that makes the threshold voltage approximately the same for every photoresistors. As a result, the microcontroller can use the same threshold voltage for ADC in each run. Another advantage of using the potentiometer is that it is easily adjustable if the threshold voltage changes in a different environment by turning the potentiometer instead of changing the code for microcontroller and re-download the code to it.

2. Simpler Circuit for LED Candlelight Presence Detecting Circuit: there is a simpler way to make presence circuit. It is shown in Figure 40.

Figure 40 Alternative design of presence detection circuit

Page 44: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

44

When the switch is open, PIC detects 5V. Otherwise, PIC detects 0V. In this way, only one resistor is needed. Thus, it is more efficient in in terms of cost and labor. Moreover, it performs the same functionality as the one used in the current deign. 8. Microcontroller Subsystem 8.1 Introduction The microcontroller subsystem was implemented by the microcontroller member. This subsystem is responsible for user interface with the automaton, and control of the flow of operations; these tasks are done through a keypad, LCD, and input and output pin signals. PIC16F877 was selected as the microchip of the system due to its simplicity and flexibility. In order to reduce complexity and increase modularity, the microcontroller subsystem was divided into 3 components: user interface, motor control, and LED functionality inspection. These components allow user to interact with a DC motor, 9 microswitches, 9 photosensors, and LCD through the keypad. 8.2 User Interface The user interface is important since it provides the operator a mean of communicating with the machine, and a good user interface design will maximize the user experience with the automaton. Assessment of the Problem The RFP states that after the tray is loaded, the operator starts the operation by pressing a <start> on the keypad. Also, at the end of the operation, the machine must return to the standby mode by displaying a completion or termination message, and be ready to provide quality-control log. The quality-control log must include: the operation time, total number of candlelights, and the inspected functionality of each candlelight with respect to the four states, which include Pass, Flickering Fail, LED Fail, and LED Absent. In addition, the extra feature of real time/date display requires the current date and time to be displayed on the LCD in standby mode. In solving this problem, two objectives were needed to be achieved:

1. The navigation for user interface must be simple, and intuitive, because the machine is for operators of various skill levels.

2. The information displayed on the LCD must be clear, and self-explanatory, in order to reduce the unnecessary waste of time in decoding the information, and provide a satisfactory user experience.

Page 45: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

45

Solution “Mr. Black” user interface is achieved through a keypad and LCD, and contains several features to satisfy the two objectives. Usage of keys Because the machine need to be usable for operators with various skill levels, the operation should use as few keys as possible. Complex keypad inputs would be hard to memorize, or wasting time if everytime the operator needs to look up which keys to press. Therefore, the user interface design was finalized to only utilize three keys on the keypad, with each exclusively used for one function. The keys and their instructions are listed in Table 14 In addition, key 3 was re-taped as key RTC so that it is more intuitive for the operator to press when real date/time display is needed, as shown in Figure 41.

Figure 41 RTC Key

Key Function

<A> Start operation

<B> Retrieve quality-control log

<RTC> Display real date/time

Table 14 Key’s corresponding function

Page 46: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

46

Sequential flow of information A quality-control log must be displayed at the end of each operation. In order to make the navigation as simple as possible, a linear, sequential flow of information was adopted for “Mr. Black”, which means that all of the displays are shown one after another, just by pressing key B, as opposed to using different keys to retrieve different information. It works in the following manner: upon completion, the termination message will tell the operator that quality-control log can be displayed by pressing key B; this key can be pressed for three times before returning to standby mode, and each time it is pressed, the operation time, total number of candlelights, and functionality of each candlelight are displayed in order. The process is illustrated in Figure 42 Using this feature, the automaton should become easier to use since the operator then does not need to remember how to get specific information through different inputs: all he/she needs to do is just pressing one key, and then all of the quality-control log will be displayed.

Figure 42 Display sequence of operation

Intuitive information display One of the objectives is that everything displayed on the LCD must be clear and self-explanatory, meaning that the operator does not need to waste a lot of time in decoding the information even though the LCD can only hold a maximum of 32 characters at a time. Therefore, the user interface uses a combination of symbols, letters, and words to instruct the operator and express the information. For example, the double arrow brackets <> represents the key to press, and there are four different letters to represent four different states of LED candlelight. The starting interface is shown in Figure 43, and intuitively, it is clear enough for everyone that press key A will start the operation.

Page 47: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

47

Figure 43 Start Up interface The functionality of LED candlelights tested is possibly the most important thing to be displayed, and from the user interface perspective, this was implemented in a special way to provide a satisfying user experience. Since the tray of the machine is linear, the states of each light is also displayed in a linear fashion, as shown in Figure 44.

Figure 44 Report Interface

Page 48: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

48

Each letter, from left to right, corresponds to the functionality of candlelights in the tray from left to right, respectively. For instance, the first letter on the left represents the candlelight in the far left of the tray. Thus, it is very clear to the operator when he/she sees the results. Furthermore, the four letters used are representative of the four states: A means LED absent, F means LED fail to turn on, O means LED turns on but does not flicker, P means LED pass. Summary The user interface has been designed to maximize user experience by providing simple and intuitive navigation and display clear and self-explanatory information. The overall flow of the logic is shown in the flowchart in Figure 45. In addition, two legends has been printed out and pasted on the machine to make sure everything will be clear to the operator. One demonstrates how to read the letters representing the states of candlelights, and the other shows the overall procedure of how to operate “Mr. Black”.

Figure 45 Flow chart of user interfacing

Page 49: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

49

8.3 Motor Control This module is responsible for making the DC motor to turn in bi-directions, and controlling the duration of the running of the motor. Assessment of the Problem LED candlelights are turned off when loaded into the tray, and must be also turned off when the tray is retrieved from the machine after the operation, as stated in the tray. Therefore, in order to test candlelights, the machine must be able to turn the candlelights on and off. As stated in the Electromechanical Subsystem section, this was done using a DC motor. The lights will be turned on when the motor turns in one way, and off when the motor turns in the opposite direction. The reverse of the directionality of the motor was achieved using an H-bridge. The H-bridge requires two signals from the microcontroller: when both are low, the motor stops; when one is high and another is low, the motor turns in one direction, and turns in the other direction when the low and high signals are exchanged. Hence, it is the microcontroller’s responsibility to ensure the following objectives can be achieved for the motor control:

1. The motor can run in both directions, and can be turned off. 2. The duration for which the motor runs can be specified so that all the lights in the

tray can be turned on and off. Solution Two output pins were used to specify the output signals to the H-bridge; they are pins 0 and 1 from PORTD of the PIC. During the initialization of the microcontroller, both pins are cleared so that the motor will not move. However, when key A is pressed, the code immediately goes into Turn_On_Lights subroutine. In this subroutine, pin 0 is set to high while pin 1 stays low, which makes the motor turns in the direction that can push candlelight switches to the ON positions. Then a 100 ms delay is called, so that the motor runs for 100 ms. Finally pin 0 is cleared again, and motor stops. This completes a pulse of turn of the motor. This pulse is repeated for 3 more times to ensure all the lights in the tray can be turned on. The pulse, and the 100 ms interval for which motor runs, were both determined manually without using the microprocessor. The sample code for this subroutine is shown in Figure 46. Upon the completion of inspection, the Turn_Off_Lights subroutine is called. In this subroutine, pin 1 is set to high while pin 0 stays low, so that the motor turns in the opposite direction and LEDs can be turned off. The same pulses in the Turn_On_Lights subroutine are re-used.

Page 50: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

50

Figure 46 Sample code of subroutine

Summary The motor control consists of two subroutines, each responsible for turning the motor in one direction to turn on and off candlelights. The logic flow for this module is presented below in Figure 47

Fig 47 Summary of flow chart of turning ON/OFF the motor

Page 51: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

51

8.4 LED Functionality Inspection This component inspects the functionality of each LED candlelight, counts the number of LEDs present, and converts the states into letters. This is possibly considered the most important module, and the central piece of the code, because the purpose of the automaton is to examine the functionality of candlelights. Assessment of the Problem A tray contains a maximum of 9 candlelights. Each light may have one of the 3 states of functionality: pass means the LED turns on and flickers, flicker fail means the LED turns on but does not flicker, LED fail means the LED does not turn on. Nevertheless, a fourth state should also be included in addition to the three listed above, that is, the LED is absent from the tray. Including the fourth state would not only simplify the code for counting the number of LEDs present, but also reduce the overall length of the code, which means that no separate module is needed to examine the absence of the LEDs. This module need to satisfy a number of requirement to maximize the reliability and user experience of the machine:

1. The total inspection time must not exceed 90 seconds, and should be as short as possible.

2. Each candlelight’s state of functionality should be correctly determined. 3. The total number of candlelights present in the tray should be accurately counted.

Solution 9 photoresistors were used to examine the candlelights, and they would input different voltage values for different states of functionality. 9 microswitches were used to check the presence of the candlelights, and they would send a high to the microcontroller if a light is present. Due to the shortage of pins for PIC16F877, a two bit 8-to-1 MUX was used to select 8 of the 9 sensor and microswitch signals. Pins 0 to 2 from PORTC were used to select MUX signals. Pin 1 from PORTA receives the photosensor signal from MUX input, and pin 2 from PORTA receives the microswitch signal from MUX input, for the first 8 sensors and microswitches. Pin 3 from PORTA receives the 9th photosensor signal, and pin 5 from PORTA receives the 9th microswitch signal. There were 9 subroutines, for each possible candlelight present, that inspect the states of functionality with the help of the ADC_Conv subroutine. 9 registers were also used to store the letter representing the functionality of each candlelight.

Page 52: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

52

ADC_Conv Subroutine As observed from voltage values given from photoresistors, when the candlelight is flickering, the voltage values tend to fluctuate around some threshold value. When the candlelight does not turn on, the photoresistor gives 0 V; however, there is a floating voltage at the input pin of the microcontroller where it reads about 1.2 V or below when no input voltage is received. When the candlelight is turned on but does not flicker, the voltage values tend to stay constant, but much higher than 1.2 V. Therefore, an algorithm was developed to test the states of functionality of candlelights using the inputs from photosensors and PIC16F877 microprocessor’s analog-to-digital converter, which converts a voltage value received from an input pin to a 10 bits binary number. This algorithm takes the advantage of the threshold voltage value when the light is flickering around it. The algorithm was as follows:

1. A manually tested threshold voltage value, t, is set. 2. A threshold counter, n, is set. 3. Loop through the subroutine m times, each time a voltage value, x, from the

photosensor is read: if x is greater or equal to t, n is incremented by 1, else if x is less than t, n is decremented by 1. The value of n in the end is stored in another register, y.

4. If y = m + n, or y = n - m, the candlelight tested is flickering fail; if the last voltage value read is less than or equal to 1.2 V, the candlelight tested does not turn on; else the candlelight passes.

Steps 1 to 3 were implemented in this subroutine. Nth_One Subroutines There are 9 subroutines called First_One, Second_One,...,Nineth_One, each checks a candlelight in the tray, for example, Fifth_One checks the fifth light from the left, respectively. They are called one after the other in order. Each subroutine was implemented in the same fashion. Firstly, it checks the microswitch input signal, and if the signal is low, meaning the candlelight is not present, the subroutine ends, and the letter ‘A’ is stored in the register for that particular candlelight. However, if the signal is high, the ADC_Conv is called, and when it returns, the value of y is read. Then, the step 4 of the algorithm is implemented, with the difference being that a counter is also incremented when the candlelight is present, in order to keep track of the total number of candlelights. The letters representing each state are stored into registers for each candlelight. Hence, this completes the main code for the microcontroller.

Page 53: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

53

Summary The LED functionality inspection module is the heart of the automaton. The pseudocode is presented below: t = threshold voltage value n = threshold counter for i = 1 to m x = the input voltage if x >= t: n = n + 1 else if x < t: n = n - 1 end loop y = n if y = n + m or y = n - m: flickering fail else if x <= 1.2: LED fail else: LED pass 8.5 Suggestions for Improvement of the Subsystem

1. Extra features such as permanent logs and PC interface should be implemented to enhance user experience with the machine.

2. More macros should be built in the code to increase the accessibility, and make it easier to debug.

3. A loop should be used to inspect the functionality of candlelights, instead of writing 9 subroutines with similar lines of code.

4. Simple configuration board should be used to lower the overall cost of the project. The overall operation flowchart in shown in Figure 48

Page 54: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

54

Figure 48 Flow chart of the whole system

Page 55: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

55

9. Integration After the construction of each subsystem is completed, the team moves into the most crucial part of part of the design: integration. It brings the electromechanical, microcontroller and circuit subsystems together to make a functional machine. Primarily, the process of integration is divided into three phases in chronological order. Phase I is from week 8 to week 10. Phase II is from week 10 to week 12. Finally, Phase III is from week 12 to week 14. 9.1 Integration Phase I Achievement: The circuit boards and DevBugger board are mounted rigidly Mounting of circuit board The circuit boards and power supply are mounted with nut and bolts of size 1/8’’ X 1/2 as shown in Figure 9.1

Figure.9.1 The junction between circuit board and the base acrylic board are circled in

red The layout of the circuit board on the acrylic board is illustrated on Figure.I.2

Figure 9.2 Layout of circuit board on the acrylic base board

Page 56: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

56

Mounting of DevBugger Board The DevBugger board is mounted by a similar mechanism. However, its support is the user panel board. As indicated on Figure.I.3. A rectangular hole with dimension 2cm X 10cm which allows the passage of 40 pins I/O cable bus and a circle hole of 3mm radius which allows the installment of emergency stop were driven. A gap was left on purpose to promote air circulation.

Figure 9.3 Holes are drilled as indicated 9.2 Integration Phase II Achievement: the position of microswitch should be tuned to be pressed down softly when closed and the position of photoresistor should be tuned to be just in front of the Candlelight. Calibration of position of microswitch In order to avoid redrilling another hole, glue is used to extend the length of switch, as shown in Fig.9.3. Then after calibrated with glue, the whole switch is wrapped with black electrical tape for aesthetic reason.

Fig. 9.3 Calibrated microswitch

Page 57: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

57

Calibration of position of photoresistor The calibration of its position is relatively simple. Since the photoresistor is glued on to the microswitch, when the desired height was achieved, glue was applied and its position would be held rigidly. 9.3 Integration Phase III Achievement: the photosensors were tuned and calibrated for the last time, and the threshold voltage value was set, before the demonstration. The photoresistor voltage input depends on its distance from the light source. During the integration stage, it was discovered that the photosensors, after mounted on the cover, all had different distances from the candlelights, due to manufacturing imprecision. Therefore, they would all have different threshold voltage values. The microcontroller code was originally done using a loop for inspecting all of the candlelights, but if the threshold voltage values were different for each photosensor, some adjustments had to be made. One solution was to have the circuit member install 9 potentiometers to change the resistance so that all of the threshold voltages could be calibrated to be equal. However, this solution was rendered as time-consuming and if used, all of the circuit configuration designed previously would need to be changed. An alternative solution was adopted in the end, that is, modify the program, which was easier to achieve. For this solution, instead of using a loop for 9 lights, 9 subroutines were written out explicitly, each checking one candlelight. In each subroutine, a threshold voltage value, pre-determined manually for this particular photosensor, was set first, and the rest of the inspection algorithm was the same. The threshold voltage values of each photosensor when detecting flickering candlelight were determined using a voltmeter. These values are listed in Table 15.

Photoresistor Number (Numbered from the left of the tray) Threshold Voltage Value

(V)

1 2.77

2 3.3

3 3.04

4 2.80

5 3.36

6 3.3

7 2.81

Page 58: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

58

8 2.84

9 3.47

Table 15 Calibrated Threshold voltage 10. Overall System Improvement Suggestion In each subsystem section, the possible subsystem improvements are discussed and suggested. In this section, they will be brought together to improve the robot as a whole. Cost Improvement The cost of the machine can be reduced in the following two ways without compromising machine’s functionality:

1. Using simple configuration board for the microcontroller instead of the entire DevBugger: the DevBugger costs $50 CAD, which constitutes almost 25% of the total cost. Using simple configuration board that only consists the PIC microcontroller, LCD screen, Keypad and appropriate power circuit could potentially reduce the cost yet keeping the same functionality.

2. Using only one resistor for the microswitch circuit. In this way, the cost of each microswitch circuit can be reduced but its functionality remains the same.

Ergonomics Improvement Ergonomics refers to the design for user-friendliness. To make the machine more intuitive for users to operate, the following improvements can be made:

1. Labelling numbers on the tray and the position where the tray should be put: this informs users the order of the candlelight and where to put the tray for testing.

2. Installing door handle on the machine: this allows the users grab the machine more effectively and more intuitively.

3. Implementing extra features on PIC microcontroller: Extra features such as permanent logs and PC interface can enhance user experience with the machine.

Stability Improvement The stability of the system can be improved in the following two ways:

1. The wires can be wrapped with plastic pipe to prevent them from falling out when the machine is being moved.

2. More rigid mounting method should be used to stabilize the D.C. motor.

Page 59: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

59

Maintainability and Efficiency improvements The maintainability and efficiency of the machine can be improved in the following ways:

1. Unused portion of circuit boards should be cut out to shrink the physical size circuitry. Hence the weight and dimension will decrease.

2. More macros should be built in the code to increase the accessibility, and make it easier to debug.

3. To increase the code efficiency, a loop should be used to inspect the functionality of candlelights, instead of writing 9 subroutines with similar lines of code.

4. Potentiometers should be used for state detecting circuits because they are easy to adjust for different environment.

11. Accomplished Schedule

Page 60: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

60

Page 61: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

61

12. Standard Operating Procedure Before operation:

1. Check that the switching rod is in its place and not lose. 2. Make sure that all of the screws are screwed tightly.

Operate the machine:

1. Plug in the machine into an AC outlet. 2. Turn on the power supply. 3. Install each light in the tray so that the two legs opposite to the switch are aligned

to the metal chip on the bottom of the tray, and the third leg that is closest to the switch is on the opposite side of the metal chip. Make sure the legs extend out of the bottom of the tray.

4. Put the tray into the tray area above the switching rod mechanism. 5. Close the lid, and close the cover latch. 6. Press <A> on the keypad, and wait until the termination message appears. 7. Press <B> to retrieve the quality-control log. 8. Press <RTC> to read the current date and time. 9. Refer to the legend beside LCD for more information on user interface.

13. Conclusion “Mr. Black” is an automaton that was designed and constructed by a team of three Engineering Science students over the past three months. This machine was built to test a tray of maximum 9 candlelights under the time constraint of 90 seconds. It is able to turn on and off the candlelights loaded in the tray, inspect the state of functionality of each candlelight, and identify the number of lights present in the tray. The state of functionality, according to the RFP, are LED turns on and flickers, LED turns on but does not flicker, and LED does not turn on. The budget for “Mr. Black” is $227.79 CDN, below the maximum budget of $230 CDN allowed for this project. Also, the machine weighs 5.6 kg, less than 6 kg weight constraint. This automaton is reliable because it underwent over twenty test runs because the final demonstration, and has produced many perfect runs -- successfully identified the states of functionality for all of the lights present in the tray. During the demonstration, however, “Mr. Black” correctly determined the states of 5 out of the 7 candlelights loaded in the tray, successfully identified the number of candlelights present, with a total operation time of 14 seconds, well under the 90 seconds time constraint. “Mr. Black” has several unique design features:

1. The machine parts are modular, so they can be easily repaired or replacement, enhancing its sustainability.

Page 62: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

62

2. All the machines parts are fixed by nuts and screws, which make them easily to be adjusted.

3. The internal structures of the machine are completely enclosed by acrylic and cardboard walls, increasing its safety.

4. Simple circuitry with no logic gates. 5. Real date and time of each inspection are displayed on the LCD in the standby

mode. The project may be improved by incorporating the idea of four person teams instead of teams of three, since it was genuinely observed that electromechanical parts often required more than one people to make, and it would not be a bad idea to have a team of four in which two people are responsible for electromechanical subsystem, and the other two doing circuit and microcontroller. The study may be best extended to areas of quality assurance of products in industry, where an increasing number of robotic forces are being employed. “Mr. Black” is not perfect and has several limitations. For example, some candlelights that are dimmer than others might not be inspected correctly since they have different threshold voltage values. A better algorithm is needed. Nevertheless, this robotic prototype satisfies all of the requirement, and meets the constraints stated in the RFP. Moreover, the bonus feature of real date/time display has been included for the machine to maximize overall user experience.

Page 63: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

63

Appendix A: Bibliography [1] Emami, Reza. Multidiscipliary Engineering Design. 2014. 2014. Print.

[2] "Switch Test Machine by Using Makeblock." Youtube. N.p.. Web. 29 Jan 2014.

<http://www.youtube.com/watch?v=35s8QObG7bo>.

[3] "Photoelectric Sensors Information." IHS Global Spec. N.p.. Web. 29 Jan 2014.

<http://www.globalspec.com/learnmore/sensors_transducers_detectors/proximity_presen

ce_sensing/photoelectric_sensors>.

[4] "LM393 Beam Photoelectric Sensor - Black."MiniInTheBox. N.p.. Web. 29 Jan 2014.

<http://www.miniinthebox.com/lm393-beam-photoelectric-sensor-

black_p643047.html?currency=CAD&litb_from=paid_adwords_shopping&gclid=CKvbj

f7Wn7wCFQsSMwodOWMAJQ>.

[5] "Pushbutton Switches." DigiKey. N.p.. Web. 29 Jan 2014.

<http://www.digikey.com/product-search/en?lang=en&site=us&c=17&f=97>.

[6] "LED Test & Automation Instruments." Chroma. N.p.. Web. 29 Jan 2014.

<http://www.chromaus.com/product_led.html>.

[7] "Model 58158-SC LED Luminaire In-line Test System."Chroma. N.p.. Web. 29 Jan

2014. <http://www.chromaus.com/product_58158-

SC_LED_Luminaires_Inline_Test_System.php>.

[8] "Engineering ToolBox." Engineering ToolBox. N.p.. Web. 29 Jan 2014.

<http://www.engineeringtoolbox.com/>.

[9] "SN754410NE." DigiKey. N.p.. Web. 29 Jan 2014. <http://www.digikey.ca/product-

detail/en/SN754410NE/296-9911-5-ND/380180>.

[10] "900 Series." DigiKey. N.p.. Web. 29 Jan 2014. <http://www.digikey.ca/product-

detail/en/SN754410NE/296-9911-5-ND/380180>.

Page 64: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

64

Appendix B: PIC16F877 Microcontroller Data Sheet http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010241

Page 65: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

65

Page 66: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

66

Page 67: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

67

Appendix C: SN754410 Data Sheet http://www.ti.com/lit/ds/symlink/sn754410.pdf

Page 68: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

68

Page 69: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

69

Page 70: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

70

Page 71: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

71

Page 72: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

72

Page 73: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

73

Page 74: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

74

Appendix D: 900 Series Detector Switch Data Sheet http://www.e-switch.com/product/tabid/96/productid/71/sename/900-series-sub-miniature-smt-detector-switch/default.aspx

Appendix E: PDV-P8103 Photoresistor Data Sheet http://www.advancedphotonix.com/ap_products/pdfs/PDV-P8103.pdf

Page 75: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

75

Appendix F: 74HC151 8-to-1 Multiplexers Data Sheet http://pdf1.alldatasheet.com/datasheet-pdf/view/15539/PHILIPS/74HC151.html

Page 76: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

76

Page 77: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

77

Page 78: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

78

Page 79: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

79

Page 80: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

80

Page 81: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

81

Page 82: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

82

Appendix G: NC7SB3157P6X 2-to-1 Multiplexer Data Sheet http://www.digchip.com/datasheets/parts/datasheet/161/NC7SB3157P6X-pdf.php

Page 83: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

83

Page 84: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

84

Page 85: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

85

Page 86: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

86

Page 87: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

87

Appendix H: Material Selection Material property of Common Material (http://www.engineeringtoolbox.com/engineering-materials-properties-d_1225.html)

Page 88: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

88

Appendix I: Weight Approximation

Estimation of Main Frame

Page 89: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

89

Weight Estimation of Lid

Page 90: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

90

Weight Estimation of Tray

Page 91: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

91

Estimation of Weight of Circuitry and Additional Support

Page 92: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

92

Appendix J: 131:1 DC Motor http://www.alibaba.com/product-gs/1316119297/zheng_dc_motor.html

Page 93: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

93

Appendix K: Assembly Code list p=16f877 ; list directive to define processor #include <p16f877.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF #include <lcd.inc> ;Import LCD control functions from lcd.asm #include <rtc_macros.inc> cblock 0x20 COUNTH ;0x20 COUNTM ;0x21 COUNTL ;0x22 Table_Counter ;0x23 lcd_tmp ;0x24 lcd_d1 ;0x25 lcd_d2 ;0x26 com ;0x27 dat ;0x28 TempReg ;Useful, don't remove 0x29 temp ;For PCLATH, don't remove 0x2A Counter ;0x2B Threshold ;0x2C Zero_Threshold ;0x2D Loop ;0x2E MUX_Selector ;0x2F LED_Counter ;0x30 dig1 ;0x31 dig10 ;0x32 Temp ;0x33 minute ;0x34 tenSecond ;0x35 oneSecond ;0x36 totalSecond ;0x37 First ;0x38 Second Third Fourth Fifth Sixth Seventh Eighth Nineth endc

Page 94: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

94

;Declare constants for pin assignments (LCD on PORTD) #defineRS PORTD,2 #defineE PORTD,3 ORG 0x0000 ;RESET vector must always be at 0x00 goto init ;Just jump to the main code section. ; Helper macro WRT_LCD macro val movlw val call WrtLCD endm ;Delay: ~160us LCD_DELAY macro movlw 0xFF movwf lcd_d1 decfsz lcd_d1,f goto $-1 endm AdjustPCL macro TableEntries local end_ movwf temp movlw HIGH TableEntries movwf PCLATH movf temp, w addlw LOW TableEntries btfsc STATUS, C incf PCLATH, f movwf PCL end_ endm ;*************************************** ; Delay for a controlled time macro ;*************************************** DelayS macro H_Value, M_Value, L_Value local DelayS_0_ movlw H_Value movwf COUNTH movlw M_Value movwf COUNTM movlw L_Value movwf COUNTL DelayS_0_

Page 95: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

95

decfsz COUNTH, f goto $+2 decfsz COUNTM, f goto $+2 decfsz COUNTL, f goto DelayS_0_ goto $+1 nop nop endm ;*************************************** ; Display macro ;*************************************** Display macro Message local loop_ local end_ clrf Table_Counter clrw loop_ movf Table_Counter,W call Message xorlw B'00000000' ;check WORK reg to see if 0 is returned btfsc STATUS,Z goto end_ call WR_DATA incf Table_Counter,F goto loop_ end_ endm ;*************************************** ; Initialize LCD ;*************************************** init clrf INTCON ; No interrupts bsf STATUS,RP0 ; select bank 1 movlw b'00000100' ;Set ADCON1 movwf ADCON1 movlw 0xFF movwf TRISA ; All ports are completely input movlw b'11110010' ; Set required keypad inputs movwf TRISB clrf TRISC clrf TRISD ; All port D is output

Page 96: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

96

;Set SDA and SCL to high-Z first as required for I2C bsf TRISC,4 bsf TRISC,3 bcf STATUS,RP0 ; select bank 0 clrf PORTA clrf PORTB clrf PORTC clrf PORTD ;Set up I2C for communication call i2c_common_setup ;rtc_resetAll ;Used to set up time in RTC, load to the PIC when RTC is used for the first time ;call set_rtc_time call InitLCD ;Initialize the LCD (code in lcd.asm; imported by lcd.inc) ;*************************************** ; Main code ;*************************************** Main call Welcome_Interface MainLoop call Key_Pressed goto MainLoop goto $ Key_Pressed btfss PORTB, 1 ;Wait until data is available from the keypad goto $-1 movf PORTB, W ;Read PortB into W movwf TempReg call Check_Which_Key btfsc PORTB,1 ;Wait until key is released goto $-1 return Check_Which_Key movlw b'00110010'

Page 97: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

97

xorwf TempReg, W btfss STATUS, Z goto $+2 call Key_A_Pressed movlw b'01110010' xorwf TempReg, W btfss STATUS, Z goto $+2 call Key_B_Pressed movlw b'00100010' xorwf TempReg, W btfsc STATUS, Z call show_RTC return Key_A_Pressed call Clear_Display Display Operation_Msg rtc_read 0x01 movfw 0x78 movwf minute rtc_read 0x00 movfw 0x77 movwf tenSecond movfw 0x78 movwf oneSecond ;rtc_set 0x00, B'00000000' ;starting counting time ;DelayS 0x08, 0xBD, 0x30 ;;;;Actually operations clrf LED_Counter call Turn_On_Lights call First_One call Second_One call Third_One call Fourth_One call Fifth_One call Sixth_One call Seventh_One call Eighth_One call Last_One call Turn_Off_Lights ;;;;; ;Get runtime in seconds call checkTimeElapsed

Page 98: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

98

;;;;;;; call Clear_Display call Finish_Interface return Key_B_Pressed call Clear_Display call Quality_Control_Interface call Clear_Display call Welcome_Interface return Turn_On_Lights bsf PORTD, 0 call Delay3S ;call Delay3S ;Delay for 200 ms pulse bcf PORTD, 0 DelayS 0x88, 0xBD, 0x03 ;delay for 0.5 second bsf PORTD, 0 call Delay3S ;call Delay3S ;Delay for 200 ms pulse bcf PORTD, 0 DelayS 0x88, 0xBD, 0x03 ;delay for 0.5 second bsf PORTD, 0 call Delay3S ;call Delay3S ;Delay for 200 ms pulse bcf PORTD, 0 DelayS 0x88, 0xBD, 0x03 ;delay for 0.5 second bsf PORTD, 0 call Delay3S ;call Delay3S ;Delay for 200 ms pulse bcf PORTD, 0 return First_One movlw b'000' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf First return call Set_Value1 ;Begin ADC movlw b'11001001'

Page 99: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

99

movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf First incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf First incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf First incf LED_Counter, F return movlw "P" movwf First incf LED_Counter, F return Second_One movlw b'001' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Second return call Set_Value2 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W

Page 100: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

100

subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Second incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Second incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Second incf LED_Counter, F return movlw "P" movwf Second incf LED_Counter, F return Third_One movlw b'010' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Third return call Set_Value3 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5

Page 101: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

101

movlw "F" movwf Third incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Third incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Third incf LED_Counter, F return movlw "P" movwf Third incf LED_Counter, F return Fourth_One movlw b'011' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Fourth return call Set_Value4 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Fourth incf LED_Counter, F

Page 102: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

102

return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Fourth incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Fourth incf LED_Counter, F return movlw "P" movwf Fourth incf LED_Counter, F return Fifth_One movlw b'100' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Fifth return call Set_Value5 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Fifth incf LED_Counter, F return movlw b'01100101' xorwf Counter, W

Page 103: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

103

btfss STATUS, Z goto $+5 movlw "O" movwf Fifth incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Fifth incf LED_Counter, F return movlw "P" movwf Fifth incf LED_Counter, F return Sixth_One movlw b'101' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Sixth return call Set_Value6 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Sixth incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O"

Page 104: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

104

movwf Sixth incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Sixth incf LED_Counter, F return movlw "P" movwf Sixth incf LED_Counter, F return Seventh_One movlw b'110' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Seventh return call Set_Value7 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Seventh incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Seventh incf LED_Counter, F return

Page 105: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

105

movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Seventh incf LED_Counter, F return movlw "P" movwf Seventh incf LED_Counter, F return Eighth_One movlw b'111' movwf PORTC call Delay3S btfss PORTA, 2 goto $+2 goto $+4 movlw "A" movwf Eighth return call Set_Value8 ;Begin ADC movlw b'11001001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Eighth incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Eighth incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z

Page 106: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

106

goto $+5 movlw "O" movwf Eighth incf LED_Counter, F return movlw "P" movwf Eighth incf LED_Counter, F return Last_One btfss PORTA, 5 goto $+2 goto $+4 movlw "A" movwf Nineth return call Set_Value9 ;Begin ADC movlw b'11011001' movwf ADCON0 call AD_CONV movf ADRESH, W subwf Zero_Threshold, W btfss STATUS, C goto $+5 movlw "F" movwf Nineth incf LED_Counter, F return movlw b'01100101' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Nineth incf LED_Counter, F return movlw b'00000001' xorwf Counter, W btfss STATUS, Z goto $+5 movlw "O" movwf Nineth incf LED_Counter, F return movlw "P"

Page 107: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

107

movwf Nineth incf LED_Counter, F return Turn_Off_Lights bsf PORTD, 1 call Delay3S ;call Delay3S bcf PORTD, 1 DelayS 0x88, 0xBD, 0x03 ;delay for 0.5 second bsf PORTD, 1 call Delay3S ;call Delay3S bcf PORTD, 1 return ;*************************************** ; Look up table ;*************************************** Welcome_Msg AdjustPCL Welcome_Msg1 Welcome_Msg1 dt "CNDL Automaton", 0 Info_Msg AdjustPCL Info_Msg1 Info_Msg1 dt "Start: press <A>", 0 Operation_Msg AdjustPCL Operation_Msg1 Operation_Msg1 dt "Operating...", 0 Done_Msg AdjustPCL Done_Msg1 Done_Msg1 dt "Done! Start: <A>", 0 Done_Msg2 AdjustPCL Done_Msg21 Done_Msg21 dt "Info.: press <B>", 0 QC_OpTime AdjustPCL QC_OpTimeMsg

Page 108: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

108

QC_OpTimeMsg dt "Runtime(s):", 0 QC_Number AdjustPCL QC_NumberMsg QC_NumberMsg dt "LEDs:", 0 QC_Functionality AdjustPCL QC_FunctionalityMsg QC_FunctionalityMsg dt "States:", 0 ;*************************************** ; LCD control and display ;*************************************** Welcome_Interface Display Welcome_Msg call Switch_Lines Display Info_Msg return Finish_Interface Display Done_Msg call Switch_Lines Display Done_Msg2 return Quality_Control_Interface Display QC_OpTime call Switch_Lines movfw totalSecond call BCD_Converter movfw dig10 call WR_DATA movfw dig1 call WR_DATA ; movfw RT1 ; call WR_DATA ; movfw RT2 ; call WR_DATA btfss PORTB,1 ;Wait until data is available from the keypad goto $-1 call Clear_Display Display QC_Number

Page 109: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

109

call Switch_Lines movfw LED_Counter call BCD_Converter ;movfw dig10 ;call WR_DATA movfw dig1 call WR_DATA ;Need to display BCD counter number DelayS 0x01, 0x7A, 0x01 ;Adding a small delay to prevent user from pressing too long btfss PORTB,1 ;Wait until data is available from the keypad goto $-1 call Clear_Display Display QC_Functionality call Switch_Lines ;Hard code to display all 9 reg values movfw First call WR_DATA movfw Second call WR_DATA movfw Third call WR_DATA movfw Fourth call WR_DATA movfw Fifth call WR_DATA movfw Sixth call WR_DATA movfw Seventh call WR_DATA movfw Eighth call WR_DATA movfw Nineth call WR_DATA DelayS 0x01, 0x7A, 0x01 btfss PORTB,1 ;Wait until data is available from the keypad goto $-1 return Switch_Lines movlw B'11000000' call WR_INS return Clear_Display

Page 110: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

110

movlw B'00000001' call WR_INS return ;******* LCD-related subroutines ******************************* ;************************************ ;WrtLCD: Clock MSB and LSB of W to PORTD<7:4> in two cycles WrtLCD movwf lcd_tmp ; store original value call MovMSB ; move MSB to PORTD call ClkLCD swapf lcd_tmp,w ; Swap LSB of value into MSB of W call MovMSB ; move to PORTD call ClkLCD return ;ClkLCD: Pulse the E line low ClkLCD LCD_DELAY movwf PORTD bcf E LCD_DELAY movwf PORTD ; __ __ bsf E ; |__| return ;**************************************** ;MovMSB: Move MSB of W to PORTD, without disturbing LSB MovMSB andlw 0xF0 iorwf PORTD,f iorlw 0x0F andwf PORTD,f return ;**************************************** ;The following 3 methods are for ADC conversion AD_CONV bsf ADCON0, GO ;start conversion and wait for it to complete btfsc ADCON0, GO goto $-1 movf ADRESH, W subwf Threshold, W btfss STATUS, C goto $+2 goto $+3

Page 111: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

111

decf Counter, F goto $+2 incf Counter, F call Delay1HalfS movlw b'00110001' xorwf Loop, W btfss STATUS, Z goto $+2 goto $+3 incf Loop, F goto AD_CONV return Set_Value1 movlw b'00110011' movwf Counter ;51 sample points movlw b'10001101' ;2.77V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value2 movlw b'00110011' movwf Counter ;51 sample points movlw b'10101000' ;3.3V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value3 movlw b'00110011' movwf Counter ;51 sample points movlw b'10011011' ;3.04V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return

Page 112: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

112

Set_Value4 movlw b'00110011' movwf Counter ;51 sample points movlw b'10001111' ;2.80V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value5 movlw b'00110011' movwf Counter ;51 sample points movlw b'10101011' ;3.36V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value6 movlw b'00110011' movwf Counter ;51 sample points movlw b'10101000' ;3.3V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value7 movlw b'00110011' movwf Counter ;51 sample points movlw b'10001111' ;2.81V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value8 movlw b'00110011'

Page 113: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

113

movwf Counter ;51 sample points movlw b'10010001' ;2.84V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Set_Value9 movlw b'00110011' movwf Counter ;51 sample points movlw b'10110011' ;3.47V movwf Threshold movlw b'01001100' movwf Zero_Threshold ;1.5V movlw b'000000' movwf Loop return Delay1HalfS ;Delay for 30 ms call TenMs call TenMs call TenMs return Delay3S ;Delay for 100 ms call TenMs call TenMs call TenMs call TenMs call TenMs call TenMs call TenMs call TenMs call TenMs call TenMs return TenMs movlw 0x86 movwf COUNTH movlw 0x14 movwf COUNTL TenMs_0 decfsz COUNTH, F

Page 114: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

114

goto $+2 decfsz COUNTL, F goto TenMs_0 goto $+1 nop return Delay3S2 ;Delay for 50 ms call TenMs call TenMs call TenMs call TenMs call TenMs return ;**************************************************** ;The following code is responsible for displaying BCD numbers on LCD BCD_Converter movwf dig1 clrf dig10 movlw 0xA subwf dig1, F btfss STATUS, C goto Divide_Done incf dig10 goto $-4 Divide_Done addwf dig1, F movlw 0x30 addwf dig10, F addwf dig1, F return ;**************************************** ;Displays the current date and time show_RTC ;clear LCD screen movlw b'00000001' call WR_INS ;Get year movlw "2" ;First line shows 20**/**/** call WR_DATA movlw "0" call WR_DATA ;call set_rtc_time

Page 115: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

115

rtc_read 0x06 ;Read Address 0x06 from DS1307---year movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw "/" call WR_DATA ;Get month rtc_read 0x05 ;Read Address 0x05 from DS1307---month movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw "/" call WR_DATA ;Get day rtc_read 0x04 ;Read Address 0x04 from DS1307---day movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw B'11000000' ;Next line displays (hour):(min):(sec) **:**:** call WR_INS ;Get hour rtc_read 0x02 ;Read Address 0x02 from DS1307---hour movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw ":" call WR_DATA ;Get minute rtc_read 0x01 ;Read Address 0x01 from DS1307---min movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw ":"

Page 116: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

116

call WR_DATA ;Get seconds rtc_read 0x00 ;Read Address 0x00 from DS1307---seconds movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA DelayS 0x10, 0x7A, 0x06 ;Delay for exactly one seconds and read DS1307 again btfss PORTB,1 ;Wait until data is available from the keypad goto show_RTC call Clear_Display call Welcome_Interface return ;*************************************** ; Calculates operation time ;*************************************** multiplyBy macro times ; times: *60, times = 59 movwf Temp addwf Temp, 1 ;placed back to Temp decfsz times, F ; if f is subtracted to 0, pass goto $-2 endm multiplyByTen movwf Temp addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 addwf Temp, 1 movfw Temp return multiplyBySix movwf Temp addwf Temp, 1 addwf Temp, 1 addwf Temp, 1

Page 117: INSTITUTE FOR AEROSPACE STUDIES -   · PDF fileInstitute for Aerospace Studies 4925 Dufferin Street, ... are LED turns on and flickers, ... a rotating disk, and two metal shafts

117

addwf Temp, 1 addwf Temp, 1 movfw Temp return checkTimeElapsed ; first check the minute by subtract them clrf totalSecond ; init the register ;Get minute rtc_read 0x01 ;Read Address 0x01 from DS1307---min movfw 0x78 ; minute right now movwf Temp movfw minute ; minute read when starting in W subwf Temp, w ; place the result in w call multiplyByTen call multiplyBySix ; time the minute by 60 -> second in W movwf totalSecond ; calculate second rtc_read 0x00 ; read the seconds movfw 0x77 ; 10digit to w movwf Temp movfw tenSecond subwf Temp, W ; place the result in w call multiplyByTen addwf totalSecond, F movfw 0x78 ; 10digit to w movwf Temp movfw oneSecond subwf Temp, W ; place the result in w addwf totalSecond, F return END