Control, Robotics, & Embedded Systems Industrial Training Report

Share Embed


Descrição do Produto

A TECHNICAL REPORT OF STUDENT INDUSTRIAL WORK EXPERIENCE SCHEME (SIWES) AT THE CONTROL AND ROBOTICS LABORATORY, DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, AHMADU BELLO UNIVERSITY, ZARIA - NIGERIA.

BY

AMINU, USMAN KABIR U10EE1095

SUBMITTED TO THE DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, ABU ZARIA, IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF BACHELOR OF ENGINEERING (B. ENG) DEGREE, IN ELECTRICAL ENGINEERING.

JANUARY, 2015.

ABSTRACT This report is aimed at explaining key areas of my training under the Student Industrial Work Experience Scheme (SIWES) undertaken at the Robotics and Control Lab., Department of Electrical and Computer Engineering. An extensive and comprehensive practical was carried out on Microcontrollers and the means by which they may be used and applied, specifically in computer-integrated scenarios, robotics and industrial automations; utilizing Android phone sensors for enhanced control. The training was very enlightening and exposed students to real life practices that are used in developing theoretical ideas. So much experience was gained in these areas because they blend well with what was taught in classrooms and very much relevant to my future career as an Industrial Control/ Automation Engineer.

TABLE OF CONTENTS DECLARATION .................................................................................. Error! Bookmark not defined. CERTIFICATION ................................................................................ Error! Bookmark not defined. DEDICATION ...................................................................................... Error! Bookmark not defined. ACKNOWLEDGEMENT .................................................................... Error! Bookmark not defined. ABSTRACT............................................................................................................................................. i TABLE OF CONTENTS ........................................................................................................................ ii LIST OF FIGURES ............................................................................................................................... iv CHAPTER ONE ..................................................................................................................................... 1 1.1 PREAMBLE ............................................................................................................................... 1 1.2 AIMS AND OBJECTIVES ........................................................................................................ 2 1.3 MOTIVATION FOR SELECTION OF ATTACHMENT PLACE ........................................... 2 1.4 TRAINING METHODOLOGY ................................................................................................. 3 1.5 REPORT OUTLINE................................................................................................................... 3 CHAPTER TWO .................................................................................................................................... 4 2.1 HISTORICAL BACKGROUND OF CONTROL AND ROBOTICS LAB .............................. 4 2.2 ORGANIZATIONAL CHART .................................................................................................. 5 2.3 INTRODUCTION TO MICROCONTROLLERS ..................................................................... 5 2.3.1

TYPES OF MICROCONTROLLERS ............................................................................ 6

2.3.2

BASIC STRUCTURE OF MICROCONTROLLERS. ................................................... 8

2.4 SYSTEM DESIGN USING MICROCONTROLLERS ........................................................... 10 2.5 INTRODUCTION TO ARDUINO .......................................................................................... 11 2.5.1 ADVANTAGES OF ARDUINO BOARDS ..................................................................... 11 2.5.2 TYPES OF ARDUINO BOARDS .................................................................................... 12 2.6

CEREBOT MX3CK™ BOARD .......................................................................................... 14

2.7

ARDUINO DEVELOPMENT ENVIRONMENT ............................................................... 15

2.8

INTRODUCTION TO ARDUINO PROGRAMMING ....................................................... 16

2.9

ARDUINO LIBRARIES....................................................................................................... 18

2.10

INTRODUCTION TO THE APPINVENTOR ENVIRONMENT .................................. 19

2.11

ARDUINO SHEILDS ........................................................................................................ 21

2.12

INTRODUCTION TO SIMULATION ............................................................................ 23

2.13

PROTEUS PROFESSIONAL........................................................................................... 24

2.14

BLUETOOTH MODULE................................................................................................. 25

2.15

INFRARED TRANSMITTERS & RECEIVERS ............................................................. 26

CHAPTER THREE .............................................................................................................................. 28 3.1

INTRODUCTION ................................................................................................................ 28

ii

3.3

ARDUINO SERIAL COMMUNICATION ......................................................................... 28

3.4

ARDUINO SERIAL MONITOR.......................................................................................... 30

3.5

ARDUINO COMMUNICATION USING REMOTE CONTROL ...................................... 31

3.5.1

IRremote LIBRARY ..................................................................................................... 31

3.5.2

DECODING IR REMOTE CONTROLS ..................................................................... 32

3.6

ARDUINO BLUETOOTH COMMUNICATION ............................................................... 33

3.6.1

CONNECTING BLUETOOTH MODULE TO ARDUINO ........................................ 33

3.7

THE LIQUIDCRYSTAL DISPLAY .................................................................................... 36

3.8

CONTROLLING A SERVOMOTOR WITH AN ARDUINO ............................................ 38

3.8

THE SERVO ROBOT KIT................................................................................................... 39

3.8

MICROCONTROLLER SENSORS..................................................................................... 40

3.8.1 3.9

ANALOG TEMPERATURE SENSOR ...................................................................... 40

ARDUINO PROGRAMMING DEVICES ........................................................................... 41

3.9.1

USB CABLE - TYPE A TO TYPE B........................................................................... 41

3.9.2

STACKABLE HEADERS ........................................................................................... 42

3.9.3

BREAK AWAY HEADER .......................................................................................... 43

3.9.4

JUMPER WIRES .......................................................................................................... 43

3.9.5

SERVO MOTOR .......................................................................................................... 44

CHAPTER FOUR................................................................................................................................. 45 4.1

INTRODUCTION ................................................................................................................ 45

4.1

EXPERIENCE GAINED ...................................................................................................... 45

4.2

APPLICATIONS TO FUTURE CAREER .......................................................................... 46

CHAPTER FIVE .................................................................................................................................. 47 5.1 INTRODUCTION .................................................................................................................... 47 5.2 LIMITATIONS OF THE TRAINING ..................................................................................... 47 5.3 DIFFICULTIES DURING THE TRAINING .......................................................................... 48 5.4 CONCLUSION ........................................................................................................................ 48 5.5 SUGGESTIONS FOR FUTURE STUDENTS .................................................................... 49 REFRENCES ........................................................................................................................................ 50 APPENDIX A................................................................................................................................... 51 APPENDIX B ................................................................................................................................... 52 APPENDIX C ................................................................................................................................... 53 APPENDIX D................................................................................................................................... 54

iii

