FINAL Lab Report Card Scanner

24
ECE 388- Digital Electronics Fall 2014 Final Report on: Key Card Entry Lock Embedded System By signing, I certify that I have contributed to and read this report, understand and approve of its contents and that all data in it is valid. Brett Southworth___________________________ Alexander Grube___________________________ Date Submitted: December 11 th , 2014

Transcript of FINAL Lab Report Card Scanner

Page 1: FINAL Lab Report Card Scanner

ECE 388- Digital ElectronicsFall 2014

Final Report on:

Key Card Entry Lock Embedded System

By signing, I certify that I have contributed to and read this report, understand and approve ofits contents and that all data in it is valid.

Brett Southworth___________________________

Alexander Grube___________________________

Date Submitted: December 11th, 2014

Page 2: FINAL Lab Report Card Scanner

Contents

1 Introduction 2

2 Methods 3

2.1 …............................................................................................................................ 32.2 …............................................................................................................................ 52.3 …............................................................................................................................ 72.4 …............................................................................................................................ 92.5 …............................................................................................................................ 11

3 Discussion 14

5 Appendix 15

1

Page 3: FINAL Lab Report Card Scanner

Abstract

In this project, a magnetic card scanner is used to actuate a locking mechanism and open an electric strike. This kind of technology is widely in use all across the world as a means of securing restricted areas or restricting access to secure information. The system is designed to run off of a typical residential or commercial outlet, with the ability to store multiple card values for access. There is also functionality for an admin user to add or remove cards from the system, allowing for greater user control and more versatility in the marketplace. The system securely transmits information via a hardline PS/2 connection. This kind of card scanning system could be put to use in a number of different environments, though this particular one is programmed to work with UMass Dartmouth ID cards.

1 Introduction

The mission of this project was to complete the task given in our problem statement using a custom PCB and chosen parts, working with software and hardware to accomplish the task. As given in our Problem Statement (see Appendix B), our task was to create an embedded system that would wait until a card was swiped, then either grant the user access by actuatingan electric strike, or deny the user access by staying idle. This system was implemented via avigorous design process that will be documented in this report, and the final design meets every aspect of the given problem statement with additional functionality. All of the following criteria were considered during the design and construction process:

-The cost of chosen components-The time taken to build and design the system-The turnaround time for component ordering and shipping-Electrical constraints-Data handling and programming constraints and consideration-Noise reduction in circuit for ideal data and power transmission

Detailed in this report are the final schematic designs for the actuator circuit, the power delivery system, the serial communication hardware, and flowcharts for all software systems and drivers. The report also contains an overall look at the system and how each subsystem reacts to tests in a test matrix. Finally, the report gives reflection on the project and discussionon ways to improve the design process that was used.

2

Page 4: FINAL Lab Report Card Scanner

2 Methods

The project included the building and testing of each component of the final system individually, and the system itself as a whole. Each system was designed seperately, but with consideration of the other connecting systems. For example, the power distribution system was designed as a discrete unit, but still made use of the power requirements of 3.3V and 5V rails when designed.

2.1 Power Distribution

Tools Used:

-PCB-120V AC in / 12V DC out power converter-12V in / 3.3 and 5V out power regulator-Green LEDs

The power distribution system was demonstrated to be functional with separate power supplies in a breadboard environment. However, when using a voltage regulator to provide the needed 5V line to the serial converter, and utilizing the PCB traces to distribute power, thesystem was not providing any power at all. For testing purposes, this design was called Iteration 1 (It. 1) and documented in our test matrix.

The first modification made upon closer inspection was a swap of the GND and 12V routes from the power connector. The schematic had been interpreted wrong and, therefore, the 12Vand GND pins were opposite. The traces on the board were cut, wires were soldered to reroute power, and the system was tested again for Iteration 2 (It. 2).

There was slightly more functionality on Iteration 2, but the system was still not adequately providing power, due to a short that was found between the 5V and 3.3V pins of the voltage regulator. This was fixed by cutting the traces and unshorting the pins, replacing those traces with wires that crossed, as the datasheet for the regulator was misleading and the 3.3V and 5V lines were actually swapped. After implementing these fixes, the system was tested as Iteration 3 (It. 3)

Unfortunately, during the testing of the power distribution system, the 5V input of the Serial converter was loaded with 12V and shorted the converter subsystem, prompting a rush order of a replacement board. With the replacement part in place, the system was functioning as expected.

