SlideShare a Scribd company logo
1 of 9
Download to read offline
Using microcontrollers and solid state sensors
Meirin Evans
9214122
School of Physics and Astronomy
The University of Manchester
Second Year Laboratory Report
May 2016
This experiment was performed in collaboration with John Cobbledick.
Abstract
Through using a microcontroller combined with electronic components, output voltage
measurements from various circuits were made. Along with a Radio Frequency Identifi-
cation Device (RFID), the microcontoller was used to convert the device’s binary reading
to an RFID tag’s individual number.

1. Introduction
Microcontrollers are small computers which are connected via Universal Serial Bus
(USB) to a larger computer which programs the microcontroller. They have an inbuilt
circuit board to connect to other electronic components enabling them to measure the out-
puts as well as control components. Microcontollers can be used in inductor/capacitor/
resistor circuits as well as with amplifiers, transistors and diodes. They can also be used
with an oscilloscope’s wave generator to produce a variety of voltages and the oscillo-
scope can measure the microcontroller’s output voltage. Solid state sensors are used
widely; examples include Radio Frequency Identification Devices (RFID), temperature
sensors, alcohol sensors, proximity sensors, range sensors, frequency to light converters
and gas sensors [1].
2. Theory
Microcontrollers can be used to construct a peak and hold circuit, shown in Figure 1. The
circuit includes an oscilloscope signal, a diode and a capacitor (with negative terminal
grounded) in series. A voltage reading is taken between the capacitor and diode. The cir-
cuit bears this name since the signal passes through the diode and charges the capacitor,
giving a voltage across it, but when the capacitor discharges no current can pass through
the diode in the other direction so it holds the same voltage. A higher capacitance means
a higher time constant (longer discharge time) so the peak is held for longer.
RFID tags have individual decimal numbers associated with them, for example school
cafeteria tags as illustrated in Figure 2. For cafeteria tags, this number may then be linked
to the holder’s name and balance, which could then be displayed on a screen. When a tag
is flashed within 1-2 cm of a sensor it reads the tag’s number as a series of binary bits
with different time lengths. This includes bits that notify the sensor as to when the signal
starts and ends. It is usually sufficient to flash the tag in front of the sensor. The binary
number is converted to hexadecimal (base 16) within the microcontroller, as shown in Ta-
ble 1. Converting the microcontroller output to a string using a programming language
gives the number in ASCII format. ASCII format is a system used by computers to dis-
!2
Reading
Fig 1. Circuit diagram for peak and hold. Includes an oscilloscope signal, a diode and a capacitor.
play characters like numbers, letters and punctuation or to give instructions to the com-
puter. Once the number is in ASCII it can be directly converted to decimal to give a
recognisable number.
A 5 digit (for example) hexadecimal ghijk is converted to decimal through Equation 1;
! .
The value of each digit is multiplied by increasing powers of 16 from the right,
where g through k can be 0-9 or A-F (corresponding to 10-15). In ASCII, a 2 indicates the
start of a signal whilst a 3 indicates the end. The last 2 digits in the hexadecimal number
kjihgghijk ++++= 16161616 234
!3
(1)
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
ASCII 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70
Table 1. Table showing binary, hexadecimal and ASCII equivalents for decimal 0-15.
Fig 2. Picture of RFID tags, like those used in school cafeterias [2].
are a checksum and are therefore ignored when calculating the decimal number. The first
2 digits are also ignored as these are only used to calculate the checksum. The checksum
is useful in verifying whether the information was correctly received. To do this, the tag
number’s hexadecimal digits are paired then an XOR operation is performed on all pairs
together. To understand an XOR operation numbers are converted to binary and the bina-
ry digits of the numbers are then compared. An XOR gives 1 if digits are different and 0
if they are the same, as illustrated in Table 2. If the XOR operations of all the pairs corre-
sponding to the tag number give the checksum, the data has been read correctly.
3. Experimental method
In the peak and hold circuit, capacitors of 1nF and 100nF were used to compare be-
haviour.
The microcontroller used was an Arduino UNO [3] board which could be programmed
using the Arduino language, which is similar to C. An RDM630 [4] operating at 125kHz
was used as an RFID sensor. Pictures of both are in Figure 2. The program converted the
ASCII characters read by the Arduino to tag number, which was then printed to the Ar-
duino’s serial port. The program also did the XOR operations to obtain the tag’s check-
sum and compared it with the read value. The program used to read the RIFD tags is in
the Appendix. Viewing the series of bits read by the sensor on an oscilloscope showed
that the first 2 digits of the hexadecimal number should be ignored in calculating the tag
number.
!4
Fig 2. Picture of an Arduino UNO board [5] (left). Picture of RFID sensor RDM630 [6] (right).
Table 2. Example of XOR operation on 2 hexadecimal numbers 3C and CC. The binary representations
are put in columns of decreasing powers of 2 for ease in calculating the result. 3C XOR CC gives F0.
Hexadecimal Decimal 27 26 25 24 23 22 21 20
3C 60 0 0 1 1 1 1 0 0
CC 204 1 1 0 0 1 1 0 0
F0 240 1 1 1 1 0 0 0 0
4. Results
Graphs of the input and output voltage shapes for both capacitors are shown in Figure 3.
The results from reading RFID tags are shown in Table 3. All the tags’ calculated check-
sums agreed with the initial reading.
A screenshot of an example output from the Arduino’s serial is shown in Figure 4. It
shows an introductory comment, the tag’s checksum, a statement saying whether the
checksum was read correctly and the tag’s number.
!5
Hexadecimal 3C00CC825725 3C00CEF5C3C4
ASCII 2 51 67 48 48 67 67 56 50
53 55 50 53 3
2 51 67 48 48 67 69 70 53
67 51 67 52 3
Tag number 13402711 13563331
Table 3. Table showing conversions from hexadecimal to ASCII to tag number for RFID tags.
0 2 4 6 8 10 12 14 16 18 20
0
.2
.4
.6
.8
1
.2
in
out
0 2 4 6 8 10 12 14 16 18 20
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
in
out
Voltage (V)
time (s) time (s)
Fig 3. Plots of input and output voltage against time. Left is 1nF, right is 100nF. 100nF holds the peak for
longer than 1nF.
5. Discussion
The main difficulty in converting the hexadecimal reading of an RFID tag to its tag num-
ber was in the step of converting hexadecimal to ASCII. Particularly troublesome was
splitting the whole hexadecimal number into its individual digits to then put into arrays.
Problems arose when trying to access array elements. To overcome this a do-while loop
was used to read the tag’s hexadecimal digits whilst a for loop was used to do conver-
sions, as opposed to a for loop for both.
Another detail requiring particular attention is the use of long format rather than int when
calculating the final number. The maximum decimal using int is 32767, obtained from
the fact that an int is held in 16 bits and 216 is 65536, but negative numbers as well as 0
need to be included. A long, however, is held in 32 bits and 232 is 4294967296, giving a
maximum long of 2147483647. The final tag numbers were between the maximum val-
ues of int and long therefore long was appropriate. Int was used in other steps to speed up
the program, though it probably did not change the speed much.
!6
Fig 4. Screenshot of the Arduino’s output on the serial for one of the tags used. Includes an introductory
comment, the tag’s checksum, a statement saying whether the checksum was read correctly and the tag’s
number.
6. Summary
Microcontrollers are very useful devices to manipulate electronic components, which are
themselves easily manipulable using programming. They are most useful when used with
solid state sensors to read, convert and output information from the sensors.
References
[1] Lalauze, R. & Pijolat, C., “A new approach to selective detection of gas by
an SnO2 solid-state sensor”, Sensors and Actuators, Volume 5, Issue 1, 1984.
[2] http://www.globalspec.com/learnmore/data_acquisition_signal_condition-
ing/data_input_devices/rfid_tags, RFID Tags Information, IHS Engineering360,
Accessed 30/03/2016.
[3] https://www.arduino.cc/en/Main/ArduinoBoardUno, Arduino UNO &
Genuino UNO, Arduino, Accessed 21/03/2016.
[4] http://www.seeedstudio.com/depot/datasheet/RDM630-Spec..pdf, RD-
M630 Specification, Seed Studio, Accessed 21/03/2016.
[5] https://www.arduino.cc/en/Guide/Windows, Getting Started with Arduino
and Genuino on Windows, Arduino, Accessed 21/03/2016.
[6] http://store.iteadstudio.com/index.php?main_page=product_info&product-
s_id=6, 125kHz RFID module RDM630 - UART, iStore, Accessed 21/03/2016.
The number of words in this document is 1547.
This document was last saved on 8/5/2016 at 21:31.
Appendix
// allow use of mySerial
#include <SoftwareSerial.h>
// use pin 10 on Arduino
SoftwareSerial mySerial(10, 11); // RX, TX.
// create arrays of ints
int fig[14];
int check[5];
// setup loop
void setup()
{
// Open hardware serial port for Serial Monitor.
!7
Serial.begin(9600);
// debug statement
Serial.println("RFID reader - simple test.");
// Set the baud rate for the SoftwareSerial port.
mySerial.begin(9600);
}
// main loop
void loop()
{
// initialise j
int j = 0;
// long format for tag num
long dec;
// do while loop for reading
do {
if (mySerial.available() > 0) {
fig[j] = mySerial.read();
j++;
}
} while (j < 14);
// for loop to do conversions
for (int i=0; i < 14; i++) {
if (fig[i] > 47 && fig[i] < 58) {
fig[i] = fig[i]-48;
}
else if (fig[i] > 64 && fig[i] < 71) {
fig[i] = fig[i]-55;
}
}
// for loop to pair digits
for (int k = 1; k < 12; k = k + 2) {
check[k]= fig[k]*16 + fig[k+1];
}
// initialise csum
int csum = 0;
// for loop for checksum
for (int h = 1; h < 10; h = h + 2){
csum = csum^check[h];
}
// print checksum
Serial.println(csum,HEX);
if (csum == check[11]) {
Serial.println("correct checksum");
}
!8
// calculate tag num
dec = fig[10] + fig[9]*16 + fig[8]*power(16,2) + fig[7]*power(16,3) +
fig[6]*power(16,4) + fig[5]*power(16,5);
// print tag num
Serial.println(dec);
}
// user defined power func
long power(int a, int b) {
long c = a;
for (int p = 0; p < b - 1; p++){
c = a*c;
}
return c;
}
!9

