Вы находитесь на странице: 1из 17

International Islamic University Malaysia

Kulliyyah of Information and Communication


Technology

(KICT)

Department of Computer Science

(DCS)
Embedded Systems
CSC 4402
SEM 1 2010/2011
Project Title:
“Inter-Microcontroller UART based wireless communication”

Group Member
Name Matric No
Hassen Mohammed Abdallah Alsafi 0629167

DIALLO ABDOULAYE KINDY 0721587

Muhammad Amin bin Hasmuni 0724407

Prepare for:
Salwa Aqeel Mahdi
Table of Contents
Introduction ..................................................................................................................................... 3

Scope ............................................................................................................................................... 3

Objectives ....................................................................................................................................... 3

Requirements .................................................................................................................................. 4

Components Used ........................................................................................................................... 4

Steps to set up the device ................................................................................................................ 7

Problems Faced ............................................................................................................................... 7

Solution Used .................................................................................................................................. 8

UIC00A ........................................................................................................................................... 8

Screenshots of final product............................................................................................................ 9

Appendixes ................................................................................................................................... 10

References ..................................................................................................................................... 17

2
Introduction
Embedded system is usually defined as computer system that is designed to perform one or few
dedicated functions often with real-time computing constraints. Embedded system is controlled
by one or more main processing cores that are typically either microcontroller or digital signal
processing (DSP). The microcontroller is usually designed to handle a particular task, which may
require powerful processors. However, in this project we are using 16f876A as microcontroller,
Arduinoi Dumelimove board and UIC00A programmer.

These components will help us to create the wireless device that named as Inter-Microcontroller
UART communication. It is mainly about sending signal from one remote device to the main
board which is located in other side and it contains some important features such as the switch,
buzzer, LCD’s, LED’s and others.

Scope