LIST OF FIGURES Fig. 2.1: Organizational chart of the Department of Electrical and Computer Engineering......5 Fig. 2.2: A Microcontroller Chip ............................................................................................... 6 Fig. 2.3: Classification of Microcontrollers ............................................................................... 8 Fig. 2.4: Microcontroller Chip showing Pin configurations ...................................................... 9 Fig. 2.6: Arduino UNO Board ................................................................................................. 12 Fig. 2.7: An MX3ck Board ...................................................................................................... 14 Fig. 2.8: Screenshot of the Arduino Environment ................................................................... 16 Fig. 2.9: Flowchart for the Arduino execution program. ......................................................... 18 Fig. 2.10: Screenshot of the AppInventor Designer Environment........................................... 19 Fig. 2.11: Development process of the AppInventor. .............................................................. 20 Fig. 2.12: Snippets of Visual Graphical Programming in the Block Designer. ....................... 20 Fig. 2.13: Arduino Ethernet Shield .......................................................................................... 22 Fig. 2.14: A shield mounted on the Arduino Board. ................................................................ 22 Fig. 2.15: ISIS™ window showing running simulation .......................................................... 25 Fig. 2.16: Bluetooth Wireless Logo ......................................................................................... 25 Fig. 2.17: RN-42 Bluetooth Module ........................................................................................ 26 Fig. 2.18: An Infrared Transmitter & its projection (right) ..................................................... 27 Fig. 2.19: An Infrared Emitter ................................................................................................. 27 Fig. 3.1: Serial Monitor Window ............................................................................................ 30 Fig. 3.2 : TSOP382 IR receiver connected to an Arduino and a common remote control......31 Fig. 3.3: Terminal window displaying random button presses on the remote........................31 Fig. 3.4: Connection of the bluetooth module to an Arduino UNO ........................................ 34 Fig. 3.5: An LCD connected to an Arduino Board with a potentiometer ................................ 37 Fig. 3.6: An Assembled SRK Car ............................................................................................ 40 Fig. 3.8: USB CABLE - TYPE A TO TYPE B ....................................................................... 42 Fig. 3.9: Stackable Headers for Mircocontroller boards. ......................................................... 42 Fig 3.10: Break Away Headers for Microcontroller. ............................................................... 43 Fig 3.11: Bunch of Jumper wires ............................................................................................. 43 Fig. 3.12: A Servo Motor ......................................................................................................... 44

iv

CHAPTER ONE GENERAL INTRODUCTION 1.1 PREAMBLE The Students Industrial Work Experience Scheme (SIWES) is a Skills Training Programme designed to expose and prepare students of Universities, Polytechnics/Colleges of Technology/Colleges of Agriculture and Colleges of Education for the Industrial Work situation they are likely to meet after graduation (SIWES, 2008). The scheme also affords students the opportunity of familiarizing and exposing themselves to the needed experience in handling equipment and machinery that are usually not available in their Institutions. Before the establishment of the scheme, there was a growing concern among our Industrialists that graduates of our Institutions of Higher learning lacked adequate practical background studies preparatory for employment in Industries. Thus, the employers were of the opinion that the theoretical education going on in higher institutions was not responsive to the needs of the employers of labour. It is against this background that the rationale for initiating and designing the scheme by the Fund during its formative years – 1973/74 was introduced to acquaint students with the skills of handling employers’ equipment and machinery. The ITF solely funded the scheme during its formative years. But as the financial involvement became unbearable to the Fund, it withdrew from the Scheme in 1978. The Federal Government handed over the scheme in 1979 to both the National Universities Commission (NUC) and the National Board for Technical Education (NBTE). Later the Federal Government in November 1984 reverted the management and implementation of the

SIWES Programme to ITF and it was effectively taken over by the Industrial Training Fund in July 1985 with the funding being solely borne by the Federal Government.

1.2 AIM AND OBJECTIVES Apparently, the aim and objectives of SIWES are not limited: 1. To expose students to engineering experience and knowledge which is required in industry, where these are not taught in the lecture rooms. 2. To apply the engineering knowledge taught in the lecture rooms in real industrial situations. 3. To use the experience gained from the SIWES in discussion held in the lecture rooms. 4. To get a feel of the work environment. 5. To gain experience in writing reports in engineering works/projects. 6. To provide students the opportunity to test their aptitude for a particular career before permanent commitments are made. 7. Expose students to work methods and techniques in handling equipment and machinery not available in their institutions.

1.3 MOTIVATION FOR SELECTION OF ATTACHMENT PLACE Following the recent upgrade to the Department of Electrical and Computer Engineering with state-of-the-art equipments, I became interested and curious to utilize these new tools in an harsh-free environment. Nevertheless I discovered the Control and Robotics Laboratory of the Department as the most suitable place for me to quench my thirst for Industrial Automations which will enable me capitalize on my programming experience for the building, development and control of an Industrial setting in real-world applications.

2

1.4 TRAINING METHODOLOGY 1. Research: The industry-based supervisor encouraged research in specific areas and discuss specific problems encountered as students whilst on the attachment, so as to ensure the chain of learning is moving forward. 2. Self-Implementation: It was required that each student performed his given task by himself using the tools and knowledge obtained from research, with relevant guidance and correction being given by industry based supervisor where necessary. 3. Project-works: The training encompasses a three week theoretical orientation on networking and the basics of managing a campus local area network. Then we go with the field-workers on daily installations, maintenance and troubleshooting of the A.B.U. Fiber internetwork. We are sometimes sent on projects where we practice what we have learnt from the field experience.

1.5 REPORT OUTLINE This technical report is compiled in a sequential order from chapters one to five, where the first chapter provides a general introduction to the SIWES scheme and the institution of attachment. Chapter two provides a theoretical presentation on the selected technical field of work. The Third chapter provides a summarized view of the actual tasks carried out, while the fourth and fifty chapters provide my personal views and conclusion for the report.

3

CHAPTER TWO THEORETICAL BACKGROUND OF THE SELECTED SIWES AREA 2.1 HISTORICAL BACKGROUND OF CONTROL AND ROBOTICS LAB The Department of Electrical Engineering was established in the year 1962, being one of the departments that was inaugurated at the inception of the university. At conception, it was charged with training its students in the academic and practical aspects of Electrical Engineering, ranging from the design and analysis of Power and Machine systems to Control Systems Engineering. To cater for the requisite practical aspects, a number of laboratories were established right from the start of the academic programs. These labs were the Power and Machines Laboratory, the Control Systems Laboratory, the Electronics laboratory and the Telecommunications Laboratory. These laboratories were established to provide the research portions of academic courses offered at the Department. At a much later time, other laboratories including the Mamman Kontagora computer lab would be established to supplement the existing ones. The control laboratory was tasked with research activities regarding the design, evaluation and analysis of controllers and control systems, which were applied to many scenarios including mechanical flight-control systems, speed governors, etc. amongst others. As control systems become more and more advanced, it is the responsibility of the laboratory to incorporate these advances into the practical portions of courses offered within the department, as well as provide a conducive environment for research activities. Currently, major research areas actively being evaluated include embedded systems (microcontrollers, programmable logic devices), classical control systems (PID-based controllers) and standalone and networked computer systems. Research in these areas is well supported by the availability of modern equipment which is made available to researchers.

4

In its current form, the control laboratory has been divided into three subunits: the robotics and embedded systems laboratory, the control (systems) laboratory and the computer laboratory. Each laboratory has its own dedicated staff, all under a single head. 2.2 ORGANIZATIONAL CHART OF THE DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, ABU ZARIA

