PIC LAB Manual. Examples for experiments using Microcontrollers

PIC 16F877 and LPC 2148 ARM 7 Trainer Kits


Template, Example, 2015
62 Pages

Excerpt

Contents

PIC 16F877 MICROCONTROLLER TRAINER KIT
FAMILIARIZATION OF KIT
Features
Hardware Specification
I2C Based Devices:
MPLAB IDE
Windows Serial Downloader
Windows Win X Talk Serial Output Window
BUZZER CONTROL
RELAY CONTROL
WRITING TO LED ARRAY
READING DIP SWITCH
READING MATRIX KEYPAD
WRITING TO LCD DISPLAY
SERIAL TRANSMIT& RECEIVE
RTC (REAL TIME CLOCK)
8 BIT DAC
TEMPERATURE SENSOR
SERIAL EEPROM

LPC 2148 ARM 7 PROCESSOR TRAINER KIT
FAMILIARIZATION OF TRAINER KIT
Features
Applications
On Board Peripherals
IAR EMBEDDED WORKBENCH
Running IAR Embedded Workbench:
Running Launch LPC 210x –IS down loader:
Running Windows Win X Talk Serial Output Window:
BUZZER CONTROL
RELAY CONTROL
WRITING TO LED ARRAY
READING DIP SWITCH
READING MATRIX KEYPAD
8 BIT A/D CONVERTOR
TEMPERATURE SENSOR
8 BIT D/A CONVERTOR

PIC 16F877 MICROCONTROLLER TRAINER KIT

EXPERIMENT 1.

FAMILIARIZATION OF KIT

Aim:

To familiarize with PIC trainer kit and MPLAB IDE.

Introduction

The VPUT-01 is a trainer kit for 8,16 and 32 bit microcontroller development system furnished with under mentioned capabilities and can be used either as a stand alone system or as a system with serial interface to personal computer to further enhance its performance and exploit it for maximum benefit.

CPUs Supported

The VPUT -01 supports the following microcontrollers:

PIC Microcontroller (PIC16F873,876,874,877,452,18F8720 and 6720)

89C51 Microcontroller

Atmel ATMEGA 128/64 Microcontroller

ARM-LPC2148 Microcontroller

Above all CPUs are provided as separate plug-in boards called piggy back boards. For working with any controller, just plug-in the respective piggy back onto the board. The Trainer contains the CPU, I2C based RTC, EEPROM, Stepper motor driver circuit, LCD display, 4x4 matrix keyboard, 8 digital input and 8 digital output. All digital inputs, outputs and key board connections are terminated in individual 16 pin FRC connector. We can communicate VPUT-01 trainer with PC via serial port. VPUT-01 Embedded Trainer is very powerful and economical development system for advanced experimentation and research applications. Depending of the need and applications, we can use VPUT-01 in any one of the microcontrollers. Normally, the main board contains the CPU PIC 16F877.

Features

On-Board Features:

- Universal Embedded trainer(VPUT-01) is compatible for most microcontroller's.
- USART/UART Lines are terminated at 9-pin D-Type male connector.
- It supports character based LCD .
- Universal Board contains I2C based EEPROM and RTC.
- I2C based 8 bit (PCF 8591) ADC.
- I2C based 8 bit (PCF 8591) DAC.
- I2C based 7-Segment and I/O line based relay.
- On board LED, switch and key interfaces.
- Battery backup is provided for RTC.
- On board stepper motor driver lines are terminated at 5 pin RMC.
- LM35 temperature sensor was provided for temperature measurement.
- ADC and DAC lines are terminated at 20 pin FRC and J801 connector.
- CPU lines are terminated at two 50 pin FRC header.
- Opto Isolated USB to serial port.

On-Chip Features:

Main Features of PIC 16F877

- Operating frequency : DC to 20Mhz
- Single supply at 5v
- RISC Architecture.
- Only 35 instruction set
- 8K × 14 words of program memory
- 368 × 8 bytes of data memory
- 256 × 8 bytes EEPROM data memory
- 3 Timers are also available
- 2 capture, compare, and PWM modules are available
- Synchronous serial port with SPI and i2c
- A synchronous serial port with 9 bit address detection
- 10 bit , 8 channel analog to digital converter
- PIC 16F877A - two comparator is available
- In system programming at 5V
- In circuit debugging via two pins
- Low power high speed Flash/EEPROM technology
- Self re-programmable under software control

