Final Project

<

Final project video





1. Project Proposal:.

I am going to divide this section into three parts.

  • What I am going to do (Introduction).
  • Why I am going this (Problem statement).
  • Project Cost.

1.1. Introduction (what..?)

My Idea for final project is to design a purpose specific device which will replace manual paper work takes places in different recruitments tests, entrance test of many universities and colleges. This device will be given to the candidate appeared in the written test and questions will appear on the display of this device. This device will be connected to a local wifi from were it gets the relavent files at ones and store it in the internal memory of device.

1.2 Why I want to do this.

There are many testing service provider in pakistan, few are listed below.

  • National Testing Services founded by COMSATS
  • SIBA Testing Services by Sukkur IBA
  • Pakistan testing services by Higher education commission
  • Faderal public service commission.

1.2.1 Almost each of above Testing services conduct aleast 1 test per week, the number of students appared in one test are upto 20k (approx.), Now if a single question book contains 10 pages then we can thing that how much papers are used in one test only.

1.2.2 The second thing is security, if a test is conducted at many centers at the same time in the whole country then we need to move the question books atleast one day before. so its difficult to make sure that question books remain sealed till the start of the test.

1.2.3 The third and forth problem is printting of copies and checking, it is also difficult ot print that huge amount of papers and check all those.

1.2.4 Currently all of these testing are handling it by conducting (Multiple choice Question)MCQs based tests and checking it with OMR (optical mark recognition) machine and this OMR machine cost upto 20,000 USD.

1.2.5 And the last problem is impersonation

1.3 Proposed Solution.

To replace this completely manual system I just need to make a device that can handle MCQs, conduct the test and show the results to candidate and upload the result to a server again and use a fingerprint scanner in the device to encounter impersonation. This is the main idea for my final project.

1.3 how much will it cost?

Components Number of components * Price of components(Euro) Total price (Euro) link
E-paper Display
1 * 51
51
Click here for link
Resistive touch
1 * 6.15
6.5
Click here for link
Wifi (ESP8266)
1 * 2
1.45
Click here for link
3.7 Lipo battery
1 * 5
5
Click here for link
microSD card
1 * 1.5
1.5
click here for link
ATMEGA32u4
1 * 3
3
www.digikey.es
Regulator (3.3V)
1 * 0.1
0.1
www.digikey.es
MCP73831T-2A (lipo charging IC)
1 * 0.5
0.5
www.digikey.es
LEDs
10 * 0.1
1
click here for link
Capacitors
10 * 0.1
1
click here for link
Resistors
20 * 0.1
2
www.digikey.es
USB mini connector
2 * 0.5
1
www.digikey.es
PLA 3D printed pieces
20Euro/kg required 100g.
2
www.digikey.es
Finger printscanner
1 * 31 .
31
https://www.sparkfun.com/products/13007
Total Cost
--
105.7
--

2. Mainboard and Battery charger circuit Development.

2.1 Mainboard Development.

Now the next task is to develop and mainboard with ATMEGA328p or ATMEGA32u4. I decided to go with ATMEGA32u4 becasue it is more powerfull then ATMEGA32u4 in term of memory and interfaces, it also have USB interface which help to program it without any external FTDI cable or programmer.

There are lots of generic boards of ATMEGA32u4 on internet, but I was looking for a board with single layer PCB and which can be developed in our lab, so I started with FABLEO, which can be found here

I rearranged the board to make it smaller and made some changes (takeout pins for serial communication and I2C) and made it as per my requirements. This was not an easy take to take out track and do manual routing, but finally I managed.

After desiging board, the next task is to create the rml files from fabmodule.org and mill the board using Rolland SRM-20 machine. We can find more details of this step in week 4, but one think to remember is that we can not mill the fableo board with 1/64 tool size, we need to use 0.254mm tool to mill this board. Few images of this process are given below.

I mill the board straight with 0.01 inche tool size, and the following image shows the result after milling.

Apparently board looks good, but it yes really difficult to solder it. Because of very small clearance, soldering the conponents on the board becomes really difficult. I realised that most of the copper on board was short with one another. After spending a long time in debuging I decided to remill the board.

I will suggest to those who wants to mill such boards, mill the board with 1/64 tool and then mill the board again with 0.01 tool, otherwise you will waste your time and energy while soldering the board. Milling the same board twice with 1/64 and then 0.01 tool will give you excellent results and soldering with become comparatively easy.