Head Of Department

Chief Technologist

Principal Technologist (Electronics)

Principal Technologist (Control/Computer)

Principal Technologist (Power)

Senior Technologist

Senior Technologist

Senior Technologist

Technologist I

Technologist I

Technologist I

Technologist II

Technologist II

Technologist II

Fig. 2.1: Organizational chart of the Department of Electrical and Computer Engineering.

2.3 INTRODUCTION TO MICROCONTROLLERS Microcontroller is a single chip micro computer made through VLSI fabrication. A microcontroller also called an embedded controller because the microcontroller and its 5

support circuits are often built into, or embedded in, the devices they control. Fig 2.2 Shows a typical microcontroller chip. Nowadays, microcontrollers are so cheap and easily available that it is common to use them instead of simple logic for the sole purpose of gaining design flexibility and saving some space. Some machines and robots will even rely on a multitude of microcontrollers, each one dedicated to a certain task. Most recent microcontrollers are ‘In System Programmable’, meaning that you can modify the program being executed, without removing the microcontroller from its place (Atmel Corporation, 2010).

Fig. 2.2: A Microcontroller Chip 2.3.1 TYPES OF MICROCONTROLLERS Microcontrollers are generally classified into several categories according to their memory, architecture, bits and instruction sets. 1. Bits: 

8 bits microcontroller executes logic & arithmetic operations. Examples of 8 bits microcontroller is Intel 8031/8051.



16 bits microcontroller executes with greater accuracy and performance in contrast to 8-bit. Example of 16 bit microcontroller is Intel 8096.

6



32 bits microcontroller is employed mainly in automatically controlled appliances such as office machines, implantable medical appliances, etc. It requires 32-bit instructions to carry out any logical or arithmetic function.

2. Memory: 

External Memory Microcontroller – When an embedded structure is built with a microcontroller which does not comprise of all the functioning blocks existing on a chip it is named as external memory microcontroller. For illustration- 8031 microcontroller does not have program memory on the chip.



Embedded Memory Microcontroller – When an embedded structure is built with a microcontroller which comprise of all the functioning blocks existing on a chip it is named as embedded memory microcontroller. For illustration- 8051 microcontroller has all program & data memory, counters & timers, interrupts, I/O ports and therefore its embedded memory microcontroller.

3. Instruction Set: 

CISC- CISC means complex instruction set computer, it allows the user to apply 1 instruction as an alternative to many simple instructions.



RISC- RISC means Reduced Instruction Set Computers. RISC reduces the operation time by shortening the clock cycle per instruction.

4. Memory Architecture: 

Harvard Memory Architecture Microcontroller



Princeton Memory Architecture Microcontroller

The diagram below shows the various classifications of microcontrollers. 7

Microcontrollers

Bits

Memory

Instruction Set

Memory Architecture

8 Bits

Internal

CISC

Harvard

16 Bits

External

RISC

Princeton

32 Bits

Fig. 2.3: Classification of Microcontrollers 2.3.2 BASIC STRUCTURE OF MICROCONTROLLERS. a. CPU: CPU is the brain of a microcontroller. CPU is responsible for fetching the instruction, decodes it, then finally executed. CPU connects every part of a microcontroller into a single system. The primary function of CPU is fetching and decoding instructions. Instruction fetched from program memory must be decoded by the CPU. b. Memory: The function of memory in a microcontroller is same as microprocessor. It is used to store data and program. A microcontroller usually has a certain amount of RAM and ROM (EEPROM, EPROM, etc) or flash memories for storing program source codes. c. Parallel input/output ports: Parallel input/output ports are mainly used to drive/interface various devices such as LCD’S, LED’S, printers, memories, etc to a microcontroller. Some of the ports are shown in Fig. 2.4. d. Serial ports: Serial ports provide various serial interfaces between microcontroller and other peripherals like parallel ports. 8

e. Timers/counters: This is the one of the useful function of a microcontroller. A microcontroller may have more than one timer and counters. The timers and counters provide all timing and counting functions inside the microcontroller. The major operations of this section are perform clock functions, modulations, pulse generations, frequency measuring, making oscillations, etc. This also can be used for counting external pulses. f. Analog to Digital Converter (ADC): ADC converters are used for converting the analog signal to digital form. The input signal in this converter should be in analog form (e.g. sensor output) and the output from this unit is in digital form. The digital output can be use for various digital applications (e.g. measurement devices). g. Digital to Analog Converter (DAC): DAC perform reversal operation of ADC conversion.DAC convert the digital signal into analog format. It usually used for controlling analog devices like DC motors, various drives, etc. h. Interrupt control: The interrupt control used for providing interrupt (delay) for a working program .The interrupt may be external (activated by using interrupt pin) or internal (by using interrupt instruction during programming).

Fig 2.4: Microcontroller Chip showing Pin configurations (Atmel Corporation, 2010) 9

2.4 SYSTEM DESIGN USING MICROCONTROLLERS Before a microcontroller can be operational within any system, a number of tasks must be carried out beforehand. Typically, the computer-dependent portion of these tasks are carried out through the use the Integrated Development Environment (IDE) written by the manufacturer. Examples of IDEs include Atmel Studio for Atmel® microcontrollers, MPLAB and MPLAB X for Microchip® microcontrollers. The tasks are: a) Program composition b) Program Translation c) Program Deployment d) Hardware Deployment

Fig. 2.5: Typical workflow when designing microcontroller-based systems

10

2.5 INTRODUCTION TO ARDUINO Arduino is an open-source platform used for building electronics projects. Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller) and a piece of software, or IDE (Integrated Development Environment) that runs on your computer, used to write and upload computer code to the physical board. The Arduino hardware and software was designed for artists, designers, hobbyists, hackers, newbies, and anyone interested in creating interactive objects or environments. Arduino can interact with buttons, LEDs, motors, speakers, GPS units, cameras, the internet, and even your smart-phone or your TV! This flexibility combined with the fact that the Arduino software is free, the hardware boards are pretty cheap, and both the software and hardware are easy to learn has led to a large community of users who have contributed code and released instructions for a huge variety of Arduino-based projects (Arduino, 2010). 2.5.1 ADVANTAGES OF ARDUINO BOARDS 

Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50



Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.



Simple, clear programming environment - The Arduino programming environment is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with the look and feel of Arduino

11



Open source and extensible software- The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries.



Open

source

and

extensible

hardware

-

The

Arduino

is

based

on

Atmel's ATMEGA8 and ATMEGA168 microcontrollers. The plans for the modules are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money. 2.5.2 TYPES OF ARDUINO BOARDS The Arduino board is a small-form microcontroller circuit board. Arduino is fast becoming one of the most popular microcontrollers used in robotics. There are many different types of Arduino microcontrollers which differ not only in design and features, but also in size and processing capabilities. All Arduino boards are based around the ATMEGA AVR series microcontrollers from ATMEL which feature both analog and digital pins.

Fig. 2.6: Arduino UNO Board (Arduino, 2010)

