Top Banner
Design & Development of IOT/Embedded application using ARM(LPC11U24 ) based mbed board A Practical Approach (Experimental Manual ForB.Tech & M.Tech Students) For SoC and Embedded systems in association with ARM university program and ITRA Designed & Developed By: Ms. Nidhi Agarwal Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE 1
27

LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Mar 30, 2018

Download

Documents

lyque
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Design & Development of IOT/Embedded application

using ARM(LPC11U24 ) based mbed board

A Practical Approach

(Experimental Manual ForB.Tech & M.Tech Students)

For SoC and Embedded systems in association with ARM university program and ITRA

Designed & Developed By: Ms. Nidhi Agarwal

Under the Guidance of: Dr. SRN Reddy, Associate Professor, CSE

Computer Science & Engineering Department

Indira Gandhi Delhi Technical University for Women

Kashmere Gate, Delhi-110006

LIST OF EXPERIMENTS

1

Page 2: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Exp No. Description of experiment Page No.

Exp. 1 To familiarize with ARM mbed board and understand the procedure of creation and compilation of C++ source code.

3-10

Exp. 2 To write C++ source code for creating different LED patterns and use ARM mbed board, on-board LEDs for checking output.

11-12

Exp. 3 To write C++ source code for interfacing LEDs and push to on switch with ARM mbed board at different GPIO pins.

13-15

Exp. 4 To write C++ source code for interfacing 16x2 LCD with ARM mbed board at different GPIO pins.

16-18

Exp. 5 To write C++ source code for using analog input at GPIO pin with ARM mbed board.

19-20

2

Page 3: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Mbed drive Mbed html link Source code files

ARM MBED SYSTEM BOARDmbed NXP LPC11U24

Experiment 1

Objective: To familiarize with ARM mbed board and understand the procedure of creation and compilation of C++ source code.

Software Requirement: Internet access.

Hardware Requirement: Target board mbed NXP LPC11U24, USB Cable

Procedure: 1. Connect ARM mbed board with PC using proper USB cable.2. Upon connection there appears a drive at My Computer of PC. E.g. MBED (E:) here figure

1.1.

Figure 1.1 mbed drive on My computer

3. A click on mbed drive will show html link for mbed.org and all source code files (if board is used earlier, for first time users no file will be there) saved into this board.

4. Click on html link and you will be redirected to mbed website.5. First time user should create their login to use online compiler.6. Click on Platform and select mbed LPC11U24. Figure 1.2, 1.3.

3

Page 4: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

GPIO pins

LED1-LED4(on board)

GPIO pins

USB connector

Reset Switch

Programming status LED

Figure 1.2 LPC 11U24 ARM mbed board

7. All the documents related to concerned platform will be available there.8. Pin diagram showing mapping of LPC11U24 pins with mbed LPC11U24 board with all

functions, is as shown in figure 1.4 and 1.5

Figure 1.3 LPC 11U24 ARM mbed board pin outs

4

Page 5: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Figure 1.4 Mapping of LPC 11U24 pins with ARM mbed board pin outs

5

Page 6: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Figure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs

The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low cost USB devices, battery powered applications and 32-bit ARM Cortex-M0 based designs. It is packaged as a small DIP form-factor for prototyping with through-hole PCBs and breadboard and includes a built-in USB FLASH programmer. The pin-out above shows the commonly used interfaces and their locations. All the numbered pins (p5-p30) can also be used as DigitalIn and DigitalOut interfaces. It includes a built-in USB programming interface for easy programming.

Features of mbed board and mbed.org website support1. NXP LPC11U24 MCU

1.1. Low power ARM Cortex-M0 Core 1.2. 48MHz, 8KB RAM, 32KB FLASH 1.3. USB Device, 2xSPI, I2C , UART, 6xADC, GPIO

2. Prototyping form-factor 2.1. 40-pin 0.1" pitch DIP package, 54x26mm 2.2. 5V USB, 4.5-9V supply or 2.4-3.3V battery 2.3. Built-in USB drag 'n' drop FLASH programmer

3. mbed.org Developer Website 3.1. Lightweight Online Compiler 3.2. High level C/C++ SDK

6

Page 7: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

3.3. Cookbook of published libraries and projects

Creating source codes for mbed board:-

1. Connect to mbed.org website.2. Login and open online Compiler.3. Click New for new program creation. Then Empty program and provide some name. Figure

1.6, 1.7.4. Add new file for source code with .cpp extension and library file mbed.h. Figure 1.8.5. Open newly created .cpp file and write C++ source code at editor. Figure 1.9. Take any

source code of experiment 2.6. Compile source code by pressing compile tab. Figure 1.9.7. After compilation, when prompted choose save as and save .bin file only into mbed drive

at my computer. Figure 1.10, 1.11. 8. mbed board will be programmed then with .cpp source code. Program LED (Figure 1.2)

will be seen blinking during programming process..9. Press reset switch (Figure 1.2) to start source code operation.

Figure 1.6 New Program creation

Figure 1.7 New Program creation

7

Page 8: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Compile tab

Figure 1.8 New Program creation, Addition of new source code file

Figure 1.9 New Program creation