While milling the board second time I first used the 1/64 tool and then 0.01 tool and the results were awesome.

Now it is turn to solder the components again on the new board. Following image shows the list of components required.

After soldering and debuging the board its time to program it.

I programmed the board using Arduino IDE. Simply connect the board with your PC using USB cable, the operating system of PC will install some drivers of ATMEGA32u4. After that open Arduino IDE and select the board Arduino Leonardo becasue Leonardo board contains ATMEGA32u4, and then upload the board loader. It will take your seconds and then try to burn blink example. If every thing goes well you will see the board as shown in picture given below.

If every thing goes well you will see the board as shown in picture given below.

3. Interfacing E-paper Display.

Connecting E-paper Display module with microcontroller board.

Now this is the main task to interface EPD with microcontroller board. For that the first thing we need to do is to make connections as given in table below.

Mainboard Pins 4.3inch e-paper wires
5V
Red
GND
Black
RX/D0
White
TX/D1
Green
D4
Yellow
RST (or keep unconnected)
Blue

The next thing to Program the board, for that it is better to test the demo first. After adding the library of EPD module then you can find the Demo program in Examples. As shown in figure given below.

Before uploading the program following please remember to do the following things.

  • As the Demo program is for arduino uno (Atmega328p) and I am using ATMEGA32U4 so we need to changes the pins as given in table above in this section.
  • Simply changing the pins will not work, because there are two serial ports in ATMEGA32u4. We need to make some changes in library of EPD that we have added. For that go to next step
  • Find the Arduino library folder in your computer, in my PC it is there (C:\Users\Sohail\Documents\Arduino\libraries\LibraryEPD-master).
  • Now here we need to find the file "epd.cpp". If you are unable to find file location simply search the file in your C: drive.
  • Open the file in notepad or notepad++ or in anyother relavent software and Search for "Serial" and replace it by "Serial1", because in ATMEGA32U4 the default serial port is used for communication with the Arduino IDE. We need to use another port to communicate with EPD module
  • You can also download updated library for this EPD module that will work on Leonardo or this main board at the end of this page.
  • Now save the file and upload the demo example sketch.

After following all above steps you will be able see the output on your EPD as shown in the video given below

Now I need to write my program to show some different images and text.

Text is pretty straightforward, we can use the function "epd_disp_string("text here", X, Y)" and we can use "epd_set_en_font(ASCII32)" for fonts size. so far we this module has three fonts size by default in its Memory, that is ASCII32, ASCII48 and ASCII64.

To display images we need to follow the following steps.

  • Make sure the resolution of the image is less than 800x600 pixels. Start the tool mspaint.exe on Windows to open the image to be converted;
  • Select the option 24-bit bitmap in the Save as Type list, to save the image as a bmp format file
  • Start the software tool provided by Waveshare: uC-GUI-BitmapConvert.exe
  • Click File -> Open, and select the bitmap image you want to convert
  • Click Image -> Convert Into -> Gray4 (2 BPP);
  • Click File ->Save As, and select the option Windows Bitmap file(*.bmp) in the Save as Type list, and then enter a correct file name and save the image.
  • Conditions for correct file name: The name of the image should be in uppercase English character(s) with the length less than 10 characters (the symbol “.” is included). And the string length of the image name should be less than 11 characters, in which the ending “0” is included.
  • Store that image in microSD card and put this microSD card into the module.
  • microSD card must be FAT32 format.
  • Do the same with all the image file you want to show on the EPD module.

After following the all above steps you can use the function "epd_disp_bitmap("file_name", X, Y)" in your program to display the image.

For further details of function and commands please go through the tutorial of EPD module attached at the end of the page.

4. Interfacing Resistive touch and light sensor

4.1 Resistive touch interfacing.

For interfacing resistive touch I am using the same microcontroller board that I have made in assignment 10.