12

Below is the table showing the comparation between different Arduino boards:

Name

Processor

Operating Voltage/Input Voltage

CPU Speed

Analog In/Out

Digital IO/PWM

Flash [KB]

Uno Due Leonardo Mega 2560 Mega ADK Micro Mini Nano

ATmega328 AT91SAM3X8E ATmega32u4 ATmega2560 ATmega2560 ATmega32u4 ATmega328 ATmega168 ATmega328 ATmega328 ATmega32u4

5 V/7-12 V 3.3 V/7-12 V 5 V/7-12 V 5 V/7-12 V 5 V/7-12 V 5 V/7-12 V 5 V/7-9 V 5 V/7-9 V

16MHz 84MHz 16MHz 16MHz 16MHz 16MHz 16MHz 16MHz

6/0 12/2 12/0 16/0 16/0 12/0 8/0 8/0

14/6 54/12 20/7 54/15 54/15 20/7 14/6 14/6

5 V/7-12 V 5 V/7-12 V

16MHz 16MHz

6/0 -

14/4 -

32 512 32 256 256 32 32 16 32 32 32

Ethernet Esplora

Table 2.1: Comparations between different Arduino boards.

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega8U2 programmed as a USB-to-serial converter. "Uno" means "One" in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino (Arduino, 2010). The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions, see the index of Arduino boards shown in Table 2.1 above.

13

2.6

CEREBOT MX3CK™ BOARD

The Cerebot MX3cK is a microcontroller development board based on the Microchip PIC32MX320F128H, a member of the 32-bit PIC32 microcontroller family. It is compatible with Digilent’s line of Pmod™ peripheral modules, and is suitable for use with the Microchip MPLAB® IDE tools. The Cerebot MX3cK shown in Figure 2.7 below, is also compatible for use with the chipKIT™ MPIDE development environment (Digilent Inc, 2011).

Fig. 2.7: An MX3ck Board

ChipKIT and MPIDE is a PIC32 based system compatible with many existing Arduino™ code examples, reference materials and other resources. The Cerebot MX3cK is designed to be easy to use and suitable for use by anyone from beginners to advanced users for experimenting with electronics and embedded control systems. It is intended to be used with either the Multi-Platform IDE, (modified Arduino IDE), MPIDE, or the Microchip MPLAB

14

IDE. The kit contains everything needed to start developing embedded applications using the MPIDE. In order to use the MPLAB IDE, an additional programming/debugging device, such as a Microchip PICkit3 is required. The Cerebot MX3cK provides 42 I/O pins that support a number of peripheral functions, such as UART, SPI and I2C™ ports as well as five pulse width modulated outputs and five external interrupt inputs. Eleven of the I/O pins can be used as analog inputs in addition to their use as digital inputs and outputs. The Cerebot MX3cK can be powered via USB, or an external power supply that may be either an AC-DC power adapter, or batteries.

2.7

ARDUINO DEVELOPMENT ENVIRONMENT

The Arduino development environment contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. It is a cross-platform application written in Java. It is designed to introduce programming to artists and other newcomers unfamiliar with software development (Arduino, 2010). The Arduino Integrated Development Environment (IDE)

includes a code editor with

features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling and uploading programs to the board with a single click. A program or code written for Arduino is called a sketch. Sketches are saved with the file extension .ino. It has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom righthand corner of the window displays the current board and serial port.

15

Fig. 2.8: Screenshot of the Arduino Environment The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the Serial Monitor as shown on the screenshot in Fig. 2.8 above.

2.8

INTRODUCTION TO ARDUINO PROGRAMMING

Arduino programs are written in C or C++. The Arduino IDE comes with a software library called "Wiring" from the original Wiring project, which makes many common input/output operations much easier. Users only need define two functions to make a runnable cyclic executive program:

16



setup(): a function run once at the start of a program that can initialize settings



loop(): a function called repeatedly until the board powers off

A typical first program for a microcontroller simply blinks an LED on and off. In the Arduino environment, the user might write a program like this: #define LED_PIN 13 void setup () { pinMode (LED_PIN, OUTPUT); // Enable pin 13 for digital output } void loop () { digitalWrite (LED_PIN, HIGH); // Turn on the LED delay (1000); // Wait one second (1000 milliseconds) digitalWrite (LED_PIN, LOW); // Turn off the LED delay (1000); // Wait one second }

Programming the Arduino and executing your program takes place in four stages: a. Write a program: First, you write your program. The Arduino environment lets you program in the programming language called C. The format for writing programs must obey the C language. b. Compile the program: Second, you compile your program, translating the code that you wrote to code that the computer chip on the Arduino can understand. If you’ve made any mistakes in your code, they will be detected during this phase and you will have to correct them and recompile your code before you move on to the next step. c. Load the program onto the Arduino: Third, you load your compiled code onto your Arduino, moving the code from your computer to the Arduino.

17

d. The program executes on the Arduino: Once it has been loaded, your program executes on your Arduino. The Arduino does what you told it to do. Write A Program

Compile The Program

Load The Program Onto The Arduino

The Program Executes On The Arduino

Fig. 2.9: Flowchart for the Arduino execution program. 2.9

ARDUINO LIBRARIES

Libraries are a collection of code or a folder with some files in it, the files will end in .cpp (C++ code file) and .h (C++ header file) that makes it easy for you to connect to a sensor, display, module, etc. For example, the built-in LiquidCrystal library makes it easy to talk to character LCD displays. #include is used to include outside libraries in a sketch. This gives the programmer access to a large group of standard C libraries (groups of premade functions), and also libraries written especially for Arduino. Example of some standard libraries: 

EEPROM - reading and writing to "permanent" storage



Ethernet - for connecting to the internet using the Arduino Ethernet Shield



Firmata - for communicating with the computer using a serial protocol.



GSM - for connecting to a GSM/GRPS network with the GSM shield.



LiquidCrystal - for controlling liquid crystal displays (LCDs)



SD - for reading and writing SD cards



Servo - for controlling servo motors

18

2.10 INTRODUCTION TO APP INVENTOR DEVELOPMENT ENVIRONMENT App Inventor is a web-based online graphical mobile application development environment for Android devices, where you can create an application by simply drag and connect a series of function blocks. It is a visual "blocks" language for programming Android mobile applications. It is an open-source web application originally provided by Google, and now maintained by the Massachusetts Institute of Technology (MIT). The Designer is divided into four separate sections: Palette, Viewer, Components and Properties.

Fig. 2.10: Screenshot of the AppInventor Designer Environment App Inventor has 2 different view modes, Designer and Blocks modes. In Designer mode, the Viewer section provides a graphical interface to view and design the app’s layout as shown in figure 2.10 above . In Blocks mode, the Viewer section provides a graphical interface where you can construct the app’s logic and function by dragging different component from the Blocks section. Snippets of Visual Graphical Programming in the Block Designer are shown in Figure 2.12 below.

19