More Related Content

What's hot

Arduino Based Smart Home Automation System
Arduino Based Smart Home Automation SystemArduino Based Smart Home Automation System
Arduino Based Smart Home Automation Systemijtsrd
 
Hướng dẫn sử dụngTesto 174
Hướng dẫn sử dụngTesto 174 Hướng dẫn sử dụngTesto 174
Hướng dẫn sử dụngTesto 174 Tenmars Việt Nam
 
Atl equipment list_60_students
Atl equipment list_60_studentsAtl equipment list_60_students
Atl equipment list_60_studentsTapu Mon
 
Logic design and switching theory
Logic design and switching theoryLogic design and switching theory
Logic design and switching theoryjomerson remorosa
 
A Measurement Device for an Air Conditioning Unit
A Measurement Device for an Air Conditioning UnitA Measurement Device for an Air Conditioning Unit
A Measurement Device for an Air Conditioning UnitDoruk Angun
 
22 micropl csandhmi_04_21
22 micropl csandhmi_04_2122 micropl csandhmi_04_21
22 micropl csandhmi_04_21Oskitar Gabriel
 
Humidity and Temperature Measurement Using Arduino
Humidity and Temperature Measurement Using ArduinoHumidity and Temperature Measurement Using Arduino
Humidity and Temperature Measurement Using Arduinodollonhaider
 