Results of the tests done are shown in a Test Matrix (Table 1).

The power distribution schematic is shown in Fig. 1.

3

Page 5: FINAL Lab Report Card Scanner

Table 1: Power Distribution Test MatrixTest Description It. 1 It. 2 It. 3

12V Power to Voltage Reg. FAIL PASS PASS

5V present on pin 4 FAIL FAIL PASS

3.3V present on pin 6 FAIL FAIL PASS

GND to pin 2 FAIL PASS PASS

12V to pin 1,3,5 FAIL FAIL PASS

5V to serial converter Not Tested Not Tested PASS

12V to actuator Not Tested Not Tested PASS

Conclusions and Additions Reverse polarity of power plug

Unshort and reroute power via wires

System working properly.

4

Page 6: FINAL Lab Report Card Scanner

Fig. 1 – Actuator Circuit

2.2 Actuator Circuit

Tools Used:

-MOSFET Transistor-12V Power Supply-Multimeter-Electric Strike-Diode

The actuation system was demonstrated to be functional in a breadboard environment, with a transistor accepting a signal from the microcontroller and connecting the 12V signal to groundthrough the electric strike.

When mounted on the PCB, the system didn't function as planned, with the electric strike not closing when a timed test signal was sent from the microcontroller. This test was called Iteration 1 and logged in the Test Matrix.

To fix the issue, the design and construction were inspected carefully, and it was discovered that the transistor was put in backwards, giving incorrect bias and not successfully closing thecircuit. The transistor was re-soldered correctly, and the circuit was tested again for Iteration 2.

Results of the tests done are shown in a Test Matrix (Table 2).

The actuator circuit schematic is shown in Fig. 2.

5

Page 7: FINAL Lab Report Card Scanner

Table 2: Actuator Test MatrixTest Description It. 1 It. 2

12V Power to Actuator PASS PASS

Transistor connected to ground and actuator PASS PASS

Transistor correctly biased FAIL PASS

Signal supplied to gate of transistor PASS PASS

Conclusions and Additions Reverse polarity of MOSFET.

System working properly.

Fig. 2 – Actuator Schematic

6

Page 8: FINAL Lab Report Card Scanner

2.3 Serial Conversion and Transmission

Tools Used:

-Card Scanner-Propeller Microcontroller-Multimeter-PS/2 to Serial Data Converter

The Serial Input and Conversion System was shown to be working on a breadboard environment, but was not functional. After discussion, it was decided that this was a software issue that could be fixed at a later date for the purposes of time management. The components were mounted on the PCB and tested in Iteration 1.

(It should be noted that for the purposes of this report the PS/2 to Serial converter was already replaced from the applied over-voltage from section 2.1)

The data was successfully being sent from the scanner to the converter, and was being spit out along the data line to the Propeller microcontroller. Unfortunately, the data was not being read in correctly by the microcontroller, and therefore the system was not giving correct results. This led to debugging and fixing the software code to receive serial data. This was initially tried with SPI functionality, giving Iteration 2.

After the failure of iteration 2, it was discovered that the SPI functions for the Propeller chip required the use to a master clock signal from the microcontroller. In the design, it was marked out as using the clock pulse from the slave device. Next, an I2C process was implemented to avoid the clocking problems of the SPI interface. This is Iteration 3.

The I2C implementation of Iteration 3 was also a failure. The system would now successfully wait for a scanned card, but the data was incorrect. This was due to the lack of 2-way communication for the I2C bus, as the converter device is only one way. The next method tried was a Full-Duplex Serial connection using the Tx pin of the converter. This is Iteration 4.

Iteration 4 was a success. The system could read in data and store it to a string to be compared to a list of other strings. The programming for it was still a little off with timing, as the Propeller chip runs at a 5MHz clock, while the converter only works at 115k. Pause statements between each read took care of this issue pretty easily.

Results of the tests done are shown in a Test Matrix (Table 3).

The actuator circuit schematic is shown in Fig. 3.

Final code is shown in Appendix A.

7

Page 9: FINAL Lab Report Card Scanner

Table 2: Firmware Test MatrixTest Description It. 1 It. 2 It. 3 It. 4

5V to power pin PASS PASS PASS PASS

3.3V out of power out PASS PASS PASS PASS

Data Read (LED) PASS PASS PASS PASS

Data Sent PASS PASS PASS PASS

Data Read by Microcontroller FAIL FAIL FAIL PASS

Conclusions and Additions Hardware working.Implement SPI.