Fig. 2.11: Development process of the AppInventor for development of Android applications.

After the build process is completed, App Inventor provides the option to download the generated .apk file,

Fig. 2.12: Snippets of Visual Graphical Programming in the Block Designer.

20

App Inventor's capabilities include: 

Access to most of the phone's functionality: phone calls, SMS texting, sensors for location, orientation, and acceleration, text-to-speech and speech recognition, sound, video.



The ability to invoke other apps, with the ActivityStarter component



Programming control just as with a textual language. There are blocks for conditionals (if, ifelse), foreach, and while, and a fairly comprehensive list of math and logic blocks.



Database access, both on the device and on the web. So you can save data persistently, and with a web database share data amongst phones.



Access to web information sources (APIs)-- you can bring in data from Facebook, Amazon, etc.

2.11 ARDUINO SHEILDS Shields are boards that can be plugged on top of the Arduino PCB extending its capabilities. The different shields follow the same philosophy as the original toolkit: they are easy to mount, and cheap to produce. Every Arduino shield must have the same form-factor as the standard Arduino. Power and ground pins on one eight (previously six) pin header, and analog pins on a six-pin header next to that. Digital pins cover the other edge on the other side, an eight-pin header separated from a 10-pin by that weird 0.5" spacing. An Arduino Ethernet Shield is shown in Figure 2.13.

21

Fig. 2.13: Arduino Ethernet Shield

Some shields use every pin on the Arduino, while others only use a couple. Some also communicate with the Arduino via SPI, I2C, or Serial, and others use the Arduino’s interrupts or analog inputs. Examples of some Shields supported by Arduino are: 

Arduino Ethernet Shield - Ethernet Shield supplies your Arduino with an ability to connect to the world wide web. There’s a great library to support it as well.



XBee Shield - XBee’s provide cheap means for communicating wirelessly. You could use an XBee to wirelessly trigger coffee machines, lights, or household appliances.



Cellular Shield w/ SM5100B - Turn your Arduino into a cellular phone! Send SMS text messages, or hook up a microphone and speaker.



GPS Shield - With a GPS Shield, your Arduino will always know where it is.

Fig. 2.14: A shield mounted on the Arduino Board. 22

2.12

INTRODUCTION TO SIMULATION

Simulation is the imitation of the operation of a real-world process or system over time. The act of simulating something first requires that a model be developed; The model represents the system itself, whereas the simulation represents the operation of the system over time. Electronic circuit simulation uses mathematical models to replicate the behavior of an actual electronic device or circuit. Simulation software allows for modeling of circuit operation and is an invaluable analysis tool. Electronics simulation software engages the user by integrating them into the learning experience. These kinds of interactions actively engage learners to analyze, synthesize, organize, and evaluate content and result in learners constructing their own knowledge. Few examples of simulation softwares include: 

Proteus ISIS Professional



Circuit Wizard



Live Wire



CircuitLogix



Multisim



SPICE

Main advantages of using simulation software include:

i.

It gives the proper idea and implementation of your code and circuit before implementing on hardware.

ii.

It reduces the time on creating hardware and testing your errors directly on hardware. You can analyze your circuit and code both to find the errors encountering before implementing on hardware.

iii.

Reduces project cost and software dependency.

23

2.13

PROTEUS PROFESSIONAL

Proteus is a design software developed by Labcenter Electronics for electronic circuit simulation, schematic capture and PCB design. Its simplicity and user friendly design made it popular among electronics hobbyists. Proteus is commonly used for digital simulations such as microcontrollers and microprocessors. It can simulate LED, LDR, USB Communication etc. It is integrated with real time simulation of the electronic circuit and test whether your designed circuit is working properly or not. It also features the revolutionary VSM (Virtual System Modelling) technology, which allow you to simulate micro-controller based design, complete with all the surrounding electronic (Labcenter Electronics, 2009) . Furthermore, you can interact with the microcontroller software through the use of animated keypads, switches, buttons, LEDs, lamps and even LCD displays. The Proteus Professional features the following features: 

Friendly User Interface.



Powerful Virtual Instrument.



ISIS (Intelligent Schematic Input System) Schematic Capture: an easy to use yet and extremely powerful tool for entering your design



PROSPICE Mixed mode SPICE Simulation industry standard SPICE3F5 simulator up



ARES PCB Layout



Modern Graphical User Interface standardized across all modules



Runs on Windows 98/ME/2000/XP or Later

The Intelligent Schematic Input System lies right at the heart of the PROTUES system and is far more than just another schematic package. It has powerful environment to control most aspects of the drawing appearance. whether your requirement is the rapid entry of complex design for simulation & PCB layout. 24

Fig. 2.15: ISIS™ window showing running simulation

2.14

BLUETOOTH MODULE

Bluetooth is a wireless technology standard for exchanging data over short distances from fixed and mobile devices, and building personal area networks (PANs). Invented by telecom vendor Ericsson in 1994, it was originally conceived as a wireless alternative to RS-232 data cables (Wikipedia). It can connect several devices, overcoming problems of synchronization.

Fig. 2.16: Bluetooth Wireless Logo

Below are the few applications of Bluetooth: 

Wireless control of and communication between a mobile phone and a handsfree headset. This was one of the earliest applications to become popular.

25



Wireless control of and communication between a mobile phone and a Bluetooth compatible car stereo system.



Wireless control of and communication with tablets and speakers such as iPad and Android devices.



Wireless streaming of audio to headphones without communication capabilities.



Wireless networking between PCs in a confined space and where little bandwidth is required.



Wireless communication with PC input and output devices, the most common being the mouse, keyboard and printer.

Fig. 2.17: RN-42 Bluetooth Module

An example of the is the RN-42 module from Roving Networks as shown in Figure 2.17 above, powerful, small, and very easy to use. This Bluetooth module is designed to replace serial cables. It is a Class 2 device meaning its range is about 50 to 60 feet and correspondingly the power consumption is reduced. It is simple to integrate into an embedded system or simply connect to an existing device.

2.15

INFRARED TRANSMITTERS & RECEIVERS

IR, or infrared, communication is a common, inexpensive, and easy to use wireless communication technology. IR light is very similar to visible light, except that it has a 26

slightlty longer wavelength. This means IR is undetectable to the human eye - perfect for wireless communication. For example, when you hit a button on your TV remote, an IR LED repeatedly turns on and off, 38,000 time a second, to transmit information (like volume or channel control) to an IR photo sensor on your TV.

Fig. 2.18: An Infrared Transmitter & its projection (right)

An infrared emitter, or IR emitter, is a source of light energy in the infrared spectrum. It is a light emitting diode (LED) that is used in order to transmit infrared signals from a remote control. In general, the more they are in quantity and the better the emitters are, the stronger and wider the resulting signal is.

Fig. 2.19: An Infrared Emitter

27

CHAPTER THREE DETAILS OF TRAINING UNDERGONE

3.1

INTRODUCTION

The details of the training undergone at the Control and Robotics Laboratory, Department of Electrical Engineering, Ahmadu Bello University, Zaria.