This project will be used to control components remotely attached to the mini 28 training kit.
This consists of LED’s, Fans, buzzer and LCD’s which can be controlled from the menu. The
transmitter components will send signal to the receiver in the main board. PCW compiler will be
used to program 16f876A microprocessor and the Arduinoi compiler will be used to program
(Atmega 328 microprocessor on the Arduinoi Dumelimove board. UART communication is a
widely used method of communication between electronic devices. We seek to implement this in
our project. The transmitter will be based on an Atmel microprocessor (Atmega328) which will
be on an Arduino board and the board will contain the shield that we will use to remotely control
the components as well as the transmitter.
We found that programming the 16f876a microcontroller with UIC00A programmer coupled
with the PIC kit 2 software’s can be more convenient than playing around with the jumpers and
trying to program directly on the board. The Arduinoi board is Arduino Duemilanove and the
transmitter/ receiver model is APC220 Radio communication Module.

Objectives
1. To understand the application of embedded microcontroller based System.
3
2. To breach the gap between ICT and Engineering.

3. To understand the background of raw wireless communication

4. To be able to integrate the system with a real world application on hardware platform.
5. To design and implement an embedded system.
6. To provide understanding about embedded system internals.

Requirements
We need the LCD (Liquid Crystal Display) to display menu functions. The options within the
menu are as the following :
 Option 1: LED (Light Emitting Diode) used to turn on the diode number 4.
 Option 2: BUZZER to produce alarming sounds.
 Option 3: LDR (Light Dependant Resistor) beeper used to detect the light sensor.
 Option 4: FAN used to turn on and off the fan.

Components Used
Components

PIC Complier
Ardunio Compiler.
Arduino Duemilanove board.
Input Shield.
Transmitting Components.
Main board(Mini 28) PIC Training Kit
Build in microcontroller(16f876A)
UIC00A programmer.
ACR wireless module.
Table 1: Components of the project

4
However, the following pictures are showing the environment we used to conduct the
implementation of the code:

1. PCW Compiler

Figure1: PCW Compiler


2. Ardunio compiler

Figure2: Ardunio Compiler

5
The following devices are the used remotely to control the main board:

Figure3: Arduino Duemilanove

Figure 4: Input Shield

Figure5: Transmitting Components

6
Figure 6: the main board.

Steps to set up the device


 Connect the external fan to the dual DC-Motor Driver MT1 pin.
 Connect D1, D1 and E1 pins to C2, C1 and C0 pins respectfully.
 Connect the Ground from Buzzer to ground in the microcontroller.
 Connect Q1 from Buzzer to C6.
 Connect A0 to Z1.
 Connect +5v in the LDR to +5v in the microcontroller.
 Connect RS,RW,EN,D4,D5,D6,D7 pins to B1,B2,B0,B4,B5,B6 and B7 respectfully.
 Connect GND, VCC, RXD, and TXD from the ACR wireless to GND, +5v, C4, C5
respectfully in the microcontroller

Problems Faced
 Programming related problems which require more time for understanding and
debugging the code.
 Getting the required components. As we were working on this particular Embedded
Systems project we had to buy extra costly devices outside campus.
 Environment to work was also a big issue as the lab was not available.
 Getting a suitable time where everyone is available and the lab too.

7
Solution Used
For the programming problems and lab issues, we manage to get a device called UIC00A
programmer that helped us to compile the code on the 16f876A chip and then put it back to the
main board.

UIC00A
Using this device can offer the low cost yet reliable and user friendly PIC USB programmer
solutions for developer, hobbyist and students. It is designed to program popular Flash PIC MCU
which includes PIC 12F, PIC16F and PIC18F family. It can also program 16bit PIC MCU. On
board ICSP (In circuit serial Programming) connector offers flexible method to load program. It
supports on board programming which eliminate the frustration of plug-in and plug-out of PIC
MCU. This also allow user to quickly program and debug the source code while the target PIC is
on the development board. Since USB port is commonly available and widely used on Laptop
and Desktop PC, UIC00A is designed to be plug and play with USB connection. This
programmer obtained it power directly from USB connection, thus No external power supply is
required, making it truly portable programmer. This programmer is ideal for field and general
usage. UIC00A offers reliable, high speed programming and free window interface software. In
addition, the device is compatible with windows vista, XP and windows 7.

Figure 7: UIC00A for 28 Pins

8
Figure 8: UIC00A for 28 Pins

Plugging the microcontroller


28-pin Microcontroller
• Plug in the microcontroller at the upper portion of the ZIF socket and turn the slide switch
to label “28/40 Pins” as shown below.

Screenshots of final product

Figure 9: setting up the product 1

9
Figure 9: setting up the product 2

10
Appendix
Main Code (main Board-Receiver)
#include <16f876a.h>
#use delay(clock=20M)
#use rs232(baud=9600,xmit=PIN_C4,rcv=PIN_C5,parity=N,stream=ACC)
#fuses hs,nolvp,nowdt,noprotect
#include <lcd28.c> //we modified the lcd header file to support 28 pin microcontroller
char status; //variable that indicates the character that we will receive through the wireless
transmitter
int menu=1; //variable to indicate where we are in the menu
int led=1; //variable to indicate whether the led is on or off
int buzzer=1; //variable to indicate whether the buzzer is on or off
int servo=1; //variable for fan
int val; //value we receive from the LDR(light dependent resistor) that shows the darkness in a
room
int j; //variable for the for loop
char menustring[30]; //string that displays which menu object we are controlling
char componentstring[30]; //string that shows the status of a component
void main()
{
lcd_init(); //to initialize the lcd
setup_port_a( ALL_ANALOG ); //set port A for analog input
setup_adc( adc_clock_internal );
set_adc_channel( 0 );
strcpy(menustring,"1. LED");
strcpy(componentstring,"Off");
while(1)
{
status = fgetc(ACC); // to receive the character fron the transmitting component
printf(lcd_putc,"\f"); //clear LCD

11
printf(lcd_putc,"%s\n %s",menustring,componentstring); //display the strings on the screen
delay_ms(50);
if(status == 'A') //increment menu variable if we receive an 'A' through the wireless
transmitter
{
menu++;
if(menu==5)
menu=1;
}
if(menu==1 && status=='B') //if the menu choice is 1 and we receive a B we switch on/off
the led by incrementing its variable(led++)
{
led++;
if(led==3)
led=1;
}
if(menu==2 && status=='B') //if the menu choice is 2 and we receive a B we switch on/off
the buzzer by incrementing its variable(buzzer++)
{
{
buzzer++;
if(buzzer==3)
buzzer=1;
}
if(menu==4 && status=='B') //if the menu choice is 4 and we receive a B we switch on/off
the fan by incrementing its variable(servo++)
{
{
servo++;
if(servo==3)

12
servo=1;
}
if(menu==1)
{
strcpy(menustring,"1. LED"); //we change 'menustring' accordingly
if(led==1) //if the led variable is 1
{
strcpy(componentstring,"off"); //we change 'componentstring' accordingly
output_low(PIN_B3); //led is connected to pin B3 and it is switched off
}
if(led==2)
{
strcpy(componentstring,"on"); //we change 'componentstring' accordingly
output_high(PIN_B3); //led switched on
}
}
if(menu==2)
{
strcpy(menustring,"2. BUZZER");
if(buzzer==1)
{
strcpy(componentstring,"off");
output_low(PIN_C6);
}
if(buzzer==2)
{
strcpy(componentstring,"on");
output_high(PIN_C6);
}
}

13
if(menu==3)
{
strcpy(menustring,"3. LDR beeper");
val = read_adc(); //we read the analog value from the LDR
if(val>6)
{
//strcpy(componentstring,("%d",val));
output_low(PIN_C6); //if the val is greater than 6, we swich off the buzzer(connected to
pin C6)
sprintf(componentstring, "%d", val);
}
if(val<=6)
{
//strcpy(componentstring,val);
output_high(PIN_C6); //if the val is lower or equal to 6, we swich on the buzzer(connected
to pin C6)
sprintf(componentstring, "%d beep!", val);
}
}

if(menu==4)
{
strcpy(menustring,"4. FAN");
if(servo==1)
{
strcpy(componentstring,"off");

output_high(PIN_C1);
output_high(PIN_C2);

14
}
if(servo==2)
{
strcpy(componentstring,"on");

output_low(PIN_C1);
output_high(PIN_C2);
}
}

15
Source code for Arduino transmitter
int button_A= 5; //button to control menu - connected to digital pin 5 on the arduino board
(black)
int button_B= 3; //button to select - connected to digital pin 3 on the arduino board (red)
void setup()
{
Serial.begin(9600); //to initialize uart communication with wireless module

pinMode(3, INPUT); //to declare as input


pinMode(5, INPUT); //to declare as input
}
void loop()
{

if(digitalRead(button_A)==0) //if button is pressed (black)


{
Serial.println('A'); //transmit the character 'A' to the main board for processing
delay(100);
}
if(digitalRead(button_B)==0) //if button is pressed (red)
{
Serial.println('B'); //transmit the character 'A' to the main board for processing
delay(100);
}
if(digitalRead(button_A)!=0 && digitalRead(button_B)!=0)
{
Serial.println('X'); //transmit X if no button is pressed
}

16
References
1. UIC00A USB ICSP PIC PROGRAMMER User’s Manual V1.7 User’s Manual.
2. http://www.eetimes.com/design/embedded
3. Embedded System Design By Peter Marwedel.
4. Embedded system applications By Claude Baron, Jean-Claude Geffroy, G. Motet
5. Embedded system design on a shoestring: achieving high performance By Lewin A. R. W.
Edwards.
6. Introduction to Embedded System Design Using Field Programmable Gate Arrays By
Rahul Dubey

17

Вам также может понравиться