0% found this document useful (0 votes)
37 views25 pages

Dev Board Manual - FINAL

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 25

 

A Product from THE ARELAB 

No part of this document may be reproduced or distributed in any form or by


any means, electronic, mechanical, photocopying, recording, or otherwise or
stored in a database or retrieval system without the prior written permission of
The ARELAB. The programs may be entered, stored, executed in computer
system but they may not be reproduced.

Copyright © 2008 The Advanced Robotics and Electronics Laboratory


Introduction
The Robotics Development Platform is an essenstial and key element
for designing all types of autonomous robots including robots
meant for competitions. This is a compact, cost effective platform
with easy to connect/disconnect options for sensors, motor drives,
switches and LEDs. The difficulty in designing reliable and error
free hardware connections for autonomous robots inhibits the
coding and algorithm development challenge. So keeping that in
the mind, THE ARELAB presents you a Robotics Development platform
DB01 which is equipped with powerful yet cost effective
Microcontroller Phillips P89V51RD2. The In System Programmability
ensures hassle free program transfer; even it is compatible with
Serial to USB converter so you can use your LAPTOP also for
programming.

FEATURES

1. Supports all 40 pin MCS-51 Microcontroller


2. In-System Programming Facility ( with 89V51RD2)
3. 2 input keys
4. Comparator to Interface 8 Sensors
5. 1 Bidirectional Motor Driver with 600mA Max Current
6. 1 Unidirectional Driver ULN2803
7. 2 Servo Motor Connector
8. 2 LED for debugging and Testing
9. Power Supply and reset Switch
10. On Board Power supply section with rectifier, filter and regulator.
11. Power supply Inversion protection.
12. Power supply LED
13. Max 232 and DB-9 Female Connector

DB01              Page 2 
Contents

1. Block Diagram                Page 4 
2. On Board Pin Connections            Page 5 
3. Identifying the components            Page 6 
4. P89V51RD2 Microcontroller            Page 7 
5. Input Keys                  Page 9 
6. Light Emitting Diodes              Page 11 
7. Motor Driving using L293D            Page 11 
8. Motor Driving using ULN2803            Page 15 
9. Sensor Interfacing using LM339           Page 16 
10.RS 232 interfacing.               Page 19 
11.Using Keil Software              Page 23 
12.Transferring the program             Page 24 
13.Troubleshooting                Page 25   

 
 
 
  Note: This manual is based on DB01 kit and includes the Hardware components, their
  details and circuit connections and the use of supplied functions to drive the different
components. It excludes the theory of operation of different components and also how
  to write the driver routines.

 
 

DB01              Page 3 
BLOCK DIAGRAM: 

12 V DC 7805 Voltage Regulator To all LOGIC circuitry


Supply

Fig 1: Power supply Diagram

2 Servo 2 LEDs

2 Switches L293D motor


Driver
P89V51RD2
LM339 Quad 64 KB Flash
1K Byte MAX DB 9
Comparator RS 232 232 Connector
RAM
2 MIPS
8 X Analog
  Input
L293D motor
Driver
 
  Crystal and
Reset
ULN2803 motor
Driver
 
Circuitry

 
  Fig 2: I/O Block Diagram

 
 
 
DB01              Page 4 
Identifying the Components: 
 
 
 
 
 
 
 
 
 
 
  RESET SWITCH

 
 
 
 
 

DB01              Page 5 
 
On Board Pin Connections: 
Name Port Pin Defined as (in DB01.H)
Number
Left Input Key P3.2 L_KEY

Right Input Key P3.3 R_KEY

Left DC motor – input A P0.0 M1_A

Left DC motor – input B P0.1 M1_B

Left DC motor – EN P0.2 M1_EN

Right DC motor – inputA P0.3 M2_A

Right DC motor – EN P0.4 M2_B

Right DC motor – inputB P0.5 M2_EN

RED LED / Servo1 P0.6 LED_RED

GREEN LED / Servo2 P0.7 LED_GREEN

Sensor 4 P1.0 S4