Digital electronics nandhini kusuma
Digital electronics nandhini kusumaDigital electronics nandhini kusuma
Digital electronics nandhini kusumakusuma11
 
Design of a Digital Baseband Processor for UWB Transceiver on RFID Tag
Design of a Digital Baseband Processor for UWB Transceiver on RFID TagDesign of a Digital Baseband Processor for UWB Transceiver on RFID Tag
Design of a Digital Baseband Processor for UWB Transceiver on RFID Tagtheijes
 
Monitoring Temperature Room With Display LCD and Data Recording
Monitoring Temperature Room With Display LCD and Data RecordingMonitoring Temperature Room With Display LCD and Data Recording
Monitoring Temperature Room With Display LCD and Data RecordingMR Selamet
 
IRJET- Centralised Status alert system for industrial machines
IRJET-  	  Centralised Status alert system for industrial machinesIRJET-  	  Centralised Status alert system for industrial machines
IRJET- Centralised Status alert system for industrial machinesIRJET Journal
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ajit kumar singh
 
Logistics information monitoring by means of rfid sensor tag
Logistics information monitoring by means of rfid sensor tagLogistics information monitoring by means of rfid sensor tag
Logistics information monitoring by means of rfid sensor tagLihguong Jang
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ajit kumar singh
 
Design Efficient Wireless Monitoring Platform for Recycling Point Spots
Design Efficient Wireless Monitoring Platform for Recycling Point SpotsDesign Efficient Wireless Monitoring Platform for Recycling Point Spots
Design Efficient Wireless Monitoring Platform for Recycling Point SpotsIJMTST Journal
 