3.3

ARDUINO SERIAL COMMUNICATION

In order to make two devices communicate, whether they are desktop computers, microcontrollers, or any other form of integrated circuit, we need a method of communication and an agreed-upon language. The most common form of communication between electronic devices is serial communication. Communicating serially involves sending a series of digital pulses back and forth between devices at a mutually agreed-upon rate. For example, let’s say two devices are to exchange data at a rate of 9600 bits per second. First, we would make three connections between the two devices: a) a common ground connection, so both devices have a common reference point to measure voltage by; b) one wire for the sender to send data to the receiver on (transmit line for the sender); c) one wire for the receiver to send date to the sender on (receive line for the sender). Now, since the data rate is 9600 bits per second (sometimes called 9600 baud), the receiver will continually read the voltage that the sender is putting out, and every 1/9600th of a second, it will interpret that voltage as a new bit of data. If the voltage is high (+5V in the case of Wiring/Arduino, the PIC), it will interpret that bit of data as a 1. If it is low (0V in the case of Wiring/Arduino, the PIC), it will interpret that bit of data as a 0. By interpreting

28

several bits of data over time, the receiver can get a detailed message from the sender. at 9600 baud, for example, 1200 bytes of data can be exchanged in one second. Below is the general syntax for communicating with the computer at 9600 bits per second (baud) for serial data transmission. void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() {} /* Analog input reads an analog input on analog in 0, prints the value out. */ int analogValue = 0;

// variable to hold the analog value