Sensor 2 P1.1 S2

Sensor 3 P1.2 S3

Sensor 1 P1.3 S1

Sensor 7 P1.4 S7

Sensor 8 P1.5 S8

Sensor 5 P1.6 S5

Sensor 6 P1.7 S6

RS 232 RX P3.0 SE_RX

RS 232 TX P3.1 SE_TX

DB01              Page 6 
 
P89V51RD2 Microcontroller: 
The Phillips 89V51RD2 is an 80C51 Microcontroller with 64kB Flash
and 1024 Bytes of data RAM.

GENERAL FEATURES:

• 80C51 Central Processing Unit


• 5 V Operating voltage from 0 to 40 MHz
• 64 kB of on-chip Flash program memory with ISP
• Supports 12-clock (default) or 6-clock mode selection via
software or ISP
• SPI (Serial Peripheral Interface) and enhanced UART
• PCA (Programmable Counter Array) with PWM and Capture/Compare
functions
• Four 8-bit I/O ports with three high-current Port 1 pins (16 mA
each)
• Three 16-bit timers/counters
• Programmable Watchdog timer (WDT)
• Eight interrupt sources with four priority levels
• Second DPTR register
• TTL- and CMOS-compatible logic levels
• Brown-out detection

DB01              Page 7 
Connection Diagram:
The VDD pin is connected to the
+5V Supply Bus. And VSS is
connected to the Ground the
Clocking circuitry is made by an
11.0592 MHz Crystal and two 33 pF
Capacitors. The ‘Power On reset
Circuitry’ consist of one 10UF
capacitor and one 8.2K Resistance.
The remaining port Pins are
connected to various input and
output ports as described by the
Table in Page 5.

Writing the programs for 89V51RD2:


You can program DB01 using assembly or C language. For C
programming we recommend MicroVision 3 by Keil Software. In this
document we will learn the programming of the DB01 board with the
help of C compiler from Keil.
The discussion below illustrates the use of 89V51 using Keil C.
89V51 Have 4 bi-directional I/O Ports for communication with the
external world. They are called as Port 0,Port 1,Port 2 and Port
3. For accessing the ports there are some system registers named
as P0,P1,P2 and P3. These registers are also called SFR or
“Special Function Registers”. There are also some other SFRs which
we will discuss later. These SFRs are defined in a Header file
called “REG52.H”. So we have to include this header file to use
the ports. Here is a sample program which outputs some data in
port1.

#include<reg52.h>
void main ()
{
P1=0x00; /// Send the data 00 in port 1 ///
while (1);
}

* Note: There is nowhere to return after program execution so we have to


write an infinite loop after the program objective ends.

The Delay Function: You will need the function to generate some
time delay. The easiest way of generating the time delay is to
write some loops and inside the loop do nothing. Obviously the
time of execution of the delay routine depends on the
microcontroller execution Speed. In DB01 the clock frequency is

DB01              Page 8 
11.0592 MHz. Depending on this speed the following function
generates delay routine of 1 ms interval.

void Delay(unsigned int tic)


{
char i;
while(tic!=0)
{
i=140;
while(i!=0)
i--;

tic--;
}
}

So we can now write a program which will complement a port pin


after one second.

void main()
{
while(1)
{
P1^0 = ~P1^0;
Delay(1000);
}
}

Note 1: The Delay function is already defined in DB01.H


Note 2: Individual port pins can be accessed by (Port no)^(Bit No)

Interfacing Simple Keys: 

  89V51RD2

Keys act as input device. Keys can be used to operate Menu based
programs or inputting some value or parameters. Only 2 keys have
DB01              Page 9 
been provided in this board to minimize PCB area and also to
minimize the microcontroller pins associated with it. In menu
based programs left and right key can be used to navigate
between menu items. You can input some numeric values also by
these 2 keys (like your digital wrist watch).

Connection and Interfacing: The Switch is connected between