Octal to binary and octal to hexa decimal conversions
Octal to binary and octal to hexa decimal conversionsOctal to binary and octal to hexa decimal conversions
Octal to binary and octal to hexa decimal conversionsAfrasiyab Haider
 
Electronics Multisensor Shield
Electronics Multisensor ShieldElectronics Multisensor Shield
Electronics Multisensor ShieldLeopoldo Armesto
 

What's hot (20)

Arduino Based Smart Home Automation System
Arduino Based Smart Home Automation SystemArduino Based Smart Home Automation System
Arduino Based Smart Home Automation System
 
Hướng dẫn sử dụngTesto 174
Hướng dẫn sử dụngTesto 174 Hướng dẫn sử dụngTesto 174
Hướng dẫn sử dụngTesto 174
 
Atl equipment list_60_students
Atl equipment list_60_studentsAtl equipment list_60_students
Atl equipment list_60_students
 
Coa presentation1
Coa presentation1Coa presentation1
Coa presentation1
 
Android project
Android projectAndroid project
Android project
 
Logic design and switching theory
Logic design and switching theoryLogic design and switching theory
Logic design and switching theory
 
A Measurement Device for an Air Conditioning Unit
A Measurement Device for an Air Conditioning UnitA Measurement Device for an Air Conditioning Unit
A Measurement Device for an Air Conditioning Unit
 
22 micropl csandhmi_04_21
22 micropl csandhmi_04_2122 micropl csandhmi_04_21
22 micropl csandhmi_04_21
 
Humidity and Temperature Measurement Using Arduino
Humidity and Temperature Measurement Using ArduinoHumidity and Temperature Measurement Using Arduino
Humidity and Temperature Measurement Using Arduino
 
Digital electronics nandhini kusuma
Digital electronics nandhini kusumaDigital electronics nandhini kusuma
Digital electronics nandhini kusuma
 
Design of a Digital Baseband Processor for UWB Transceiver on RFID Tag
Design of a Digital Baseband Processor for UWB Transceiver on RFID TagDesign of a Digital Baseband Processor for UWB Transceiver on RFID Tag
Design of a Digital Baseband Processor for UWB Transceiver on RFID Tag
 
Monitoring Temperature Room With Display LCD and Data Recording
Monitoring Temperature Room With Display LCD and Data RecordingMonitoring Temperature Room With Display LCD and Data Recording
Monitoring Temperature Room With Display LCD and Data Recording
 
IRJET- Centralised Status alert system for industrial machines
IRJET-  	  Centralised Status alert system for industrial machinesIRJET-  	  Centralised Status alert system for industrial machines
IRJET- Centralised Status alert system for industrial machines
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
 
Logistics information monitoring by means of rfid sensor tag
Logistics information monitoring by means of rfid sensor tagLogistics information monitoring by means of rfid sensor tag
Logistics information monitoring by means of rfid sensor tag
 
Barcode Decoder
Barcode DecoderBarcode Decoder
Barcode Decoder
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
 
Design Efficient Wireless Monitoring Platform for Recycling Point Spots
Design Efficient Wireless Monitoring Platform for Recycling Point SpotsDesign Efficient Wireless Monitoring Platform for Recycling Point Spots
Design Efficient Wireless Monitoring Platform for Recycling Point Spots
 