8

C++ source code written in editor window

Page 9: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Click here and press Save AsFigure 1.10 Compiling .cpp source code

Figure 1.11 Saving .bin source codeResult :- Compilation and programming of ARM mbed board is done and process understood.

9

Page 10: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Conclusion :- Using online compiler and editor it is easy to program ARM board anywhere, with only mandatory requirement of internet access.

Remark :- Pin outs available at ARM mbed board is actually different from actual LPC11U24 processor. This should be kept in mind while preparing source codes.Reference:-

1. www. mbed.org

Experiment 2

10

Page 11: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Objective: To write C++ source code for creating different LED patterns and use ARM mbed board on-board LEDs for checking output.

Software Requirement: Internet access.

Hardware Requirement: Target board ARM mbed NXP LPC11U24, USB Cable

Procedure:

1. Write desired C++ source code 2. Compile using online compiler as described in experiment1.

Source Code 1: Table 2.1;Program written using C++ for mbed LPC11U24 board;This program will blink all four onboard LEDs,define all 4 LEDs ;using name myledx.

#include "mbed.h"DigitalOut myled1(LED1);DigitalOut myled2(LED2);DigitalOut myled3(LED3);DigitalOut myled4(LED4);

int main() { while(1) {

myled1 = 1; myled2 = 1; myled3 = 1; myled4 = 1; wait(0.2); myled1 = 0; myled2 = 0; myled3 = 0; myled4 = 0; wait(0.2); }}

Source Code 2: Table 2.2;Program written using C++ for mbed LPC11U24 board;This program will lit all four onboard LEDs in rotating ;manner, ;litting one LED at a time, define all 4 LEDs ;using name myledx.

#include "mbed.h"DigitalOut myled1(LED1);DigitalOut myled2(LED2);DigitalOut myled3(LED3);DigitalOut myled4(LED4);int main() { while(1) { myled1 = 1; myled2 = 0; myled3 = 0; myled4 = 0; wait(0.2);

myled1 = 0; myled2 = 1; myled3 = 0; myled4 = 0; wait(0.2); myled1 = 0; myled2 = 0; myled3 = 1; myled4 = 0; wait(0.2); myled1 = 0; myled2 = 0; myled3 = 0; myled4 = 1; wait(0.2); }}

Source Code 3: Table 2.3;Program written using C++ for mbed LPC11U24 board int main() {

11

Page 12: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

;This program will lit two-two onboard LEDs, at a time;Outputs given here as port and not as bits.

#include "mbed.h" BusOut ledchk(LED1,LED2,LED3,LED4);

while(1) { ledchk = 12; wait(0.5); ledchk = 3; wait(0.5); }}

Source Code 4: Table 2.4;Program written using C++ for mbed LPC11U24 board;This program will lit all four onboard LEDs, showing ;hexadecimal counting pattern from 0 to 15( Fh).;Outputs given here as port and not as bits.

#include "mbed.h"BusOut myleds(LED1, LED2, LED3, LED4);

int main() { while(1) { for(int i=0; i<16; i++) { myleds = i; wait(1); } }}

Result:- Output observed at LEDs, as per compiled C++ source code.

Conclusion :- Small changes in source code may result in saving memory space and programmers efforts tremendously.

Remark :- ALL available GPIOs can be accessed as individual pins using DigitalOut or as 4 bit/8bit port using BusOut. All these functions are available in mbed.h library. Here Out describe Output port. Similarly with DigitalIn and BusIn functions, GPIOs can be used as Input port.

Any available GPIO can be combined to form I/O port. This ease of programming is provided by mbed board and not by ARM processor.

Reference:- 1. www.mbed.org

Experiment No. 3

12

Page 13: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Objective: To write C++ source code for interfacing LEDs and push to on switch with ARM mbed board at different GPIO pins.

Software Requirement: Internet access.

Hardware Requirement: Target board ARM mbed NXP LPC11U24, USB Cable

Procedure:

Interfacing of LED1. Connect LEDs as per connections given in Figure.2. Write the desired C++ program and compile using online compiler as described in

experiment1.

Figure 3.1 Interfacing of LEDs at GPIOs

Source Code : Table 3.1

;Program written using C++ for mbed LPC11U24 board;This program will blink LED connected at pin 36 on mbed board ;GPIO pin.

#include "mbed.h"DigitalOut myled(p36);

int main() { while(1) { myled = !myled; wait(0.2); }}

13

Page 14: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Source Code : Table 3.2

;Program written using C++ for mbed LPC11U24 board;This program will lit 8 LEDs interfaced at GPIO pins, showing ;hexadecimal counting pattern from 0 to 65535( FFFFh).;Outputs given here as port and not as bits.

#include "mbed.h"BusOut ledchk(p21,p22,p23,p24,p25,p26,p29,p30);

int main() { while(1) { for(int i=0; i<65535; i++) { ledchk = !i; wait(0.05); } }}

Interfacing of push to on switch:

1. Connect switch as per connections given in Figure 3.22. Write the desired C++ source code and compile using online compiler as described in

experiment1.

Figure 3.2 Interfacing of push to on switch at GPIO p35