SPI fail, try I2C config.

I2C Failure. Try Full Duplex Serial.

Functioning asexpected.

Fig. 4 – Serial Communication Logic

8

Page 10: FINAL Lab Report Card Scanner

2.4 State Machine Design

The operating system of the embedded system is a finite state machine, where the system has multiple states that exist in a cycle, as shown in Fig. 5 below.

Fig. 5 – Finite State Machine for Card Swipe System

The machine has 4 states that it operates between, with changes triggered by events.The machine however is only an overview. For a more precise look at the events in each state, flowcharts can be used.

Flowcharts for the Data Acquisition, Data Check, and Actuation are shown over the next few pages in Fig. 6-8.

9

Page 11: FINAL Lab Report Card Scanner

Fig. 6 – Data Acquisition Flowchart Fig. 7 – Data Check Flowchart

10

Page 12: FINAL Lab Report Card Scanner

Fig. 8 – Actuation Flowchart

2.5 PCB Design

The PCB fabriction for this project ran into minor difficulties, both on the development front and with time limitations. As far as development goes, PADS was not a very helpful tool when it came to generating the Gerber files for fabrication, and compatibility issues between different versions of PADS kept productivity to a minimum when trying to work on the project using multiple machines. Figure 9 shows the final layout of the board, as rendered by PADS.

Fig. 9 – Final PCB Layout

11

Page 13: FINAL Lab Report Card Scanner

Fabrication was delayed by about 2 weeks due to miscommunication and the turnaround timewas higher than expected. When the board was finally received and populated, it looked as shown below, in Figure 10.

Fig. 10 – Populated PCB, Iteration 1.

Of course, as shown in the testing procedures earlier in this report, modifications needed to be made to make the design functional. The finished and functioning board is shown in Figures 11 and 12.

12

Page 14: FINAL Lab Report Card Scanner

Fig. 11 – Working System PCB (Top)

13

Page 15: FINAL Lab Report Card Scanner

Fig. 11 – Working System PCB (Bottom)

Note the attached jumper wires and cut traces especially in the power regulation area.

3 Discussion/Reflection

This project was an essential experience in real-life problem solving and engineering. The creation of an embedded system from scratch is one of the most useful things done at school and prepares students for actual problem solving skills and application that are indispensable in the workplace.

The system performs to specifications, but doesn't save the program and data to the on boardEEPROM, as there was a shortage of time before deadline. Hopefully that will be working in the next release for full functionality.

This project was designed to Time, Capitol, and Fabrication specifications, yielding an efficient product that completes the task given in the problem statement.

14

Page 16: FINAL Lab Report Card Scanner

5 Appendix

Appendix A – Full Software Code and Additional Pictures.

Source Code for Serial Read and Compare:

#include "simpletools.h" //Include simple tools

#include "fdserial.h" //Include serial communication functions

char c[10];int counter=0;void ResetVar(void);char File[100]; //Holds 10 people at 10 slots of info for eachint Known(char in[]); //The proto-typed functionchar Admin[10];int AddP(void);

int main() // Main function{

memset(File,'L',100);//Setting the Admin ID for possible later useAdmin[0] = ';';Admin[1] = '8';Admin[2] = '0';Admin[3] = '1';Admin[4] = '2';Admin[5] = '6';Admin[6] = '1';Admin[7] = '3';Admin[8] = '0';Admin[9] = '3';

/***************/File[10] = ';';File[11] = '8';File[12] = '0';File[13] = '1';File[14] = '3';File[15] = '3';File[16] = '7';File[17] = '2';File[18] = '2';File[19] = '6';printf("File[0] = %c\n",File[0]);while(1){

fdserial *term = fdserial_open(1,-1,0,115200); //Opens serial connection to propellerprintf("Ready\n");while(counter < 10)

15

Page 17: FINAL Lab Report Card Scanner

{c[counter] = fdserial_rxChar(term); //Read in serial connection. Also reads in as Char not single binary valuesif(c[counter] != -1) //If theres invalid data the c[counter] will be -1 else it is the first char read in{

printf("c = %c\n",c[counter]);counter++;

}}pause(300);//Bretts Test Codeint output = Known(c); //Enter the functionprintf("The returned value is %d\n\n",output); //Output resultsif(output == 0){

high(16);pause(4000);low(16);pause(100);

}printf("Sequence Complete\nResetting Variables\n\n");//pause(500);ResetVar();fdserial_close(term);pause(300);

}}