microcontroller pin and ground as shown in the figure. When the
switch is not pressed, the circuit is open and the default
status of the microcontroller pin is high. When the switch is
pressed, the microcontroller pin is pulled to ground. To read
the switch status, you have to set the pin associated with the
switch as “logic 1” or “High” first (for explanations please
refer to microcontroller bidirectional pin and open collector
type behavior from any microcontroller book). For the pin
connection information please refer to the On Board Pin
connections in Page 6.

For interfacing and scanning the two keys we have provided a


function. Once called this function checks the states of these
two keys. If no switch is pressed, it returns 0; else it returns
different codes for each key. For example for Left switch it
returns 1, for Right 3.

unsigned char Scan_Key()


{
L_KEY=1; R_KEY=1;
if(L_KEY==0)
{
while(L_KEY==0); // wait until user releases the key//
return 1;
}
else if(R_KEY==0)
{
while(R_KEY==0); // wait until user releases the key//
return 3;
}

else return 0;
}

For example we want to implement a program in which a count will


be incremented or decremented if the user presses the left or
right key.

void main(void)
{
unsigned char val,count=0;

while(1)

DB01              Page 10 
{
val=Scan_Key();
switch(val)
{
case 1: count++;
break;

case 3: count--;
break;
}
}
}

Light Emitting Diodes: 
The LED is connected to the
microcontroller I/O pin directly and
the microcontroller pins cannot source
current required to drive the LED, but
it can sink the required current. So,
the LED s are connected in such a way
that the LED will glow when the
microcontroller will sink current. The
anode of the LED is connected to Vcc
via a series resistance and the cathode
is directly connected to the pin.

One Red and one Green LED is provided in


the development board. Look at the pin
Port Pin Led configuration table for the pin number. At
Status Status the end of this document, sample codes for
Logic 1 or 5V OFF LED blinking has been provided.
Logic 0 or 0V ON

 
Bipolar Motor Driving: L293D 
L293D is a bipolar motor driver IC. This is a high voltage, high
current push-pull four channel driver compatible to TTL logic
levels and drive inductive loads. It has 600 mA output current
capabilities per channel and internal clamp diodes.

DB01              Page 11 
CONNECTION DIAGRAM FOR DRIVING BIPOLAR STEPPER MOTOR

CONNECTION DIAGRAM FOR DRIVING BIPOLAR DC MOTOR

DB01              Page 12 
As shown below there are connectors provided in the development
board to connect DC motors with L293D. Each connector contains
3pins. The center pin is ground. The left and right pins should be
connected to the two motor terminals. The motor driver has 3 input
pins for each motor. They are EN, A, B. A truth table is provided
below to relate the input conditions with the motor action.

EN A B Motor Action
0 X X Stopped
1 0 0 Brake
1 1 1 Brake
1 0 1 Clockwise
Rotation
1 1 0 Anti-Clockwise
Rotation

Differential Drive robot car with DC motor using L293D

A differential Drive car normally uses 2 drive motors for


Locomotion. Usually the left and the right Rear wheels are being
driven by 2 separate motors. Driving the car and the steering is
possible by controlling the DC motors. Now remember that the two
motors are connected in such a way that one motor is connected in
opposite direction with the other. So turning the left motor
Clockwise and the Right one anti-clockwise will send the car in
the forward direction. Here is a chart given which will map the
Car motion with the control of the Left and the Right Motor.

Left Right Motion


Motor Motor
Stopped Stopped Stopped
CW CCW Forward
CCW CW Backward
CW CW Left Turn
Car Chassis CCW CCW Right
Turn
BRAKE BRAKE Brake

Left Motor Right Motor

DB01              Page 13 
Software Interfacing:

Subroutines are provided for interfacing the DC motors. These


routines will drive the Differential Drive Robot in different
manners.

DCM_Forward(); // drives the Robot in the forward direction ////


DCM_Back(); // drives the Robot in Backward direction //////////
DCM_Left(); // drives the Robot in the left direction //////////
DCM_Right(); // drives the Robot in right direction ////////////
DCM_Stop(); // stops the robot movement ////////////////////////

Software Interfacing:

The following program checks the DC motor drive system. In this