Hardware Specification

Switches:

In VPUT-01 Universal Embedded trainer, two switches are provided. One switch is for programming and execution( for PIC and 89C51 microcontrollers). If the switch is in Prog. mode, CPU goes to Boot mode. In boot mode we can download the Hex files through windows serial downloader(PIC bootPlus,Win ISP). If the switch is in Exec mode, CPU goes to Execution mode. User code going to be executed. Another one switch is for selection of Internal and external peripherals. If the switch is in Internal mode, we can access the onboard peripherals. If the switch is in the External mode, we can access the add-on cards without disturbing the onboard peripherals.

Serial Port :

Data from the controller is transferred through the serial port to any media(e.g VPUT-01 trainer kit to PC or Vice versa). Serial Port transmits data as +/-12v using the serial port driver ICL 232. ICL communication software is used to verify the data transmission(e.g Win-Xtalk, Hyperterminal etc.,).

USB to Serial Port Convertor:

We are separately having isolated RS232 and USB portS for the purpose of transferring data. USB 2.0 port is accomplished using the FTDI chip FT232RL USB-to-UART Bridge Controller. The VPUT-01 interfaces to the FT232RL as a simple UART. The UART interface to FT232RL can run at speeds ranging from 300 to 115200 baud rate. The FT232RL is a highly integrated USB-to-UART Bridge Controller, providing a simple solution for USB serial communications using a minimum of components and PCB space. The FT232RL includes a USB 2.0 full-speed function controller, USB transceiver, oscillator, EEPROM, and synchronous serial data bus (UART) with full modem control signals in a compact package. No other external USB components are required.

ICSP Connector:

The connector uses two device I/O pins that are shared between In Circuit Debugging and In Circuit Serial Programming. The kit is connected to PC using USB and can be connected to the device via ICSP connector for In Circuit Serial Programming.

LED interfacing:

8 LED's are connected to PORTD lines through 74LS273 Latch. Latch is enabled via PORTB.4. Digital data are sent to Port D lines. According to the digital data, LED glows.

DIP Switch Interfacing:

8 DIP switches are connected to Port D lines through 74LS244 chip which is enabled by PORTB.6. Key status is read by Port D lines and output is display through LEDs and serial port.

4X4 Matrix Key Pad Interfacing:

16 keys are formed in 4x4 matrix format. Port D lines are used for column scanning and row reading.

Buzzer and Relay interfacing:

Buzzer and relay devices are connected in I/O Lines. Buzzer is connected in port B.0. Two relays are connected in Port D.4 and Port D.5. Latch line used for relay is Port B.1.

I2C Based Devices:

I2C (Inter integrated Circuit) uses wire Communication. These are

1. Serial Clock(SCL) 2. Serial Data (SDA)

1. Serial EEPROM:

24LS256 is I2C based Serial EEPROM. Device address = 0xA6

2. Real Time Clock:

DS1307 is I2C based Real Time Clock. Device address = 0xD0 for I2C write and 0xD1 for I2C read operations.

3. Seven Segment Display:

A seven-segment display (abbreviation: "7-segment display"), less commonly known as a seven-segment indicator, is a form of display device that is an alternative to the more complex dot-matrix displays. Seven-segment displays are commonly used in electronics as a method of displaying decimal numeric feedback on the internal operations of devices.

4. 8 Bit ADC:

PCF8591 is 8 bit ADC. ADC Input and output channel lines are terminated at 20 pin box type header and J801 connector. PCF 8591 device address is 0x98 for I2C write and 0x99 for I2C read operations.

5. 8 Bit DAC:

PCF8591 is 8 bit DAC. DAC output channel lines are terminated at 20 pin box type header and J801 connector. PCF 8591 device address is 0x98 for I2C Write,

Power Supply:

On VPUT-01 board, Multi output power supply is used. It provides +5v,+12v,-12 and GND.

LCD Module:

VPUT-01 supports 16x2 character based LCD. Data lines and control lines are from Port D.

Connectors:

CPU lines are terminated at two 50 pin FRC header.