Source Code : Table 3.3;Program written using C++ for mbed LPC11U24 board;This program will toggle onboard LED1, for every switch press; switch connected at GPIO pin, p35.

#include "mbed.h"DigitalIn switchpress(p35);DigitalOut led(LED1);

int main() { while(1) { if(switchpress) { led = !led; } wait(0.25); }}

Result:- Output observed at GPIO pins. LEDs and switch interfacing achieved at GPIOs as per compiled C++ source code.

14

Page 15: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Conclusion :- Small changes in source code may result in saving memory space and programmers efforts tremendously.

Remark :- Any available GPIO can be combined to form I/O port. This ease of programming is provided by mbed board and not by ARM processor.

Reference:- www.mbed.org

15

Page 16: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Experiment No. 4

Objective: To write C++ source code for interfacing 16x2 LCD with ARM mbed board at different GPIO pins.

Software Requirement: Internet access.

Hardware Requirement: Target board ARM mbed NXP LPC11U24, USB Cable .

Procedure:

Interfacing of LCD1. Connect 16x2 LCDs as per connections given in Figure 4.12. Write the desired C++ source code3. Compile using online compiler as described in experiment1.

Figure 4.1 Interfacing of LCD at GPIOs

16

Page 17: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Figure 4.2 Command set of LCD

17

Page 18: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Source Code : Table 4.1

;Program written using C++ for mbed LPC11U24 board;8 bit mode LCD display, lcd commands used are -01h for ;clear display, 12h for display on, 06h for entry mode, 28h ;for cursor and display shift, 56h for function set

#include "mbed.h" BusOut ledchk(p21,p22,p23,p24,p25,p26,p29,p30);DigitalOut RS(p8);DigitalOut ENB(p14);

unsigned char wel[]={"Hello World"};void lcd_cmd(int lcdcmd){ wait(0.2); RS = 0; ENB = 1; wait(0.05); ledchk = lcdcmd; wait(0.05); ENB = 0; } void lcd_data(int lcddata){ wait(0.1); RS = 1; ENB = 1; wait(0.05);

ledchk = lcddata; wait(0.1); ENB = 0; RS = 0; }void lcd_int(void){ lcd_cmd(01); lcd_cmd(12); lcd_cmd(06); lcd_cmd(28); lcd_cmd(56); }void printf(unsigned char msg[]){ char chari; int i=0; while(msg[i]!='/') { chari=msg[i]; lcd_data(chari); i++;} }int main() { lcd_int(); printf(wel); while(1)}

Result: Output “Hello World” observed at 16x2 LCD as per C++ source code written.

Conclusion:- LCD is interfaced with ARM mbed board and is showing messages.

Remark:- With the same procedure 16x4, 20x2, 20x4, 40x4 etc LCD can also be interfaced. Here care must be taken in selecting LCD display segment address. Through proper segment address one can display data anywhere on LCD display panel.Bidirectional communication between LCD and controller can also be done, where one can use LCD memory space, can create own characters using CGRAM data space of LCD eg hindi character set.LCD is interfaced here using 8 bit mode. Same LCD can also be interfaced using 4bit mode and results in saving GPIOs

References:- 1. www.mbed.org 2. https://www.sparkfun.com/datasheets/LCD/ADM1602K-NSW-FBS-3.3v.pdf

18

Page 19: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Experiment No. 5

Objective: To write C++ source code for using analog input at GPIO pin with ARM mbed board.

Software Requirement: Internet access.

Hardware Requirement: Target board ARM mbed NXP LPC11U24, USB Cable .

Procedure:

1. Connect input as per connections given in Figure 5.1.2. Write the desired C++ program and compile using online compiler as described in

experiment1.

Figure 5.1 ADC interfacing at GPIO pin 19

Source Code: Table 5.1;Program written using C++ for mbed LPC11U24 board; Analog input given at GPIO19;Output seen at all 4 onboard LEDs

#include "mbed.h" BusOut ledout(LED1, LED2, LED3, LED4);AnalogIn ain(p19);

int main() { float c = ain.read(); while(1){ c= ain.read(); if (c<0.1) { ledout = 0; } else if (c<0.2) { ledout = 1; }

else if (c<0.3) { ledout = 2; } else if (c<0.4) { ledout = 3; } else if (c<0.5) { ledout = 4; } else if (c<0.6) { ledout = 5; } else if (c<0.7) { ledout = 6; } else if (c<0.8) { ledout = 7; } else if (c<0.9) { ledout = 8; } else if (c<1.0) { ledout = 9; } }}

Result: Output is observed at all 4 on board LEDs as per variations in analog input voltage.

19

Page 20: LAB MANUAL - · Web viewFigure 1.5 Mapping of LPC 11U24 pins with ARM mbed board pin outs The mbed NXP LPC11U24 microcontroller board in particular is designed for prototyping low

Conclusion:- Analog voltage inputs are taken by ARM mbed board and corresponding Digital data is stored into internal registers.

Remark:- All six analog to digital channels can be used in same project. Range for analog inputs data should be in the range of 0.1 to 1.0 Volts only.

Reference:1. Datasheet LPC 11U series2. www.mbed.org

20