program we have driven the Robot in different combinations and
displayed the status in the LED.

void main()
{
While(1)
{
LED_RED = 1;
LED_GREEN = 1;
DCM_Forward();
Delay(1000);

LED_RED = 0;
LED_GREEN = 0;
DCM_Back();
Delay(1000);

LED_RED = 1;
LED_GREEN = 0;
DCM_Right();
Delay(1000);

LED_RED = 0;
LED_GREEN = 1;
DCM_Left();
Delay(1000);

DCM_Stop();
Delay(1000);
}
}

DB01              Page 14 
Note: If your robot is not moving according to the program (i.e. it is
moving left, but displaying ‘forward’) then there is a connection
problem with the motors, simply reverse one of the motor’s polarity to
solve the problem.

Note: Never make the motor driver terminals short circuited or drive a
motor with load current more than 600 mA. It will damage the IC.

Unipolar Motor Driving: ULN2803 
 
ULN 2803 is a unipolar motor
driver IC with maximum output
voltage 50 V and output current
500 mA. It contains eight
Darlington pair transistors, each
having a peak rating of 600 mA and
can withstand 50 V in off-state.
Outputs may be paralleled for
higher current capability.

ULN 2803 may be used to drive both


DC geared motors as well as
Stepper motors.Connection diagrams
for driving both types of motors
are shown below.

CONNECTION DIAGRAM FOR DRIVING UNIPOLAR DC MOTOR

DB01              Page 15 
CONNECTION DIAGRAM FOR DRIVING UNIPOLAR STEPPER MOTOR

 
Sensor Interfacing: LM339 
Depending on applications, different types of sensors can be
interfaced with this Robotics development Board. Whether the
sensors are Light Dependent Resistors, laser diode, Infrared
Sensors, Ultrasonic Sensors or anything else, the outputs of the
sensor modules are fed to the Non-inverting input of a comparator.
The reference voltage of the comparator is fed to the inverting
input of the comparator by a trim pot or a tuning device connected
between the supply lines. LM339 is a comparator IC that digitizes
the analog signal from the sensor array. Since the output of LM339
is TTL compatible it can be directly fed to the master
microcontroller.

DB01              Page 16 
 
 
 
 
 
 
A single LM339 contains 4 Comparators. 4 sensors can be interfaced
directly with the DB01. A potentiometer is provided in the DB01
for setting the threshold voltage of the comparator. The
potentiometer is 10K and 22 turns. 3 wired interface is provided
to connect the sensors. The three wires are RED (+5V), BLACK
(Analog data Input) and BROWN (Ground).The sensor module should
contain one or more resistive transducer, one pull-up device, and
LEDs for extra illumination. The generalized connection diagram of
Sensor Interfacing with microcontroller is shown below.

Infrared Line Sensor array:

INFRARED MODULE

DB01              Page 17 
LDR Line sensor array:

Identifying the Sensor Socket

S1
S2
S3
S4

The sensor pins are defined in the DB01.H in the names S1, S2, S3,
S4, S5, S6, S7, S8.
Software interfacing:

This program displays the status of sensor connected to socket S1.

void main()
{
while(1)
{
if(S1==1)
{
LED_RED = 0;
}
else
{
DB01              Page 18 
LED_RED = 1;
}

}
}

INTERFACING THE RS 232: 
RS-232 (Recommended Standard 232) is a standard for serial binary
data signals connecting between a DTE (Data Terminal Equipment)
and a DCE (Data Circuit-terminating Equipment). It is commonly
used in computer serial ports.

 
 

In resent computers and laptops however the RS232 is being


replaced by the popular USB port which is more versatile and is a
must need for today’s high speed devices. In contrast, embedded
systems applications are still very much dependant on RS232 as it
is very difficult and expensive to integrate USB protocol in an
embedded systems applications.

To understand and use RS232 in an application requires the


following details.

1) RS232 Voltage levels. 
2) RS 232 Connectors. 
3) Common 8 bit or 9 bit Data framing. 
4) Baud Rate for communication.