Devices and Address

Abbildung in dieser Leseprobe nicht enthalten

MPLAB IDE

MPLAB IDE is a software program that runs on a PC to develop applications for Microchip microcontrollers. It is called an Integrated Development Environment or IDE, because it provides a single integrated "environment" to develop code for embedded microcontrollers.

Implementing Embedded system Design with MPLAB IDE:

A development system for embedded controllers is a set of programs running on a desktop PC to help write, edit, debug, compile (or assemble), link and fuse the hex code into a microcontroller. MPLAB IDE runs on a PC and contains all the components needed to design and deploy embedded systems applications. A typical task for developing an embedded controller application is to create the high level design. From the features and performance desired, decide which PICmicro device is best suited to the application, then design the associated hardware circuitry. After determining which peripherals and pins control the hardware, write the firmware - the software that will control the hardware aspects of the embedded application. A language tool such as an assembler, which directly translate the program into machine code, or a compiler that allows a more natural language for creating programs should be used to write and edit code. Assemblers and compilers help make the code understandable, allowing function labels to identify code routines with variables that have names associated with their use, and with constructs that help organize the code in a maintainable structure.

MPLAB Features:

MPLAB IDE is a Windows® OS based Integrated Development Environment for the PICmicro MCU families. The MPLAB IDE provides the ability to

- Create and edit source code using the built-in editor.
- Assemble, compile and link source code.
- Debug the executable logic by watching program flow with built-in simulator and in real time with in-circuit emulators or in-circuit debuggers.
- Make timing measurements with the simulator or emulator.
- View variables in Watch windows.
- Program firmware into devices with device programmers.

Running MP Lab IDE:

The following are the steps for running MP Lab IDE to enter a new program in embedded C and to compile and debug the program to generate the hex file.

1. Double click on MPLAB IDE icon on the desktop.
2. Project Project Wizard Next
3. Select Device as 16F877A Next
4. Select Active Tool Suit as CCS C compiler for PIC 12/14/16/18. Toolsuite content as CCSC Compiler (ccsc.exe). Location as C:/Program files/Picc/CCSC.exe.
5. Select Tool Suit contents as CCS Compiler (ccsc.exe) Next
6. Click on Browse and create a new folder, select the new folder, enter a file name Save.
7. Next Next Finish
8. File New Enter the C Program in the edit area
9. File Save as Enter file name with extension .c Save.
10. Project add file to project select the filename Open
11. Project Build all
12. Close all windows.

Windows Serial Downloader

PIC Boot Plus:

PIC Boot plus is windows serial Downloader, which is used for downloading the hex file to the PIC 16 series CPU. It supports Hex file format only.

Running PIC Boot Plus:

The following are the steps to run PIC Boot Plus to upload the hex file from PC into the PIC microcontroller.

- Connect Serial cable between the board and PC.
- Double click on PIC Boot Plus icon on the desktop.
- Select port as COM1, Baud rates as 38400 for program burning and 19200 for serial communication. The first baud rate is for program uploading and the second baud rate is for serial port output.
- Click on Search and select the hex file
- Click on Open
- Make the kit on
- Click on Write
- Press Reset switch on the kit to upload the hex file from PC to microcontroller.
- Press the reset button again to execute the loaded program.

This window is just like a hyper terminal, we can view serial port output in this window also.

Windows Win X Talk Serial Output Window

This is a window’s tool to monitor the data input to the PC’s serial port on the screen. The following are the steps to run Win X Talk.

1. Double click on Win X Talk icon on the desktop
2. Select Serial communication port as COM1, Baud rate as 19200, Parity as N, Data bit as 8 and Handshake as None.
3. Click on Open port
4. Click on Talk on the menu bar
5. Click on Talk window
6. Press Reset button on the kit to execute the program and to display the serial output on the screen.

Result:

Familiarized with PIC 16F877 and the peripherals on the board.

EXPERIMENT 2.

BUZZER CONTROL

Aim:

Write an ALP to produce a beep sound of duration 500 msec continuously.

Program Description:

The buzzer is connected to pin RB0.

Program:

// put the jumper J6 in VCC position.

#include<16F877A.h>

#use delay(clock=20000000)

#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)