void ResetVar(void){

int i=0;for(i;i<11;i++){

c[i] = -1; //Default all c[i]'s to -1}counter = 0; //reset Counter

}

int Known(char in[]){

int i, Isadmin = 0,j=0,k=0,returned = 0;char Input[10]; //What card was swiped inchar temp[10]; //Used for getting values out of the array Filefor (i=0; i < 11; i++){

Input[i] = in[i]; //sets array input to what was passed into the function }if (!strncmp(Input, Admin, 10)) //Compair the inputted array to an admin ID

16

Page 18: FINAL Lab Report Card Scanner

{Isadmin = 1; //Set the Admin status bitprintf("Admin has been set\n");goto skip; //Skip to return a different value for admin control

}i = 0; //Reset the i variable for use belowwhile (i<111) //Below will check if the person is in the file or not{

for (j ; j < i + 10;j++){

if (k == 10) //k is used to write to the 11 slots in the array tempk = 0; //Every 11 slots it has to reset to 0

temp[k] = File[j]; //Copy the person from File and put it on tempk++;

}if (!strncmp(temp, Input,10)) //Does temp = input?{

return 0; //Match Found}i += 10; //offset by 11 so File is formatted as a new person every 11 array elements

}return 1; //Match Not Foundskip:returned = AddP();printf("\nReturned Value from AddP = %d\n",returned);return 3; //Admin exit (to be used possibly later?)

}

int AddP(void){

int i = 0,j=0, Count=0,loop = 0;int k[10];char temp[10];fdserial *term = fdserial_open(1,-1,0,115200); //Opens serial connection to propellor boardResetVar();printf("Port opened: %d\n",counter);while(counter < 10){

temp[counter] = fdserial_rxChar(term); //Read in serial connection.if(temp[counter] != -1) //If theres invalid data the c[counter] will be -1{

printf("c = %c\n",temp[counter]);counter++;

}}fdserial_close(term);pause(300);while(i<100){

if(j > 0 && Count == 0)

17

Page 19: FINAL Lab Report Card Scanner

{j = 0;i += 10;goto skip;

}if(File[i] == temp[j]) //Match found atleast once{

Count ++;k[loop] = i; //Copy the location the match was found atloop ++;

}else{

Count = 0; //No match was found so reset Countloop = 0; //Reset the loop modifier for ki++;

}if(Count == 10) //Person is in data base{

i = 0;while(i<11){

File[k[i]] = 'L';i++;

}printf("Person has been deleted\n");return 0; //Deletedskip:;

}}//ResetVar();printf("No match found\n");i = 0;while(File[i] != 'L' && i < 100){

printf("i = %d\n",i);i++;

}if(i == 100){

return 3; //Unable to add person. File is full}else //Add person to File{

File[i] = temp[0];File[i+1] = temp[1];File[i+2] = temp[2];File[i+3] = temp[3];File[i+4] = temp[4];File[i+5] = temp[5];

18

Page 20: FINAL Lab Report Card Scanner

File[i+6] = temp[6];File[i+7] = temp[7];File[i+8] = temp[8];File[i+9] = temp[9];printf("File[%d] = %c\n",i,File[i]);printf("Person Added: %s",temp);

}return 1; //No match found, Person added

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Additional Pictures

Close Up of the Power Regulator

19

Page 21: FINAL Lab Report Card Scanner

Actuator Side of the PCB

20

Page 22: FINAL Lab Report Card Scanner

Close Up of Conversion System

21

Page 23: FINAL Lab Report Card Scanner

Final Schematic For PCB Fabrication

22

Page 24: FINAL Lab Report Card Scanner

Appendix B – Additional Documents

Problem Statement

Team 5

Security System

Name(s): Alex Grube and Brett Southworth

Problem Statement

Many companies across the U.S require saftey and security but may not be able to afford it. A

cheap solution to this problem could be a security system created by team 5, a card checking system.

First the system would sit idle until a card was swiped through. Once a card was swiped through, the

information is decoded and sent to a microcontroller. From there, the microcontroller would check

memory and see if the inputted information matched. If there was a match, the microcontroller would

send out a signal to unlock the door (for testing purposes, the microcontroller will only light an LED).

If there was no match, the microcontroller would leave the door locked.

Uses for device:

- Offices

- Military buildings

- Medical Rooms

- Any building/room that requires a form of security

Device Features:

• Card reading capabilities

• Compairing inputted information to information stored in memory

23