RS232 Voltage levels: In RS232 standard the logic 0 or space is


given by any voltage ranging from +3V to +25V and Logic 1 or mark
is given by any voltage from -3V to -25V. See the following
picture.

DB01              Page 19 
 
 
 
 
 
The DB9 connector behind Computers or in typical serial-to-USB
connector exhibits proper RS232 voltage levels. But the in-built
UART (a module present in the microcontroller which can send or
receive data in RS232) present in 8051 microcontroller exhibit a
TTL level voltage. So a TTL to RS232 voltage interfacing circuitry
is needed to interface a microcontroller to a ‘true’ RS232 port of
a PC. MAX 232 is an IC which can interface these voltage logic
levels. A schematic diagram of MAX232 with the necessary
components is given below illustrating the connection between PC
and microcontroller. Although there are 9 pins present in a DB-9
connector, we have used only 3 pins named as GND, TX and RX.

Data Framing:

Although in actual RS232 specifications the data framing is not


defined, but the following data framing is widely used by PC and
UARTs. The idle state of a RS232 TX or RX line is logic 1. When
the transmitter want to send a byte, it sends a start bit (Logic
0), followed by 8 data bits (MSB first) followed by 1 stop bit
(Logic 1). The start and stop bits are needed in this protocol for
synchronization. Sometimes 1 extra bit is send with the data bits

DB01              Page 20 
for error checking/parity or other  purposes. The internal UART
takes care of generating or detecting start or stop bits.

BAUD rate:

The rate of sending the bits (bits/second) is called as ‘Baud


Rate’. For a proper communication, the receiver and the
transmitter should work with same baud rate. When the
communication is in between 2 microcontrollers, any baud rate can
be used. But the RS232 port in the PC works with some fixed rate
only. Available baud rates are 300, 600, 1200, 2400, 4800, 9600,
19200 etc.

Connecting wire:

Db01 can be connected with a PC or another DB01. While connecting


with PC, a straight cable should be used where one end is male and
another end is female type, and Pin no 2, 3, 5 is connected
directly with wires either side. In contrast connecting DB01 with
a similar embedded platform, a cross type cable should be used
where both sides of the connector is male type. Here pin no 5
should be directly connected. Pin no 2 and 3 of the connectors
should be cross connected. It is always preferable to use shielded
connectors. The total length of the connector should not be
greater than 150Feet.

Software interfacing:

RS232 port needs some registers inside the microcontroller to be


initialized after power on. So at the beginning of the program
RS232 initialization should be done. This can be done using the
following function.

void RS232_Init(int BaudRate);


For example: void RS232_Init(9600);
DB01              Page 21 
Transmitting Data:

void RS232_Send(unsigned char data);

This function sends one byte data to the serial port and returns
when the transmission is complete.

Receive Data:

unsigned char RS232_Receive();

This function waits for any data arrival in the serial port, and
returns the received data.

Sample program:

This program transmits the String “HELLO WORLD” in the RS232 port.

void main(void)
{
RS232_Init(9600);
char* str=”HELLO WORLD”;
while(*str)
RS232_Send(*str++)

while(1);
}

For convenience the following function is also provided to


directly send a string into the RS232 port.

Void RS232_String( unsigned char* str);

So, the above example can be done by the following program.

void main(void)
{
RS232_Init(9600);
RS232_Send(“HELLO WORLD”);
while(1);
}

Note:

DB01              Page 22 
1) Only 2400, 4800, 9600 and 19200 baud rates are supported by
the RS232_Init function.

Using the KEIL software: 
For using the Keil software to compile the programs the following
steps should be done.

1. Install and Run Keil Micro vision 3 Software.

2. Click File->New->UVision Project.

3. In the save dialog box Select the file location and name.

4. In the “select devices for Target” tab, select “NXP” from the
left hand list, expand it and select “P89V51RD2”. Click OK.

5. A dialog Box appears. Click OK on it.

6. Click File->New->File. A new File will be created.

7. Write your program and save it with *.C extension.

8. In the right hand side tab “Project Workspace”, right click on