void main()

{

top: output_high(PIN_b0); //make the buzzer on

delay_ms(500);

output_low(PIN_b0); //make the buzzer off.

delay_ms(500);

goto top;

}

Result:

Wrote an ALP to produce a beep sound of duration 500 msec.
EXPERIMENT 3.

RELAY CONTROL

Aim:

Write an ALP to activate relay with a time interval of 1000 msec.

Program Description:

The relays are connected to pins RC1 and RC2. The latch line is RB1.

Program:

//put the jumper J2 in 12V position .

#include<16f877A.h>

#use delay(clock=20000000)

#use rs232(baud=19200,xmit=PIN_C6,rcv=PIN_C7)

void main()

{

while(1)

{

output_c(0x06); //make both relays 1&2 on. To make relay1 on, output 0x02 and to

// make relay2 on, output 0x04.

output_low(PIN_b1);

output_high(PIN_b1); //latch the signal

delay_ms (1000);

output_c(0x00); // make both relays 1&2 off

output_low(PIN_b1);

output_high(PIN_b1); // latch the signal

delay_ms (1000);

}

}

Result:

Wrote an ALP to activate relays with a time interval of 1000 msec.

EXPERIMENT 4.

WRITING TO LED ARRAY

Aim:

To write an ALP to blink all the 7 LEDs 5 times and then to make on each LED one by one from left to right. Repeat this sequence continuously.

Program Description:

The data lines for LEDs are RD0 to RD7 and the latch line is RB4. The delay between each blinking is 500 m.sec.

Program:

#include<16f877A.h>

#use delay(clock=20000000)

#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)

unsigned int led[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80},i;

void main()

{

while(1)

{

for(i=0;i<5;i++)

{

output_d(0xFF); //make on all LEDs

output_low(PIN_B4);

output_high(PIN_B4); //latch the signal

delay_ms(500);

output_d(0x0); //make off all LEDs

output_low(PIN_B4);

output_high(PIN_B4); //latch the signal

delay_ms(500);

}

for(i=0;i<8;i++)

{

output_d(led[i]); //make on one LED at a time

output_low(PIN_B4);

output_high(PIN_B4); //latch the signal

delay_ms(500);

}

}

}

Result:

Wrote an ALP to blink the 7 LEDs 5 times with a delay of 500 m/sec. and then to make on each LED one by one from right to left.
EXPERIMENT 5.

READING DIP SWITCH

Aim:

To write an ALP to read the DIP switches and display it on the LEDs and on computer screen.

Program Description:

Data lines for DIP switch are RD0 to RD7 and data lines for LED are RD0 to RD7. Read strobe signal for switch is RB6 and latch signal for LED is RB4.

Program:

#include<16F877A.h>

#use delay(clock=20000000)

#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)

unsigned char a;

void main()

{

while(1)

{

output_low(PIN_B6); //make read strobe low

a=input_d(); //read switch status in variable a

output_high(PIN_B6); //make read strobe high

printf("\n\r Read Key Value is %x",a); //print the value of a on screen

output_d(a); //output the value of a to LED’s

output_low(PIN_B4); //make latch low

output_high(PIN_B4); //make latch high

}

}

Result:

Wrote an ALP to read the DIP switch status and to display the read value on the 8 LEDs and on the monitor screen.

[...]

Excerpt out of 62 pages

Details

Title
PIC LAB Manual. Examples for experiments using Microcontrollers
Subtitle
PIC 16F877 and LPC 2148 ARM 7 Trainer Kits
Author
Year
2015
Pages
62
Catalog Number
V313312
ISBN (eBook)
9783668123397
File size
896 KB
Language
English
Tags
manual, examples, microcontrollers, trainer, kits
Quote paper
Anoop B. K. (Author), 2015, PIC LAB Manual. Examples for experiments using Microcontrollers, Munich, GRIN Verlag, https://www.grin.com/document/313312

Comments

  • No comments yet.
Read the ebook
Title: PIC LAB Manual. Examples for experiments using Microcontrollers


Upload papers

Your term paper / thesis:

- Publication as eBook and book
- High royalties for the sales
- Completely free - with ISBN
- It only takes five minutes
- Every paper finds readers

Publish now - it's free