The first thing we need to know is the pinout of touch, I found this (http://blog.circuits4you.com/2015/06/4-wire-touch-screen-interfacing-with.html) tutorial very helpfull to find the pinout.

Now the next thing is we need is a library which help us to interface it. I tried lot of library and this (https://github.com/adafruit/Touch-Screen-Library) one works, There is an example in this library which will give you the raw and rough X and Y positions and then you need to program it further for you use. I have use this library to make 16 touch points as shown in video at the top of this page and the program that I have written is attached at the end of this page.

I have connected 4 wires of touch with 4 analog inputs of microcontroller.

Touch Pins ATmega32u4 pins
X1 (right most)
A0
X2(Second from right)
A1
Y1(2nd from left)
A2
Y2 (left most)
A3

Using the program given below.

#include <stdint.h>
#include "TouchScreen.h"
#define YP A0
#define XM A1
#define YM A2
#define XP A3
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 250);
int pxvalue = -1;
int pyvalue = -1;
void setup(void) {
Serial.begin(9600);
Serial1.begin(115200);
} void loop(void) {
TSPoint p = ts.getPoint();
if ((p.z > (ts.pressureThreshhold))) {
int xvalue = p.x/200;
int yvalue = p.y/200;
if (pyvalue != yvalue || pxvalue != xvalue)
{ pyvalue = yvalue;
pxvalue = xvalue;
switch (yvalue) {
case 1: // your hand is on the sensor
switch (xvalue) {
case 1: // your hand is on the sensor
Serial.println("0");
break;
case 2: // your hand is close to the sensor
Serial.println("1");
break;
case 3: // your hand is a few inches from the sensor
Serial.println("2");
break;
case 4: // your hand is nowhere near the sensor
Serial.println("3");
break; }
break;
case 2: // your hand is close to the sensor
switch (xvalue) {
case 1: // your hand is on the sensor
Serial.println("4");
break;
case 2: // your hand is close to the sensor
Serial.println("5");
break;
case 3: // your hand is a few inches from the sensor
Serial.println("6");
break;
case 4: // your hand is nowhere near the sensor
Serial.println("7");
break; }
break;
case 3: // your hand is a few inches from the sensor
switch (xvalue) {
case 1: // your hand is on the sensor
Serial.println("8");
break;
case 2: // your hand is close to the sensor
Serial.println("9");
break; case 3: // your hand is a few inches from the sensor
Serial.println("10");
break;
case 4: // your hand is nowhere near the sensor
Serial.println("11");
break; }
break;
case 4: // your hand is nowhere near the sensor
switch (xvalue) {
case 1: // your hand is on the sensor
Serial.println("12");
break;
case 2: // your hand is close to the sensor
Serial.println("13");
break;
case 3: // your hand is a few inches from the sensor
Serial.println("14");
break;
case 4: // your hand is nowhere near the sensor
Serial.println("15");
break; }
break;
}
}
} // touch function ends here
}

Following video is showing the result of resistive touch interfacing.

4.2 PCB Design for phototransistor and buttons.

I have designed the PCB by conserding the requirment of my final project. All the components connected will be use for my final project. Following image shows the circuit.

After designing the PCB, next step is to generate RML files for rolland SRM-20.

List of components used.

  • R1, R2, R3, R4, R5 and R6 = 10K ohm.
  • R7, R8 and R9 = 499 ohm.
  • 4 x Push buttons
  • 2 x Phototransistors
  • 1 SMD male header 1x8
  • 1 x LED
  • 2 x DIP LED
  • 1 SMD male header 1x2.

Here I am not using any microcontroller because I will use the arduino board (ATMEGA32U4) that I made in output assignment. For the details of that board please visit output assignment or my final project page.

Programming.

Following image shows the program and the output.

And here the video showing results of interfacing phototransistor.

5. Flash ESP8266 and configure it as TCP server.

  • Download the flash tool from this (https://github.com/nodemcu/nodemcu-flasher) link. and followed the instruction given on that page.

  • Here are few pictures of this process

  • We can also find the wiring circuit diagram to flash esp8266 from this (http://randomnerdtutorials.com/flashing-nodemcu-firmware-on-the-esp8266-using-windows/) link.

  • If every thing goes well you will see the some thing like image given below.

  • Now its turn to add ESP8266 library into arduino IDE. I can find the library from here (https://github.com/esp8266/Arduino). We can also find the instructions on this page. It is really usefull. it help me a lot.

  • Now after adding the library go the arduino and select the following setting to program ESP8266.

  • And Now I have written the following program in Arduino IDE to configure ESP8266 as TCP server.

    #include <ESP8266WiFi.h>
    const char* ssid = "Mypho";
    const char* password = "1234567890";
    const int ledPin = 2;
    WiFiServer server(1337);
    void printWiFiStatus();
    void setup(void) {
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    // Configure GPIO2 as OUTPUT.
    pinMode(ledPin, OUTPUT);
    // Start TCP server.
    server.begin();
    }
    void loop(void) {
    // Check if module is still connected to WiFi.
    if (WiFi.status() != WL_CONNECTED) {
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    }
    // Print the new IP to Serial.
    printWiFiStatus();
    }
    WiFiClient client = server.available();
    if (client) {
    Serial.println("Client connected.");
    while (client.connected()) {
    if (client.available()) {
    char command = client.read();
    Serial.print(command);
    }
    if (Serial.available() > 0) {
    char incomingByte = Serial.read();
    client.print(incomingByte);
    }
    }
    Serial.println("Client disconnected.");
    client.stop();
    }
    }
    void printWiFiStatus() {
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
    }
  • And thats all, we are done with flashing esp8266 and configuring it as tcp server.

  • I have already interfaced Resistive touch with Atmega32u4 in my input assignment, i will use the same setup as in input assignment and send the data from resistive touch to phone using esp8266. On wifi side every thing remains same as dicussed above this time I am sending the data instead of receiving.

  • Following video will show the results.

6. Embedded programming and Application development.

6.1 Application Development and testing.

  • Now I want to write the application which and send and get the data and make a TCP connection as well with given IP address. And also design it's interface.

  • The following video will show the work fellow of my application.

  • I am using python 2.7 for this application, the script is given below. This script is also attached at the end of this page.

    				
    from Tkinter import *
    import sys
    import socket
    import errno
    flag = False
    data = 0
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    datasent = ""
    
    def main_label():
        main_label =Label(text='TCP Client - Assignment 16', font = "Helvetica 16 bold " , bg='dark sea green').place(x=40,y=40)
    	
    def ip_label():
        myip_label =Label(text='IP', bg='dark sea green').place(x=20,y=115)
    	
    def port_label():
        myport_label =Label(text='Port', bg='dark sea green').place(x=20,y=145)
    
    def user0_label():
        user0_label =Label(text='Enter IP and port and click connect', bg='dark sea green').place(x=20,y=95)
    	
    def user1_label():
        user1_label =Label(text='Enter Data below to send', bg='dark sea green').place(x=20,y=205)
    
    def user2_label():
        user0_label =Label(text='Transmitted data', bg='dark sea green').place(x=20,y=250)
    	
    def user3_label():
        user1_label =Label(text='Received data', bg='dark sea green').place(x=20,y=360)
    	
    def user4_label():
        user1_label =Label(text='Designed by: Sohail Ahmed Soomro -- FAB LAB BCB', bg='dark sea green').place(x=20,y=480)
    	
    
    
    def button_action():
    	global datasent
    	text1= msg_input.get()
    	
    	sock.sendall(text1)
    	datasent = datasent + "\n" + text1
    	echo_win =Label(text=datasent,width=43,height=5,bg="#fff",bd=2,relief=SUNKEN).place(x=25,y=270)
    
    	msg_entry.delete(0,END)
    
        
    def button_action1():
    	data = sock.recv(100)
    	rcv_win = Label(text=data, width=43, height=5, bg="#fff", bd=2, relief=SUNKEN).place(x=25, y=400)	
        
    	
    def enter_action(self):
        button_action()
    
    def button_ip_action():
    	ip = ipinput.get()
    	myport = port_input.get()
    	print(sock.connect((ip,myport)))
    	
    	tk.after(100,recv_data)
    	
    def recv_data():
    	sock.setblocking(0)
    	try:
    		data = sock.recv(100)
    	except socket.error,e:
    		err = e.args[0]
    		if err== errno.EAGAIN or err ==errno.EWOULDBLOCK:
    			sleep(1)
    			print 'No data available'
    		else:
    			print e
    			sys.exit(1)
    	else:
    		print(data)
    		rcv_win = Label(text=data, width=43, height=5, bg="#fff", bd=2, relief=SUNKEN).place(x=25, y=400)
    	tk.after(100,recv_data)
    	
    tk = Tk()
    tk.geometry('400x500')
    tk.configure(background='dark sea green')
    tk.resizable(width=FALSE, height=FALSE)
    
    tk.title('Sohail_client')
    main_label()
    ip_label()
    port_label()
    user0_label() #show msg "Enter IP and port and click connect"
    user1_label() #show msg "Enter data below to send"
    user2_label() #show msg "Transmitted data"
    user3_label() #show msg "Received data"
    user4_label() #show msg "Designed by"
    
    
    ##### SET IP
    ipinput =StringVar()
    ip_entry= Entry(tk,textvariable=ipinput,width=20)
    ip_entry.place(x=50,y=115)
    
    
    ##### SET PORT
    port_input =IntVar()
    port_entry= Entry(tk,textvariable=port_input,width=20)
    port_entry.place(x=50,y=145)
    ip_Button = Button(tk,text='CONNECT', bd=0, bg="#FFBF00", activebackground="#FACC2E", command= button_ip_action).place(x=50,y=170)
    
    ##### SENDING MSG
    msg_input=StringVar()
    msg_entry= Entry(tk,textvariable=msg_input,width=35)
    msg_entry.bind("",enter_action)
    msg_entry.place(x=50,y=230)
    send_button = Button(tk,text='Send', bd=0, bg="#FFBF00", activebackground="#FACC2E", command= button_action).place(x=275,y=230)
    
    
    #### ECHO window. 192.168.1.106
    echo_win =Label(width=43,height=5,bg="#fff",bd=2,relief=SUNKEN).place(x=25,y=270)
    
    #### Receive window
    #recv_button = Button(tk,text='update buffer',bd=0, bg="#FFBF00", activebackground="#FACC2E", command= button_action1).place(x=275,y=360)
    rcv_win = Label(width=43, height=5, bg="#fff", bd=2, relief=SUNKEN).place(x=25, y=400)
    
    tk.mainloop()	
    							
    				
  • The big problem that I faced in writting this script is that I was unble to recived the data automatically, at the start I was using a button so that when it is pressed the action is called and in action I can display the data. but it is not a good strategy. data must be displayed automatically as it recived. To solve this problem I tried a lot using different techniques but finally I found a instruction in some forum regarding use of "sock.setblocking(0)", that help me a lot. There must be many ways to encounter this problem but I thought to mention here my experience as well.

  • Following picture shows the interface of my application

  • And the following video is showing the output and work flow of my application.

7. 3D Designing printing and lasercutting.

    I tried three time to make a case for my device, all three experiences are discussed below.

    This section is divided into three parts
  • 7.1 3D Designing and printing
  • 7.2 Laser cutting

7.1 3D Designing and printing

After taking measurements of all the components that I need to fit Inside the case I start desiging my model in Rhinoceros.

I started with the curves and then used Extrude, offset, boolean union and subtraction to make the complete model.

Following picture shows the my first design.

I place the model for printing in a way that i need less support, as shown in image given below. but I did not get the good quality output becuase the support was on outter side of the case, when I remove support It was not smooth.

After printing i found one mistake in design, there was no way to hold the Display in the case. so I designed again with support for display

And this time I putted it on print otherway around. In a way the support must be inside of the case and I can get outside with nice finishing.

Here is the result of my 2nd attempt

This time result was nice, but while removing the support from inside I broke locks of the device which make top and bottoms parts together, because the locks was very small in size, as we can see in the last image of above gif animation.

Now I decided to redesign the complete model again.

This time I make the 3d model of each of the circuit/component that need to be fit inside, then make the case.

This time I made a plan box design instead of curvy model as I was keep doing before.

There it goes for print

In my third design I thought to make the top side of the model by using laser cutter and acrylic sheet

8: Interfacing fingerprint scanner.

8.1 I am using Fingerprint Scanner - TTL (GT-511C1R). Here lots of material regarding this sensor is available.

8.2 Following video is helpful to understand that how can we use this sensor.

8.3 Its easy to store fingerprint images using this sensor with its Demo software for computer that is explained in the video above. we can download that software from Here. I also used this software to store fingerprint instead of getting it through arduino.

8.4 Here is the link of library that I used to interface this sensor with arduino. The complete arduino code of the project which also include the arduino for fingerprint scanner is attached at the end of this page.

8.5 Pinout of this sensor is very important. We can use the following image to know th correct pinout of this sensor.

8.6 Following video is showing the result.

Download All file of this project including Arduino, python, STL, dxf and eagle files from Here.

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

.