void setup() { // open the serial port at 9600 bps: Serial.begin(9600); } void loop() { // read the analog input on pin 0: analogValue = analogRead(0); // print it out in many formats: Serial.println(analogValue); // print as an ASCII-encoded decimal Serial.println(analogValue, DEC);// print as an ASCII-encoded decimal Serial.println(analogValue, HEX);// print as an ASCII-encoded hexadecimal Serial.println(analogValue, OCT);// print as an ASCII-encoded octal Serial.println(analogValue, BIN);// print as an ASCII-encoded binary // delay 10 milliseconds before the next reading: delay(10); }

The above program prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n').

29

3.4

ARDUINO SERIAL MONITOR

The Arduino IDE has a feature that can be a great help in debugging sketches or controlling Arduino from your computer's keyboard. The Serial Monitor is a separate pop-up window that acts as a separate terminal that communicates by receiving and sending Serial Data. In Setup you need to begin Serial Communications and set the Baud Rate (speed) that data will be transferred at. It looks like this: Serial.begin(9600); // Other baud rates can be used... Serial.println("My Sketch has started");

In the loop you can print helpful info to the Serial Monitor. Examples: Serial.println("Top of loop"); Serial.println("Reading Temperature Sensor"); Serial.print("LoopCounter value = "); Serial.println(LoopCounter);

The Serial Monitor window consists of an input box for sending data to the Arduino board and the Display panel, for displaying data sent from the board. One need to set the COM Port he connected the Arduino to, after which he will select that port to communicate with.

Fig 3.1: Serial Monitor Window

30

3.5

ARDUINO COMMUNICATION USING REMOTE CONTROL

To receive or transmit Infrared Remote Control codes, one needs the IRremote Library. For transmitting, a single Infrared LED and resistor are needed. For receiving, an IR receiver module with internal bandpass filter is needed. 3.5.1 IRremote LIBRARY IRremote acts like 2 libraries, one for sending and one for receiving. The Table below shows various IRremote library usage functions and their description. Function IRrecv irrecv(receivePin) irrecv.enableIRIn()

irrecv.decode(&results)

Description Create the receiver object, using a name of your choice. Begin the receiving process. This will enable the timer interrupt which consumes a small amount of CPU every 50 µs. Attempt to receive a IR code. Returns true if a code was received, or false if nothing received yet. When a code is received, information is stored into "results". results.decode_type: Will be one of the following: NEC, SONY, RC5, RC6, or UNKNOWN. results.value: The actual IR code (0 if type is UNKNOWN) results.bits: The number of bits used by this code results.rawbuf: An array of IR pulse times results.rawlen: The number of items stored in the array

irrecv.resume()

After receiving, this must be called to reset the receiver and prepare it to receive another code.

irrecv.blink13(true)

Enable blinking the LED when during reception. Because you can't see infrared light, blinking the LED can be useful while troubleshooting, or just to give visual feedback.

IRsend irsend;

Create the transmit object. A fixed pin number is always used, depending on which timer the library is utilizing.

Table 3.1: Various IRremote library usage functions and their description.

31

3.5.2 DECODING IR REMOTE CONTROLS There are many different IR remote controls. All of these may have different encoding methods and number of physical buttons, and different codes received when a button is pressed. But if you need to discover the codes received from an unknown IR Remote type, use this Sketch from the IR Remote Control Library Examples in APPENDIX A. The sketch will automatically decode the type of remote you are using and identify which button on your remote is pressed. Open the serial port in the Arduino IDE at 9600 bps and hit different buttons on your remote.

Fig. 3.2 : TSOP382 IR receiver connected to an Arduino and a common remote control. Below is the Terminal window displaying random button presses on the remote. Different buttons show different codes.

Fig. 3.3: Terminal window displaying random button presses on the remote. 32

When specific buttons are pressed, you can use the incoming values to do something else in your code, for example: if(irrecv.decode(&results)) //checks to if a code has been received { if(results.value == 0xC284) //if button press equals hex value 0xC284 { //do something useful here } irrecv.resume(); //receive the next value }

3.6

ARDUINO BLUETOOTH COMMUNICATION

The Bluetooth Module is used for setting up a connection between Arduino Uno and an Android phone via Bluetooth. This will means that we have a two way communication between the Arduino and the Android phone over Bluetooth. The same approach can be used to interact with anything connected to your Arduino (like motors, servos and sensors) or specific features of your Android phone (camera, accelerators, speakers, microphone, a screen to show data from your sensors, wi-fi adaptor e.t.c) that will make an excellent addition to a robot, or any other Arduino project. The Arduino to PC connection can also be useful in applications where the Arduino reads sensors then pass their values via serial Bluetooth to a PC for processing. The distance for this transceiver is about 30 feet or so but it really depends on many other variables. This is ideal for indoors projects. 3.6.1 CONNECTING BLUETOOTH MODULE TO ARDUINO Most Bluetooth Modules communicates with the Arduino via a serial connection. It has four pins that could be used:

33



VCC is used to power the module. It needs to be connected to the Arduino 5v pin.



GND is the ground pin. It needs to be connected to the Arduino Ground pin



TXD is used to send data from the module to the Arduino. It needs to be connected to the serial receive pin (RX) of the Arduino, which is pin 0 in case of the Uno. If you are using a different Arduino board, you have to check its schematics to make sure you have the right pin.



RXD is used to receive data from the Arduino. It needs to be connected to the the Arduino serial transmit pin (TX) , which is pin 1 in the case of Arduino Uno.



“STATE” and the “KEY” pins.

Fig. 3.4: Connection of the bluetooth module to an Arduino UNO

The Module acts as a serial port through which you can send and receive data. So using a serial terminal or a Bluetooth customized application on your computer or phone, you can control and monitor your project. It is connected as shown in Fig. 3.4 above. I used Teraterm as the serial terminal. Before uploading the code to the Arduino, disconnect Bluetooth

34

module, since it shares the TX/RX pins and will interfere with the upload. Now, for us to set up a communication via a serial port we can use a library called SoftwareSerial. This code enables you to send a string to the Arduino via Bluetooth and get an echo back on your serial monitor: String message; //string that stores the incoming message void setup() { Serial.begin(9600); //set baud rate } void loop() { while(Serial.available()) {//while there is data available on the serial monitor message+=char(Serial.read());//store string from serial command } if(!Serial.available()) { if(message!="") {//if data is available Serial.println(message); //show the data message=""; //clear the data } } delay(5000); //delay }

The code in APPENDIX B allows you to switch on and off an LED using by sending a command to the Arduino via Bluetooth.

35

3.7

THE LIQUIDCRYSTAL DISPLAY

The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins: 

A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to do next.



A Read/Write (R/W) pin that selects reading mode or writing mode



An Enable pin that enables writing to the registers



8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you're writing to a register when you write, or the values you're reading when you read.



There's also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don't need to know the low-level instructions.

36

Fig. 3.5: An LCD connected to an Arduino Board with a potentiometer

The LiquidCrystal library contains many functions which include the LiquidCrystal(), begin(), clear(), home(), setCursor(), write(), print(), cursor(), blink(), noBlink(), display()

etc.

The basic usage functions of some of the LiquidCrystal Library functions are tabulated below:

Function

Description

LiquidCrystal lcd(RS, Enable, D4, D5, D6, D7):

Create the LiquidCrystal object and specify the 6 pins where the LCD is connected. You can connect more than one display (each to its

own

pins)

and

create

a

LiquidCrystal objects for each. lcd.begin(width, height);

Initialize the display and set the size.

37

separate

lcd.print(anything);

Print a number or text. This works the same as Serial.print(), but prints to the LCD.

lcd.setCursor(x, y);

Move the cursor to position (x, y). These are zero-based coordinates.

Table 3.2: Basic usage functions of some of the LiquidCrystal Library functions 3.8

CONTROLLING A SERVOMOTOR WITH AN ARDUINO

The Servo library allows an Arduino board to control RC (hobby) servo motors. Servos have integrated gears and a shaft that can be precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds. The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

Some of the Standard Methods used in the Servo library include: 

attach(int): Turn a pin into a servo driver. Calls pinMode. Returns 0 on failure.



detach(): Release a pin from servo driving.



write(int): Set the angle of the servo in degrees, 0 to 180. 38



read(): return that value set with the last write().



attached(): return 1 if the servo is currently attached.

The following code lets you control Servo on pin2 by potentiometer on analog 0:

#include SoftwareServo myservo;

// create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin void setup() { myservo.attach(2); }

// attaches the servo on pin 2 to the servo object

void loop() { val = analogRead(potpin); // reads the value of the potentiometer 0-1023 val = map(val, 0, 1023, 0, 179); // scale it to use the servo 0-180 myservo.write(val); // sets the position according to scaled value delay(15); // waits for the servo to get there SoftwareServo::refresh(); }

3.8

THE SERVO ROBOT KIT

The Digilent Servo Robot Kit (SRK) provides the perfect starting point for those new to robotics, but has the power to be used for advanced designs and applications as well. The SRK pairs with the powerful Cerebot™ MX3cK microcontroller development board with a rugged steel platform and all the motors, wheels, and other parts needed to build a complete robot (Digilent Inc, 2011). Using your Cerebot™ MX3cK microcontroller development board you will be able to add all sorts of functionality to your robot. By adding some of the extensive line of peripheral modules (Pmods™) and you can design almost anything!

39

The Cerebot MX3cK can be programmed with either Microchip MPLAB® IDE or chipKIT™ MPIDE.

Fig. 3.6: An Assembled SRK Car 3.8

MICROCONTROLLER SENSORS

Sensors are used to perform an input operation to the control unit. They sense a physical change in some characteristic and convert them into an electrical signal. Devices which perform an output operation are generally called Actuators. Below are few example of sensors I used that are compatible with the Arduino: 3.8.1 ANALOG TEMPERATURE SENSOR The Temperature sensor is a low voltage, precision centigrade temperature sensor. It provides a voltage output that is linearly proportional to the Celsius temperature. It also doesn’t require any external calibration to provide typical accuracies of ±1°C at +25°C and ±2°C over the −40°C to +125°C temperature range. We use it because it’s so easy to use: Just give the device a ground and 2.7 to 5.5 VDC and read the voltage on the Vout pin. The output voltage can be converted to temperature easily using the scale factor of 10 mV/°C.

40

Fig. 3.7: TMP36 Temperature Sensor If you're using a 5V Arduino, and connecting the sensor directly into an Analog pin, This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V).

If you're using a 3.3V Arduino, This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V).

A simple program for reading the temperature is shown in APPENDIX D.

3.9

ARDUINO PROGRAMMING DEVICES

Arduino microcontroller comes with various devices/tools used for various purposes which include: 3.9.1 USB CABLE - TYPE A TO TYPE B The USB A to B cable connects any standard host device (computer, hub, or controller) to any standard peripheral (Arduino, printer, scanner, external drive). It is used for programming Arduino boards.

41

Fig. 3.8: USB CABLE - TYPE A TO TYPE B

The type 'A' connector is a flattened rectangle that plugs into downstream port sockets on the USB hub or USB host. The USB-B connector, somewhat square-ish with two bevelled corners, plugs into upstream sockets on devices and hubs. This cable is USB 2.0 compliant.

3.9.2

STACKABLE HEADERS

Stackable headers are used on Microcontroller boards for additional stacking of many Sheilds or sensors on the Microcontroller board. They come in different header numbers.

Fig. 3.9: Stackable Headers for Mircocontroller boards. 42

3.9.3 BREAK AWAY HEADER Breakaway header is like the duct tape of electronics, and this header is one better with extra long pins on both sides. This makes it great for connecting things together that have two sockets - especially solderless breadboards. It could also be used with female-female socket jumpers to create female-male and male-male jumpers.

Fig 3.9: Break Away Headers for Microcontroller.

3.9.4 JUMPER WIRES Jumper wires are used for connecting various components on the solderless breadboard. They are very cheap and are available in different colors.

Fig 3.10: Bunch of Jumper wires

43

3.9.5 SERVO MOTOR Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note that servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.

Fig. 3.11: A Servo Motor

44

CHAPTER FOUR EXPERIENCE GAINED AND APPLICATIONS IN FUTURE CAREER

4.1

INTRODUCTION

Throughout the duration of the SIWES period, during which students were exposed to the exercises and tasks outlined in Chapter Three previously, the experience gained therefrom can be summarized as below:

4.1

EXPERIENCE GAINED

During the attachment period, students were exposed to the practical elements of Embedded Systems Engineering. By definition, Embedded Systems are specialized systems, and as has been seen from above, sometimes require integration with existing devices and technologies. I gained the experience on the rudiments of starting an embedded system design from scratch, with regards to hardware selection choices and required operation circuitry and considerations. In addition, I gained experience in writing programs in the C programming language for the microcontroller, and going about testing, debugging and troubleshooting it in the event of erratic or incorrect behavior, from both software and hardware perspectives. I also gained experience in deploying the compiled C code (HEX file) to the microcontroller’s internal memory to enable it operate as-per the written program. I also gained experience in interfacing the microcontroller to different types of hardware peripherals (sensors and actuators) and the considerations inherent in such practices. Finally, I gained experience in writing and configuring software that could extend the functionality of the microcontroller with the use of communication means.

45

4.2

APPLICATIONS TO FUTURE CAREER

Given the rapidly-changing landscape of computer technology nowadays, the Embedded System designer is required to be conversant with the canonical principles of Embedded Systems, and know how to apply them to any embedded system in any scenario. From the tasks completed during the SIWES program, and the experience gained thus far, it can be said that these practices have readied me for the barest minimum in the field of Embedded System design, from both hardware and software perspectives. While it is nowhere complete or exhaustive, I believe that the things I have gained thus far from the SIWES program have enlightened me to a degree such that I can function to an acceptable degree in such work scenarios and will be someday be able to adapt as needed in the field of Embedded Systems.

46

CHAPTER FIVE CONCLUSION AND RECOMMENDATION

5.1 INTRODUCTION The emergence of any training comes along with its limitations, challenges and adequate recommendation. The major benefits accruing to students who participate conscientiously in industrial training are the skills and competence they acquire. This is because the knowledge and skills acquired through training are internalized and become relevant when required to perform jobs or functions but this should not be other emphasized. Some of the difficulties and limitations encountered before, during and after SIWES period are being discussed in this chapter along with a few suggestions to future SIWES students.

5.2 LIMITATIONS OF THE TRAINING 1. The inadequate supervision from SIWES office to charter for the need of students. 2. Inability of institution to secure and the scarcity of quality places of industrial training for students participating. 3. In SIWES place, limitations of access to some aspects of the job done due to status in the corporation. 4. Inability of firm to allow students handle some equipment and machinery while on SIWES.

47

5.3 DIFFICULTIES DURING THE TRAINING 1. The difficulties faced when having to work with people of different character and or background. 2. There is little link between SIWES and industries. This creates problem for students to get industrial training placements. 3. Students are totally unaware of the objectives, mission and primary function of SIWES. This is because its impact is not felt in the lives of students, but every student knows what to expect as he or she has researched to know the organizational aim and services. 4. There is virtually no relationship between SIWES and the students participating in the program

5.4 CONCLUSION This report has covered the history, aims and motivations of the Students’ Industrial Work Experience Scheme (SIWES), as well as a brief coverage of the knowledge gained and experiences undergone during the attachment period served in the Robotics and Control Laboratory, Department of Electrical and Computer Engineering, Ahmadu Bello University Zaria. The shift from custom-designed hardware to microcontroller-based systems is happening in almost every field in Electrical and Electronic Engineering. As a result, it is becoming more and more important to gain expertise in the design and construction of such systems and to explore their varied applications.

48

5.5 SUGGESTIONS FOR FUTURE STUDENTS Students should take their SIWES very seriously and gain as much as possible, because it’s the only period the theory of classroom can be felt and seen in practical form to be appreciated. Also, students should be made to do their industrial attachments anywhere in the world provided it is applicable to their course of study. And when trying to select a place, money or allowance paid should not be the utmost priority, but a place where they can be impacted with great practical knowledge and skill to back up all the theories being learnt in school.

49

REFRENCES Arduino Programming Notebook-Arduino Playground. Retrieved August 2014 from Arduino Website: Arduino. (2010). Retrieved november 2013, from Arduino: www.arduino.cc Atmel Corporation Technical Datasheet for ATMEGA8/ATMEGA8L, Retrieved February 2011 from Atmel Corporation: Atmel Corporation. (2010). Retrieved January 2015, from ATMEL: http://www.atmel.com Blum, J. (2013). Exploring Arduino: Tools and Techniques for Engineering Wizardry. Boxall, J. (2013). Arduino Workshop: A Hands-On Introduction with 65 Projects. Digilent Inc. (2011). Retrieved October 2014, from Digilent Inc: http://www.digilentinc.com Monk, S. (2013). Programming Arduino Next Steps: Going Further with Sketches. Monk, S.(2011). Programming Arduino: Getting Started With Sketches. Nussey, J. (2013). Arduino For Dummies. Purdam, J. (2012). Beginning C for Arduino: Learn C Programming for the Arduino and Compatible Microcontrollers SIWES. (2008). Retrieved January 2015, from ITF: http://odich.com/itfnig/siwes.php

50

APPENDIX A /* * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv * An IR detector/demodulator must be connected to the input RECV_PIN. * Version 0.1 July, 2009 * Copyright 2009 Ken Shirriff * http://arcfn.com */

#include

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver }

void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } }

51

APPENDIX B #include // creates a "virtual" serial port/UART // connect BT module TX to D10 // connect BT module RX to D11 // connect BT Vcc to 5V, GND to GND void setup() { // set digital pin to control as an output pinMode(13, OUTPUT); // set the data rate for the SoftwareSerial port BT.begin(9600); // Send test message to other device BT.println("Hello from Arduino"); } char a; // stores incoming character from other device void loop() { if (BT.available()) // if text arrived in from BT serial... { a=(BT.read()); if (a=='1') { digitalWrite(13, HIGH); BT.println("LED on"); } if (a=='2') { digitalWrite(13, LOW); BT.println("LED off"); } if (a=='?') { BT.println("Send '1' to turn LED on"); BT.println("Send '2' to turn LED on"); } // you can add more "if" statements with other characters to add more commands } }

52

APPENDIX C /* LiquidCrystal Library - Hello World Demonstrates the use a 16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. This sketch prints "Hello World!" to the LCD and shows the time. The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3)

// include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); }

53

APPENDIX D

/*A simple program to read the temperature from a temperature module *attached to Analog pin 0 */

#include void setup() { Serial.begin(115200);

//get called when the Arduino starts // sets up the Serial port at 115200 baud rate

}

void loop() {

// loops while the arduino is powered

int val;

//Create an integer variable

val=analogRead(0);

//Read the analog port 0 and store in val

Serial.println(val);

//Print the value to the serial port

delay(1000);

//Wait one second before we do it again

}

54

Lihat lebih banyak...

Comentários

Copyright © 2017 DADOSPDF Inc.