Octal to binary and octal to hexa decimal conversions
Octal to binary and octal to hexa decimal conversionsOctal to binary and octal to hexa decimal conversions
Octal to binary and octal to hexa decimal conversions
 
Electronics Multisensor Shield
Electronics Multisensor ShieldElectronics Multisensor Shield
Electronics Multisensor Shield
 

Similar to Microcontrollers

FPGA Based Decimal Matrix Code for Passive RFID Tag
FPGA Based Decimal Matrix Code for Passive RFID TagFPGA Based Decimal Matrix Code for Passive RFID Tag
FPGA Based Decimal Matrix Code for Passive RFID TagIJERA Editor
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...IOSR Journals
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...IOSR Journals
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...IOSR Journals
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...IOSR Journals
 
Final Report - morse code.pdf
Final Report - morse code.pdfFinal Report - morse code.pdf
Final Report - morse code.pdfHanaBaSabaa
 
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic System
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic SystemVoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic System
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic SystemSagun Man Singh Shrestha
 
Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...researchinventy
 
Research Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and ScienceResearch Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and Scienceresearchinventy
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolIJERA Editor
 
Types of encoders and decoders with truth tables
Types of encoders and decoders with truth tablesTypes of encoders and decoders with truth tables
Types of encoders and decoders with truth tablesAbdullah khawar
 
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3Abhishekvb
 
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptxSatish Chandra
 
Electronic voting machine using RFID
Electronic voting machine using RFIDElectronic voting machine using RFID
Electronic voting machine using RFIDBharath Chapala
 
FPGA Implementation with Digital Devices
FPGA Implementation with Digital Devices FPGA Implementation with Digital Devices
FPGA Implementation with Digital Devices Sachin Mehta
 
Application of Microcontroller in Transmitter Section of Wireless System
Application of Microcontroller in Transmitter Section of Wireless SystemApplication of Microcontroller in Transmitter Section of Wireless System
Application of Microcontroller in Transmitter Section of Wireless Systemijceronline
 

Similar to Microcontrollers (20)

FPGA Based Decimal Matrix Code for Passive RFID Tag
FPGA Based Decimal Matrix Code for Passive RFID TagFPGA Based Decimal Matrix Code for Passive RFID Tag
FPGA Based Decimal Matrix Code for Passive RFID Tag
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
 
E010132736
E010132736E010132736
E010132736
 
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...Implementation of an Improved Microcontroller Based Moving Message Display Sy...
Implementation of an Improved Microcontroller Based Moving Message Display Sy...
 
Final Report - morse code.pdf
Final Report - morse code.pdfFinal Report - morse code.pdf
Final Report - morse code.pdf
 
G364246
G364246G364246
G364246
 
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic System
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic SystemVoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic System
VoCoRoBo: Remote Speech Recognition and Tilt Sensing Multi-Robotic System
 
Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...
 
Research Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and ScienceResearch Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and Science
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
 
Types of encoders and decoders with truth tables
Types of encoders and decoders with truth tablesTypes of encoders and decoders with truth tables
Types of encoders and decoders with truth tables
 
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
 
Analog to Digital .pptx
Analog to Digital .pptxAnalog to Digital .pptx
Analog to Digital .pptx
 
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx
1 Unit-1 DEC B.Tech ECE III Sem Syllabus & Intro.pptx
 
Electronic voting machine using RFID
Electronic voting machine using RFIDElectronic voting machine using RFID
Electronic voting machine using RFID
 
B41012015
B41012015B41012015
B41012015
 
FPGA Implementation with Digital Devices
FPGA Implementation with Digital Devices FPGA Implementation with Digital Devices
FPGA Implementation with Digital Devices
 
Application of Microcontroller in Transmitter Section of Wireless System
Application of Microcontroller in Transmitter Section of Wireless SystemApplication of Microcontroller in Transmitter Section of Wireless System
Application of Microcontroller in Transmitter Section of Wireless System
 

More from Meirin Evans

Group 14 Special Topics
Group 14 Special TopicsGroup 14 Special Topics
Group 14 Special TopicsMeirin Evans
 