“Target 1”, click on options. A dialog Box appears. Click on the
“Output” tab, check “Create Hex file”. Click Ok.

9. If you want to use “DB01.H” in your project, don’t forget to


paste it in the project directory.

10. After these steps your project workspace is ready. But


there is not any C file included in the project still now. So in
the left hand tab, select and expand “Target 1”, select and
right click on “Source group 1”, click on “add files to group
source group1” then select the C file you have written and
saved, click on OK.

11. It’s the time for compilation. Click on Project-> Rebuild


all target files. Now the hex file is ready. If there are
errors, shown in the bottom tab.

Uploading the HEX file to DB01 
DB01              Page 23 
After successful compilation, the
final output file or the *.hex file
is generated. The hex file can be
found inside the same folder where
the project is saved.

The next step is transferring or


uploading the hex file to the DB01
Kit for testing. For this, connect
DC adapter to the DC socket of the
DB01. The power LED should glow
now.

Next connect the Supplied Serial


cable between DB01 board and your
computer’s serial port. Laptop
users can connect a compatible
Serial to USB converter between one
USB port and DB01.

Now run “NXP.EXE” software. This software should run normally on


Windows Vista or Upper level OS. But Windows Xp or Lower OS users
have to install “Windows Installer 3.1” and “DOT NET FRAMEWORK
2.0” to run this software. If an error message comes, please click
“continue”.

Next comes the settings part. Click on ‘EDIT’ button. The settings
will be enabled. Select device “P89V51RD2” from the list, baud
rate “9600”. For desktop users, the com port number is usually
COM1, but sometimes it differs. For LAPTOP users, the com port is
virtually generated when the USB-Serial converter is inserted.
Make sure the USB-Serial converter’s Driver is properly installed.
To view the COM number in this case, please visit Control Panel-
>Device manager->COM and LPT ports. Get the appropriate COM number
select that COM port in settings.
Now select the Hex file you have created by the browse button.
Note: once you have selected one hex file, the file name and path
is automatically saved and loaded next time. So while burning the
same file again and again, there is no need to select the file.
The final step is clicking the Burn Button located on the TOP LEFT
corner. The software will be ready to communicate with DB01 board.
Message will be displayed as “Press Reset”. After this, pressing
Reset switch in the DB01 board starts the burn procedure. The
software will automatically verify the burn after it is completed.
Audio sound and message will notify if the burn is successful or
not. If the burn is successful, pressing the reset switch in the
DB01 board runs the program.

 
DB01              Page 24 
Troubleshooting: 
Some Troubleshooting techniques are provided below. For
troubleshooting sometimes a multi meter or continuity tester is
required.

Q1: The Power LED is not glowing


Possible Reason1: The DB01 board is not getting the Power supply.
Solution: Check the adapter and insert it properly. Check the solder at
the DC socket also.

Possible Reason2: The adapter’s polarity is reversed.


Solution: Change the adapter polarity and re-check. The polarity of the
adapter should be center positive.

Possible Reason3: The voltage regulator IC 7805 has burnt away.


Solution: Check the voltage between 7805 Pin no 1 and 2, and 2 and 3.
These should be Volt 12 and 5 respectively. If voltage between 1 and 2
is correct, but the other is not, the 7805 is faulty; replace it with a
new one.

Q2: Burn Procedure is not starting after reset.


Possible Reason1: The Serial cable/USB converter is loose.
Solution: Tighten the cables.

Possible Reason2: The serial port of the computer is not responding.


Solutions:
1) Restart NXP.EXE.
2) Remove USB-Serial Converter from USB, reinsert it.
3) Restart computer.
4) Change USB-Serial Converter.

Possible Reason3: The MAX232 IC is damaged.


Solution: Change the IC.

Possible Reason4: PCB fault.


Solution: Contact THE ARELAB for repairing.

Q3: Motor driver IC is getting very hot/motors are not running.


Possible Reason1: The L293D IC is damaged.
Solution: Replace the IC.

DB01              Page 25 

You might also like