Analysis of neutron penetration through shielding using Monte Carlo techniques
Analysis of neutron penetration through shielding using Monte Carlo techniquesAnalysis of neutron penetration through shielding using Monte Carlo techniques
Analysis of neutron penetration through shielding using Monte Carlo techniquesMeirin Evans
 
Rotation-vibration transitions in ethyne
Rotation-vibration transitions in ethyneRotation-vibration transitions in ethyne
Rotation-vibration transitions in ethyneMeirin Evans
 
Low_temperature_resistance
Low_temperature_resistanceLow_temperature_resistance
Low_temperature_resistanceMeirin Evans
 
Heights_of_lunar_mountains
Heights_of_lunar_mountainsHeights_of_lunar_mountains
Heights_of_lunar_mountainsMeirin Evans
 
Thermal_diffusivity_of_plastic
Thermal_diffusivity_of_plasticThermal_diffusivity_of_plastic
Thermal_diffusivity_of_plasticMeirin Evans
 

More from Meirin Evans (9)

Group 14 Special Topics
Group 14 Special TopicsGroup 14 Special Topics
Group 14 Special Topics
 
Momentwm
MomentwmMomentwm
Momentwm
 
Ymchwiliad Unigol
Ymchwiliad UnigolYmchwiliad Unigol
Ymchwiliad Unigol
 
Analysis of neutron penetration through shielding using Monte Carlo techniques
Analysis of neutron penetration through shielding using Monte Carlo techniquesAnalysis of neutron penetration through shielding using Monte Carlo techniques
Analysis of neutron penetration through shielding using Monte Carlo techniques
 
Report2
Report2Report2
Report2
 
Rotation-vibration transitions in ethyne
Rotation-vibration transitions in ethyneRotation-vibration transitions in ethyne
Rotation-vibration transitions in ethyne
 
Low_temperature_resistance
Low_temperature_resistanceLow_temperature_resistance
Low_temperature_resistance
 
Heights_of_lunar_mountains
Heights_of_lunar_mountainsHeights_of_lunar_mountains
Heights_of_lunar_mountains
 
Thermal_diffusivity_of_plastic
Thermal_diffusivity_of_plasticThermal_diffusivity_of_plastic
Thermal_diffusivity_of_plastic
 

Microcontrollers

  • 1. Using microcontrollers and solid state sensors Meirin Evans 9214122 School of Physics and Astronomy The University of Manchester Second Year Laboratory Report May 2016 This experiment was performed in collaboration with John Cobbledick. Abstract Through using a microcontroller combined with electronic components, output voltage measurements from various circuits were made. Along with a Radio Frequency Identifi- cation Device (RFID), the microcontoller was used to convert the device’s binary reading to an RFID tag’s individual number.

  • 2. 1. Introduction Microcontrollers are small computers which are connected via Universal Serial Bus (USB) to a larger computer which programs the microcontroller. They have an inbuilt circuit board to connect to other electronic components enabling them to measure the out- puts as well as control components. Microcontollers can be used in inductor/capacitor/ resistor circuits as well as with amplifiers, transistors and diodes. They can also be used with an oscilloscope’s wave generator to produce a variety of voltages and the oscillo- scope can measure the microcontroller’s output voltage. Solid state sensors are used widely; examples include Radio Frequency Identification Devices (RFID), temperature sensors, alcohol sensors, proximity sensors, range sensors, frequency to light converters and gas sensors [1]. 2. Theory Microcontrollers can be used to construct a peak and hold circuit, shown in Figure 1. The circuit includes an oscilloscope signal, a diode and a capacitor (with negative terminal grounded) in series. A voltage reading is taken between the capacitor and diode. The cir- cuit bears this name since the signal passes through the diode and charges the capacitor, giving a voltage across it, but when the capacitor discharges no current can pass through the diode in the other direction so it holds the same voltage. A higher capacitance means a higher time constant (longer discharge time) so the peak is held for longer. RFID tags have individual decimal numbers associated with them, for example school cafeteria tags as illustrated in Figure 2. For cafeteria tags, this number may then be linked to the holder’s name and balance, which could then be displayed on a screen. When a tag is flashed within 1-2 cm of a sensor it reads the tag’s number as a series of binary bits with different time lengths. This includes bits that notify the sensor as to when the signal starts and ends. It is usually sufficient to flash the tag in front of the sensor. The binary number is converted to hexadecimal (base 16) within the microcontroller, as shown in Ta- ble 1. Converting the microcontroller output to a string using a programming language gives the number in ASCII format. ASCII format is a system used by computers to dis- !2 Reading Fig 1. Circuit diagram for peak and hold. Includes an oscilloscope signal, a diode and a capacitor.
  • 3. play characters like numbers, letters and punctuation or to give instructions to the com- puter. Once the number is in ASCII it can be directly converted to decimal to give a recognisable number. A 5 digit (for example) hexadecimal ghijk is converted to decimal through Equation 1; ! . The value of each digit is multiplied by increasing powers of 16 from the right, where g through k can be 0-9 or A-F (corresponding to 10-15). In ASCII, a 2 indicates the start of a signal whilst a 3 indicates the end. The last 2 digits in the hexadecimal number kjihgghijk ++++= 16161616 234 !3 (1) Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F ASCII 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 Table 1. Table showing binary, hexadecimal and ASCII equivalents for decimal 0-15. Fig 2. Picture of RFID tags, like those used in school cafeterias [2].
  • 4. are a checksum and are therefore ignored when calculating the decimal number. The first 2 digits are also ignored as these are only used to calculate the checksum. The checksum is useful in verifying whether the information was correctly received. To do this, the tag number’s hexadecimal digits are paired then an XOR operation is performed on all pairs together. To understand an XOR operation numbers are converted to binary and the bina- ry digits of the numbers are then compared. An XOR gives 1 if digits are different and 0 if they are the same, as illustrated in Table 2. If the XOR operations of all the pairs corre- sponding to the tag number give the checksum, the data has been read correctly. 3. Experimental method In the peak and hold circuit, capacitors of 1nF and 100nF were used to compare be- haviour. The microcontroller used was an Arduino UNO [3] board which could be programmed using the Arduino language, which is similar to C. An RDM630 [4] operating at 125kHz was used as an RFID sensor. Pictures of both are in Figure 2. The program converted the ASCII characters read by the Arduino to tag number, which was then printed to the Ar- duino’s serial port. The program also did the XOR operations to obtain the tag’s check- sum and compared it with the read value. The program used to read the RIFD tags is in the Appendix. Viewing the series of bits read by the sensor on an oscilloscope showed that the first 2 digits of the hexadecimal number should be ignored in calculating the tag number. !4 Fig 2. Picture of an Arduino UNO board [5] (left). Picture of RFID sensor RDM630 [6] (right). Table 2. Example of XOR operation on 2 hexadecimal numbers 3C and CC. The binary representations are put in columns of decreasing powers of 2 for ease in calculating the result. 3C XOR CC gives F0. Hexadecimal Decimal 27 26 25 24 23 22 21 20 3C 60 0 0 1 1 1 1 0 0 CC 204 1 1 0 0 1 1 0 0 F0 240 1 1 1 1 0 0 0 0
  • 5. 4. Results Graphs of the input and output voltage shapes for both capacitors are shown in Figure 3. The results from reading RFID tags are shown in Table 3. All the tags’ calculated check- sums agreed with the initial reading. A screenshot of an example output from the Arduino’s serial is shown in Figure 4. It shows an introductory comment, the tag’s checksum, a statement saying whether the checksum was read correctly and the tag’s number. !5 Hexadecimal 3C00CC825725 3C00CEF5C3C4 ASCII 2 51 67 48 48 67 67 56 50 53 55 50 53 3 2 51 67 48 48 67 69 70 53 67 51 67 52 3 Tag number 13402711 13563331 Table 3. Table showing conversions from hexadecimal to ASCII to tag number for RFID tags. 0 2 4 6 8 10 12 14 16 18 20 0 .2 .4 .6 .8 1 .2 in out 0 2 4 6 8 10 12 14 16 18 20 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 in out Voltage (V) time (s) time (s) Fig 3. Plots of input and output voltage against time. Left is 1nF, right is 100nF. 100nF holds the peak for longer than 1nF.
  • 6. 5. Discussion The main difficulty in converting the hexadecimal reading of an RFID tag to its tag num- ber was in the step of converting hexadecimal to ASCII. Particularly troublesome was splitting the whole hexadecimal number into its individual digits to then put into arrays. Problems arose when trying to access array elements. To overcome this a do-while loop was used to read the tag’s hexadecimal digits whilst a for loop was used to do conver- sions, as opposed to a for loop for both. Another detail requiring particular attention is the use of long format rather than int when calculating the final number. The maximum decimal using int is 32767, obtained from the fact that an int is held in 16 bits and 216 is 65536, but negative numbers as well as 0 need to be included. A long, however, is held in 32 bits and 232 is 4294967296, giving a maximum long of 2147483647. The final tag numbers were between the maximum val- ues of int and long therefore long was appropriate. Int was used in other steps to speed up the program, though it probably did not change the speed much. !6 Fig 4. Screenshot of the Arduino’s output on the serial for one of the tags used. Includes an introductory comment, the tag’s checksum, a statement saying whether the checksum was read correctly and the tag’s number.
  • 7. 6. Summary Microcontrollers are very useful devices to manipulate electronic components, which are themselves easily manipulable using programming. They are most useful when used with solid state sensors to read, convert and output information from the sensors. References [1] Lalauze, R. & Pijolat, C., “A new approach to selective detection of gas by an SnO2 solid-state sensor”, Sensors and Actuators, Volume 5, Issue 1, 1984. [2] http://www.globalspec.com/learnmore/data_acquisition_signal_condition- ing/data_input_devices/rfid_tags, RFID Tags Information, IHS Engineering360, Accessed 30/03/2016. [3] https://www.arduino.cc/en/Main/ArduinoBoardUno, Arduino UNO & Genuino UNO, Arduino, Accessed 21/03/2016. [4] http://www.seeedstudio.com/depot/datasheet/RDM630-Spec..pdf, RD- M630 Specification, Seed Studio, Accessed 21/03/2016. [5] https://www.arduino.cc/en/Guide/Windows, Getting Started with Arduino and Genuino on Windows, Arduino, Accessed 21/03/2016. [6] http://store.iteadstudio.com/index.php?main_page=product_info&product- s_id=6, 125kHz RFID module RDM630 - UART, iStore, Accessed 21/03/2016. The number of words in this document is 1547. This document was last saved on 8/5/2016 at 21:31. Appendix // allow use of mySerial #include <SoftwareSerial.h> // use pin 10 on Arduino SoftwareSerial mySerial(10, 11); // RX, TX. // create arrays of ints int fig[14]; int check[5]; // setup loop void setup() { // Open hardware serial port for Serial Monitor. !7
  • 8. Serial.begin(9600); // debug statement Serial.println("RFID reader - simple test."); // Set the baud rate for the SoftwareSerial port. mySerial.begin(9600); } // main loop void loop() { // initialise j int j = 0; // long format for tag num long dec; // do while loop for reading do { if (mySerial.available() > 0) { fig[j] = mySerial.read(); j++; } } while (j < 14); // for loop to do conversions for (int i=0; i < 14; i++) { if (fig[i] > 47 && fig[i] < 58) { fig[i] = fig[i]-48; } else if (fig[i] > 64 && fig[i] < 71) { fig[i] = fig[i]-55; } } // for loop to pair digits for (int k = 1; k < 12; k = k + 2) { check[k]= fig[k]*16 + fig[k+1]; } // initialise csum int csum = 0; // for loop for checksum for (int h = 1; h < 10; h = h + 2){ csum = csum^check[h]; } // print checksum Serial.println(csum,HEX); if (csum == check[11]) { Serial.println("correct checksum"); } !8
  • 9. // calculate tag num dec = fig[10] + fig[9]*16 + fig[8]*power(16,2) + fig[7]*power(16,3) + fig[6]*power(16,4) + fig[5]*power(16,5); // print tag num Serial.println(dec); } // user defined power func long power(int a, int b) { long c = a; for (int p = 0; p < b - 1; p++){ c = a*c; } return c; } !9