0% found this document useful (0 votes)
40 views

EDC-M540-Microprocessor Trainer

The trainer contains an 80386EX microprocessor and supports various I/O devices like LEDs, displays, motors and sensors. It has multiple digital I/O ports that can be configured as inputs or outputs and interfaces to control experiments. Programs can be written in C and uploaded to the trainer's flash disk to interface with the I/O devices.

Uploaded by

amrehmani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

EDC-M540-Microprocessor Trainer

The trainer contains an 80386EX microprocessor and supports various I/O devices like LEDs, displays, motors and sensors. It has multiple digital I/O ports that can be configured as inputs or outputs and interfaces to control experiments. Programs can be written in C and uploaded to the trainer's flash disk to interface with the I/O devices.

Uploaded by

amrehmani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

32-Bit MICROPROCESSOR

TRAINER (80386)
EDC-M540

1
TABLE OF CONTENTS
Introduction ...............................................................................................................................03
Peripheral Hardware .................................................................................................................08
Connecting with the Trainer .....................................................................................................09
Uploading the Files to The Trainer ...........................................................................................15
Creating a New Project .............................................................................................................18
Experiment 1. Controlling the Processor I/O Ports ..................................................................20
Experiment 2. Programmable Peripheral Interface (PPI) .........................................................25
Experiment 3. Communication with PC using UART .............................................................31
Experiment 4. 7-Segment Display ............................................................................................36
Experiment 5. Controlling Character LCD ...............................................................................38
Experiment 6. Controlling Graphical LCD ...............................................................................42
Experiment 7. Controlling Keypad and Joystick ......................................................................47
Experiment 8. Direction Control of DC Motor.........................................................................52
Experiment 9. Direction Control of Stepper Motor ..................................................................56
Experiment 10. Control of R/C Servo Motor............................................................................61
Experiment 11. Analog To Digital Converter...........................................................................64
Experiment 12. Digital to Analog Converter ............................................................................68
Experiment 13. 8-Channel Relay Module ................................................................................71
Experiment 14. Understanding Dot Matrix LED Display ........................................................75
List of Accessories ....................................................................................................................79

2
INTRODUCTION

EDC-M540 Trainer is based on Intel 80386EX processor. This trainer contains a single board
computer (SBC) with XDOS installed. This SBC contains:

• i386EX processor
• 512K Flash Memory, configured as flash disk
• PC compatible serial port
• PC Console Port
• Real Time Clock device, with backup battery, to display date and time
• Programmable Peripheral Interface (82C55A)

Main board of this Training System contains the I/O devices that are commonly used in
projects / applications. Peripheral devices mounted on Main Board are:

• 16-Bit LEDs with Driver


• 4X7-Segment Displays
• DC Motor with H-bridge Driver
• Bi-Polar Stepper Motor with H-bridge Driver
• 128X64 Graphical LCD
• 16X4 Character LCD
• 4X4 Matrix Keypad with 5-way Joystick
• 8-Bit Analog to Digital Converter
• 8-Bit Digital to Analog Converter

Application modules are also included with this training system, namely 8-Channel Relay
Module and 16x8 Dot Matrix LED Module.

i386EX is a 32-bit high performance controller having software compatibility with Intel
80386 family processors. Application programs can be directly uploaded to flash disk(B
drive). Software development is easy to understand and can be done quickly. Programs can
be edited using Borland C++ compiler provided with the trainer.

Compiled programs can be linked to .EXE files and can be uploaded to the trainer using PC
interface software. Uploaded program can be executed/tested using PC console port provided
on the Trainer.

Drive B: is read/write flash disk available to users/students to upload the


programs/applications. 415K flash memory is available to user for uploading the programs.

Note: While uploading program, always take into account the free space available on disk B.
Borland C Compiler supports Windows XP, Windows 7 only. Higher versions of Windows do not
allow direct access to ports.

3
Hardware
This Trainer contains 80386EX based single board computer (SBC). This SBC is pre-
installed with XDOS, a compact operating system for embedded applications. The XDOS
command structure is nearly identical to MS/PC DOS version 3.3. XDOS commands are
performed by the interface software provided with this Training System.

Memory Configuration
The 386Ex processor is configured in real mode with a physical address space of 1 megabyte.
The SRAM is located between 00000H and 7FFFFH, the Flash is between 80000H and
FFFFFH.

Digital I/O Ports


EDC-M540 has many I/O ports. This also contains a fully functional UART. The ports are
configured in groups as described below:

Ports A, B and C are generated by an 82C55 general purpose programmable I/O device
located on SBC. This device is located at I/O Address 60H. Configuration Register I/O
Address 63H.

Port A (J2): I/O Address 60H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PA.7 PA.6 PA.5 PA.4 PA.3 PA.2 PA.1 PA.0
Pin J2-10 J2-9 J2-8 J2-7 J2-6 J2-5 J2-4 J2-3 J2-2 J2-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

Port A can be configured as a group as either inputs or outputs. The default configuration is
all bits inputs. To make all bits output, set bit 4 of I/O address 63H to a zero, preserving the
state of the other bits. Refer to i386EX.H for detailed configuration options for PORT A.

Port B (J3): I/O Address 61H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0
Pin J3-10 J3-9 J3-8 J3-7 J3-6 J3-5 J3-4 J3-3 J3-2 J3-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

Port B can be configured as a group as either inputs or outputs. The default configuration is
all bits outputs. To make all bits input, set bit 1 of I/O address 63H to a zero, preserving the
state of the other bits. Refer to i386EX.H for detailed configuration options for PORT B.

Port C (J8): I/O Address 62H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PC.7 PC.6 PC.5 PC.4 PC.3 PC.2 PC.1 PC.0
Pin J8-10 J8-9 J8-8 J8-7 J8-6 J8-5 J8-4 J8-3 J8-2 J8-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

4
Port C is located at I/O address 62 hex and is configured as 2 groups of 4 bits each. The
default configuration for bits PC.0 to PC.3 is inputs. To make these bits outputs, set bit 0 of
I/O address 63 hex to a zero.

The default configuration for bits PC.4 to PC.7 is outputs. To make these bits inputs, set bit 3
of I/O address 63 hex to a one. When reconfiguring the I/O status of these pins, be sure to
preserve the state of the other bits. Refer to i386EX.H for detailed configuration options for
PORT C.

Ports D and E are generated by a programmable logic chip located on SBC.

Port D (J9): I/O Address FA02H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C N/C N/C PD.3 PD.2 PD.1 PD.0
Pin J9-10 J9-9 J9-8 J9-7 98-6 J9-5 J9-4 J9-3 J9-2 J9-1
Function - - - - - - IN/OUT IN/OUT IN/OUT IN/OUT

Port D is located at I/O address FA02 hex and is configured as a group as either input or
output. The default configuration of Port D is input. To configure Port D as outputs, set bit 0
of I/O address FA00 hex to a one. Refer to i386EX.H for detailed configuration options for
PORT D.

Port E (J10): I/O Address FA03H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C N/C N/C PE.3 PE.2 PE.1 PE.0
Pin J10-10 J10-9 J10-8 J10-7 J10-6 J10-5 J10-4 J10-3 J10-2 J10-1
Function - - - - - - IN/OUT IN/OUT IN/OUT IN/OUT

Port E is located at I/O address FA03 hex and is configured in three groups. The default
configuration is all bits input. To configure PE.0 and PE.1 as output, set bit 1 of I/O address
FA00 to a one. To configure PE.2 as an output, set bit 2 of I/O address FA00 to a one. To
configure PE.3 as an output, set bit 3 of I/O address FA00 to a one. In each case, be sure to
preserve the other bit settings. Refer to i386EX.H for detailed configuration options for
PORT E.

Port F are I/O pins on the i386Ex processor.

Port F (J7): I/O Address F860H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C N/C N/C PF.7 PF.6 PF.5 PF.4
Pin J7-10 J7-9 J7-8 J7-7 J7-6 J7-5 J7-4 J7-3 J7-2 J7-1
Function - - - - - - IN/OUT IN/OUT IN/OUT IN/OUT

The data on Port F can be read by inputting I/O address F860 hex. The default configuration
is all bits input. Each bit of Port F can be individually configured for input or output. To
configure a bit for output, write a zero in that bit position to I/O address F864 hex. To output

5
data on Port F, write the data to address F862 hex. Refer to i386EX.H for detailed
configuration options for PORT F.
Input Address: F860H
Output Address: F862H
Port Direction Register, Bits 4-7: F864h: 0 for output, 1 for input or open drain output.

COM1 is compatible with the UARTs on a PC and the National Semiconductor 16C450
UART.

COM1 (J1): I/O Address 3F8H

Bit 9 8 7 6 5 4 3 2 1 0
Name NC GND NC DTR CTS TXD RTS RXD DSR DCD
Pin J1-10 J1-9 J1-8 J1-7 J1-6 J1-5 J1-4 J1-3 J1-2 J1-1
Function GND GND - OUT IN OUT OUT IN IN IN

COM1 maximum data rate is 115k Baud. COM1 is wired as Data Terminal Equipment
(DTE) for connection to a peripheral such as a modem. This is a fully functional RS-232 port
implementing all of the handshaking and control lines with the exception of the Ring
Indicator input. UART base address is at I/O location 3F8h. To determine the required divisor
for baud, divide 115200 by the required baud rate. Refer to i386EX.H for detailed
configuration options for COM1.

USB – UART
USB to UART converter is provided on EDC-M540. User can use this converter to use
COM1 as a virtual COM port. Virtual COM port drivers are provided with the training
system.

Address/Data Expansion Bus and Extended Bus are the pins of i386EX processor. This
enables user to interface custom I/O devices, like A/D converters, keypad controllers etc to be
interface with i386EX processor. Interrupts can be programmed for specific needs.

Address/Data Expansion Bus (J4)

Bit 9 8 7 6 5 4 3 2 1 0
Name D5 M/IO D6 N/C D7 N/C N/C GND N/C GND
Pin J4-10 J4-9 J4-8 J4-7 J4-6 J4-5 J4-4 J4-3 J4-2 J4-1
Function IN/OUT OUT IN/OUT - IN/OUT - - - - -
Bit 19 18 17 16 15 14 13 12 11 10
Name D0 IOWR D1 IORD D2 RESET D3 D/C D4 W/R
Pin J4-20 J4-19 J4-18 J4-17 J4-16 J4-15 J4-14 J4-13 J4-12 J4-11
Function IN/OUT OUT IN/OUT OUT IN/OUT OUT IN/OUT OUT IN/OUT OUT
Bit 29 28 27 26 25 24 23 22 21 20
Name AD15 AD5 AD16 AD6 AD17 AD7 AD18 AD8 AD19 AD9
Pin J4-30 J4-29 J4-28 J4-27 J4-26 J4-25 J4-24 J4-23 J4-22 J4-21
Function OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT
Bit 39 38 37 36 35 34 33 32 31 30
Name AD10 AD0 AD11 AD1 AD12 AD2 AD13 AD3 AD14 AD4
Pin J4-40 J4-39 J4-38 J4-37 J4-36 J4-35 J4-34 J4-33 J4-32 J4-31
Function OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT

6
Extended Bus (J6)

Bit 9 8 7 6 5 4 3 2 1 0
Name D12 N/C D13 N/C D14 N/C D15 N/C N/C GND
Pin J6-10 J6-9 J6-8 J6-7 J6-6 J6-5 J6-4 J6-3 J6-2 J6-1
Function IN/OUT - IN/OUT - IN/OUT - IN/OUT - - -
Bit 19 18 17 16 15 14 13 12 11 10
Name AD21 AD20 D8 N/C D9 N/C D10 N/C D11 N/C
Pin J6-20 J6-19 J6-18 J6-17 J6-16 J6-15 J6-14 J6-13 J6-12 J6-11
Function OUT OUT IN/OUT - IN/OUT - IN/OUT - IN/OUT -
Bit 25 24 23 22 21 20
Name GND N/C AD24 AD24 AD23 AD22
Pin J6-26 J6-25 J6-24 J6-23 J6-22 J6-21
Function - - OUT OUT OUT OUT

Interrupts (J5)

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C N/C IRQ9 IRQ6 IRQ5 IRQ4 IRQ3
Pin J5-10 J5-9 J5-8 J5-7 J5-6 J5-5 J5-4 J5-3 J5-2 J5-1
Function - - - - - OUT OUT OUT OUT OUT

NOTE: Be careful when using the ports. I/O ports, Address/Data Expansion Bus and Extended
Bus are not buffered. It safe to use them with the devices provided on the Training System EDC-
M540. If any other device is to be interfaced with these I/O ports, then it necessary to use bi-
directional buffer(s). This will ensure the safety of the I/O ports. Failure to do so will result in
permanent damage of the I/O ports, Address/Data Expansion Bus and Extended Bus signals.

7
PERIPHERAL HARDWARE

EDC-M540 contains different peripheral devices. Each device can work in standalone mode,
meaning that it can be used with this Training System and can also be controlled using other
controllers/processors. Each device must be used carefully. I/O voltage levels and data
required must be carefully studied before proceeding. Study the section, related to the device,
carefully before attempting to perform experiments or write application programs.

Following devices are installed on this Training System:

• 128X64 Graphical LCD


• 16X4 Character LCD
• Four 7-Segment Displays
• 16-Bit Monitor LEDs
• DC Motor with optical encoder & direction control
• Stepper motor with drive circuit & direction control
• 4X4 Matrix Keypad with 5-way Joystick
• 8-Bit Analog to Digital Converter
• 8-Bit Digital to Analog Converter

Application Modules are also provided with this Training System:

• 8-Channel Relay Module


• 16x8 Dot Matrix LED Module

8
CONNECTING WITH THE TRAINER

1. User needs to install Borland C ver 4.5 on the PC, provided with the trainer.
2. Borland C supports Windows XP and Windows 7 32-bit environment. Make sure the PC
has the required OS installed.
3. Execute SETUP.EXE file located in BC45 folder. This will install the software in
C:\BC45>.
4. Copy the folder mentioned as i386EX from the software CD provided and paste in the
C:\BC45> folder.
5. Copy i386ex.h file located in i386EX folder to C:\BC45\Include>.
6. Make sure that folder C:\BC45 has full rights, so user can save the programs and other
settings.
7. Do not TURN ON the trainer.
8. Connect PC Console port to the PC USB port using USB cable provided with the trainer.
9. This will prompt for the installation of Virtual COM port drivers.
10. Open device manager and provide the path for the drivers as shown in Fig. A

Fig. A

11. Provide the path for the location of the drivers, provided with this trainer as shown in Fig.
B

9
Fig. B

12. Upon successful installation of the USB Serial converter, user will get the message as
shown in Fig. C

Fig. C

10
13. Now the USB Serial Port drivers need to be installed. Device manager will mark this as
shown in Fig. D

Fig. D

14. Choose Update Driver Software option and provide the same path as mentioned Fig. B.
15. System will install the drivers and a new USB Serial Port(COM3) will appear in the
system as shown in Fig. E
16. This port can be used as a fully functional COM port using USB port of the PC.

11
Fig. E

17. Execute hypertrm.exe (hyper terminal software) located in Hyperterminal folder.


18. Name his connection as i386 and choose COM3 for communication.
19. Set Bits Per Second(BAUD):57600 and Flow Control:None and press OK button as
shown in Fig. F

Fig. F

12
20. Now user is connected to the trainer through COM3 port.
21. Now TURN ON the trainer, and press RESET button, it will display welcome message as
shown in Fig. G.

Fig. G
22. Change the date of the trainer to the current date using date command, as shown in Fig.
G. It is important to change the date because if the date of the trainer does not match with
the date of your PC, then the trainer will not allow to upload programs to its memory.
23. Once the date is set then the user is ready to list the directory of the trainer. List the
directory and the trainer will display the stored files in the memory and the remaining
storage available to upload other programs as shown in Fig. H
24. Some programs are uploaded to the trainer during testing procedure. User must delete all
the .EXE files before using the trainer. Files can deleted using del command as shown in
Fig. H
25. When directory is listed the last line mentions the number of files in the disk, bytes
utilized and the free bytes available to upload other programs, as highlighted in Fig. H
26. This features allows users to upload multiple files to the trainer.
27. .EXE file uploaded to the trainer must not exceed the free bytes remaining. Always check
the remaining free bytes before uploading the file.

Note: Each time the trainer is turned OFF, date must be set by using date command.

13
Fig. H

14
UPLOADING THE FILES TO THE TRAINER

Hyper Terminal is used to interface with the operating system of the trainer. This operating
system controls the functions that can be performed on flash disk, like list directory, run
program, delete file and upload file. Sample programs for testing/evaluation of the trainer are
provided with the trainer. User can upload the sample .EXE files to the trainer using UP
command. Once the file is uploaded to the trainer, it can be executed.

While the trainer is connected to the PC through PC Console port using Hyper Terminal, as
mentioned in the previous section.

1. Files are transferred to the trainer using Xmodem protocol provided by Hyper Terminal.
2. i386EX folder contains the .EXE files for all the sample programs.
3. In order to upload .EXE file to the trainer, user must type UP command followed by the
file name and press enter key as shown in Fig. I

Fig. I

4. Trainer will wait for the path to be given by the user.


5. User must select Transfer – Send File option from the file menu of Hyper Terminal.
6. For protocol user must select Xmodem and then press Browse button to provide the path
to the .EXE file as shown in Fig. I
7. Once the .EXE is selected, press Open and then press Send button to start the transfer
process as shown in Fig. J
8. Xmodem will display the transfer status, as shown in Fig.J

15
Fig. J

9. After the completion of uploading, trainer will display prompt sign. Use dir command to
list the uploaded file and to check the remaining bytes as shown in Fig. K

Fig. K

10. Now to execute the .EXE file uploaded, simply type the name of the uploaded file and
press Enter key as shown in Fig. L

16
Fig. L

11. Follow the instructions mentioned by the program to get the required results.
12. To exit from the program either press Enter key or Esc key.
13. If the program gets stuck somewhere, simply press the RESET button given on the trainer
to restore the trainer to its normal position.

17
CREATING A NEW PROJECT

1. Borland C++ ver 4.52 compiler is provided with this trainer. Using this software, users
can create their own .exe file to be executed on the Trainer.
2. As mentioned earlier, user must install the software to the PC.
3. Now copy i386EX folder, provided with the trainer, to C:\BC45 folder. i386EX Folder
contains the sample projects with source code and their respective .exe files.
4. Copy i386EX.H file to C:\BC45\INCLUDE folder.
5. Select C:\BC45\BIN\BCW.EXE to execute the Borland C++ IDE.
6. For ease create a shortcut for BCW.EXE on your desktop or Quick Launch Bar.
7. In order to start a new project run Borland C++ file and select Project -> New Project
option. A window will appear as shown in Fig. M
8. In Target Type window Application[.exe] is selected by default.
9. Choose DOS(Standard) from Platform drop down menu, as shown in Fig. M

Fig. M Creating New Project

18
10. Now press Advanced button and choose .c Node and press OK button as shown in Fig. N
11. Now choose a path and name for the project and press OK button to create .c file and
other files related to the project.

Fig. N Advanced Option

12. Sample programs are provided with this Trainer. These sample programs are located in
C:\BC45\i386EX directory. When writing your own programs, follow the pattern used in
sample programs to properly execute/terminate the programs on EDC-M540.
13. Datasheets for the devices used in EDC-M540 are also included with the BC compiler.
These datasheets are in \Datasheet folder.
14. Header file i386EX.h must be copied to C:\BC45\INCLUDE\ folder.
15. To open and existing project simply select Project –> Open Project and browse to path
C:\BC45\i386EX and select the relevant folder and select .IDE file.

19
EXPERIMENT 1
CONTROLLING THE PROCESSOR I/O PORTS

Objective:
To understand the functionality of I/O Ports

Theory:
Input / Output (I/O) ports are an important part of any microprocessor system. This enables
the microprocessor to talk to the outside world. Based on the information provided by the I/O
ports, the processor/program decides to take certain actions. These actions are also
represented by the change caused in I/O ports. This also enables the microprocessor to
control different devices like Floppy Disk controller, Hard Disk Controllers, A/D converters
and printers etc.

The Intel386 EX microprocessor has three 8-bit, general-purpose I/O ports. All port pins are
bidirectional, with TTL-level inputs and CMOS-level outputs. All pins have both a standard
operating mode and a peripheral mode (a multiplexed function), and all have similar sets of
control registers located in I/O address space. These ports are used in SBC to control the
functionality of SBC. Only PortF (4-Bit) is available to the user.

PORT F
Port F is a processor I/O port. This port is a 4-Bit port and each bit can be used for I/O.
Sample program is menu driven software and it allows user to send/receive to each I/O.

In order to input data from Port F we will use F860H I/O address. In order to write data to
Port F we will use F862H I/O address. Each bit of Port F can be individually configured for
input or output. Port F direction Control register is located at F864H I/O address. Table 1-1
shows the configuration of the header used for Port F.

Port F (J7)

Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C PF.7 PF.6 PF.5 PF.4
Pin J7-8 J7-7 J7-6 J7-5 J7-4 J7-3 J7-2 J7-1
Function - - - - IN IN IN IN

Table 1-1

Upon power on reset all bits of Port F are configured as Input Port. To configure a bit for
output, write a zero in that bit position to I/O address F864H. Table1-2 tabulates some Port
Direction combinations for Port F.

Port Direction Configuration Register is located at F864h. Using this register direction of
each bit of Port F can be set as input or output as shown in Table1-2. User can calculate the
value of Port Direction Register for setting the direction (Input or Output) of each bit of Port
F. Output/Input to/from Port F will be observed on the header pins as mentioned in Table 1-1.

20
Port Direction Configuration Register F864h

Hex
Bit 7 6 5 4 3 2 1 0
Value
Port F Bit Name PF.7 PF.6 PF.5 PF.4
Function IN IN IN IN 0 0 0 0
Port Direction Register F864h 1 1 1 1 0 0 0 0 F0h
Function IN OUT OUT IN - - - -
Port Direction Register F864h 1 0 0 1 0 0 0 0 90h
Function OUT OUT OUT OUT 0 0 0 0
Port Direction Register F864h 0 0 0 0 0 0 0 0 00h

Table 1-2

Lower nibble of F864h will be all zeroes. Upper nibble of Port F (PF.4 ~ PF.7) is used for
data input/output direction control.

PORT D & E
Port D & E are generated by a programmable device. Port D is located at I/O address FA02h
and is configured as a group as either input or output as shown in Table 1-3. The default
configuration of Port D is input. To configure Port D as outputs, set bit 0 of I/O address
FA00h to a one.

Port D (J9): I/O Address FA02H


Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C PD.3 PD.2 PD.1 PD.0
Pin J9-8 J9-7 J8-6 J8-5 J9-4 J9-3 J9-2 J9-1
Function - - - - IN IN IN IN

Table 1-3

Port E is located at I/O address FA03 hex and is configured in three groups. The default
configuration is input as shown in Table 1-4. To configure PE.0 and PE.1 as output, set bit 1
of I/O address FA00h to a one. To configure PE.2 as an output, set bit 2 of I/O address
FA00h to a one. To configure PE.3 as an output, set bit 3 of I/O address FA00h to a one. In
each case, be sure to preserve the other bit settings.

Port E (J10): I/O Address FA03H

Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C PE.3 PE.2 PE.1 PE.0
Pin J10-8 J10-7 J10-6 J10-5 J10-4 J10-3 J10-2 J10-1
Function - - - - IN IN IN IN

Table 1-4

Port Direction Configuration register is located at FA00h. Using this register direction of the
port/bits can be set as input or output. Table 1-5 shows the values of direction control for
FA00h register.

21
Port Direction Configuration Register FA00h

Bit 7 6 5 4 3 2 1 0 Hex
Value
Name - - - - FA00.3 FA00.2 FA00.1 FA00.0
Port D&E Input 1 1 1 1 0 0 0 0 F0h
Port D Output
1 1 1 1 0 0 0 1 F1h
Port E Input
PE.0 & PE.1
Output 1 1 1 1 0 0 1 0 F2h
Port D Input
PE.2 Output
PE.0, PE.1 &
1 1 1 1 0 1 0 0 F4h
PE.3 Input
Port D Input
PE.3 Output
Port D Input 1 1 1 1 1 0 0 0 F8h
PE.0 ~ PE.2 Input

Table1-5

Any combination can be implemented, but remember to preserve the previous status of bits
when changing the value of port direction register.

16 LEDs with drive circuit are provided on EDC-M540 to monitor the logic values of I/O
Ports. These LEDs are connected to 10-pin header J21 and J22 as shown in Table 1-6 and 1-7
respectively.

LED Connector (J21):


Bit 7 6 5 4 3 2 1 0
Name L7 L6 L5 L4 L3 L2 L1 L0
Pin J21-8 J21-7 J21-6 J21-5 J21-4 J21-3 J21-2 J21-1
Function IN IN IN IN IN IN IN IN

Table 1-6

LED Connector (J22):


Bit 7 6 5 4 3 2 1 0
Name L15 L14 L13 L12 L11 L10 L9 L8
Pin J22-8 J22-7 J22-6 J22-5 J22-4 J22-3 J22-2 J22-1
Function IN IN IN IN IN IN IN IN

Table 1-7

22
8-Bit DIP Switch

8-Bit DIP Switch is also provided with the Trainer, as shown in Fig. 1.1. DIP switch will be
placed on External I/O Interface Module area. When the DIP switch is at ON position, it will
output HI.

Fig. 1.1 8-Bit DIP Switch

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project basic_io.ide located in
c:\bc45\examples\i386EX\basic_io.
5. Select option Project -> Build All. This will compile the program and will create
basic_io.exe file.
6. Upload the basic_io.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Execute the program. Program menu will be displayed in interface software window as
shown below:

Press Enter to Return to Main Menu...


Press ESC to Exit...

1- PORT D & E TEST


2- PORT F Output TEST

9. Connect Port D(J9) to PORT E(J10) using 10-pin data cable. Port D is configured as an
Output Port, while Port E is configured as an Input Port.
10. Press key 1 to select option 1.
11. Program will send data to Port D and will input data received at Port E.
12. Sent and Received data will be displayed by the program.
13. Press Enter key to return to prompt.

23
14. Connect 8-Bit DIP Switch connector to LEDs(J21) using 10-pin IDC cable.
15. Set all switches to low position.
16. Set switch 1 to ON position. Corresponding LED will be ON.
17. Similarly, all switches can be checked.
18. DIP switches can be used as input for any port available on the Trainer.
19. Connect Port F(J7) to LEDs(J21) using 10-pin data cable. Port F is configured as an
output port.
20. Press key 2 to select option 2. Program will send data to Port F and it can be verified by
the status of the LEDs.
21. Press Enter key to return to prompt.
22. Press Esc key to exit from program.

24
EXPERIMENT 2
PROGRAMMABLE PERIPHERAL INTERFACE (PPI)

Objective:
To understand the working of Programmable Peripheral Interface (PPI)

Theory:
Microprocessors do not have any I/O ports to communicate with the peripheral devices.
Programmable Peripheral Interface, commonly known a PPI, is a general purpose
programmable I/O device which may be used with many different microprocessors. There are
24 I/O pins which may be individually programmed in 2 groups of 12 and used in 3 major
modes of operation. This device is interfaced with the microprocessor and provides three
fully functional 8-Bit I/O ports to the microprocessor. Functionality of these I/O ports is
controlled by the microprocessor. Fig. 2.1 shows the functional diagram of PPI.

Fig. 2.1 82C55A Functional Diagram

Data Bus Buffer (D0 ~ D7)


This three-state bi-directional 8-bit buffer is used to interface the PPI (82C55A) to the system
data bus. Data is transmitted or received by the buffer upon execution of input or output
instructions by the CPU. Control words and status information are also transferred through
the data bus buffer.

25
Read/Write and Control Logic
The function of this block is to manage all of the internal and external transfers of both Data
and Control or Status words. It accepts inputs from the CPU Address and Control busses and
in turn, issues commands to both of the Control Groups.

(CS) Chip Select. A “low” on this input pin enables the communication between the 82C55A
and the CPU. This pin connected to the address decoding logic O/P.

(RD) Read. A “low” on this input pin enables 82C55A to send the data or status information
to the CPU on the data bus. In essence, it allows the CPU to “read from” the 82C55A.

(WR) Write. A “low” on this input pin enables the CPU to write data or control words into
the 82C55A.

(A0 and A1) Port Select 0 and Port Select 1. These input signals, in conjunction with the RD
and WR inputs, control the selection of one of the three ports or the control word register as
tabulated in Table2-1. They are connected to the least significant bits of the microprocessor
address bus (A0 and A1).

PPI Basic Operations

INPUT OPERATION (READ)


A1 A0 RD WR CS Operation Performed
0 0 0 1 0 Port A to Data Bus
0 1 0 1 0 Port B to Data Bus
1 0 0 1 0 Port C to Data Bus
1 1 0 1 0 Control Word to Data Bus
INPUT OPERATION (WRITE)
A1 A0 RD WR CS Operation Performed
0 0 1 0 0 Data Bus to Port A
0 1 1 0 0 Data Bus to Port B
1 0 1 0 0 Data Bus to Port C
1 1 1 0 0 Data Bus to Control Word

Table 2-1

(RESET) Reset. A “high” on this input initializes the control register to 9Bh and all ports (A,
B, C) are set to the input mode. “Bus hold” devices internal to the 82C55A will hold the I/O
port inputs to a logic “1” state with a maximum hold current of 400µA.

Port A One 8-bit data output latch/buffer and one 8-bit data input latch. Both “pull-up” and
“pull-down” bus-hold devices are present on Port A.

Port B One 8-bit data input/output latch/buffer and one 8-bit data input buffer.

Port C One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input).
This port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains

26
a 4-bit latch and it can be used for the control signal output and status signal inputs in
conjunction with ports A and B.
Group A and Group B Controls
The functional configuration of each port is programmed by the systems software. In essence,
the CPU “outputs” a control word to the 82C55A. The control word contains information
such as “mode”, “bit set”, “bit reset”, etc., that initializes the functional configuration of the
82C55A.

Control Group A: Port A and Port C upper (C7 - C4)


Control Group B: Port B and Port C lower (C3 - C0)

The control word register can be both written and read as tabulated in Table 2-1. Fig. 2.2
shows the control word format for both Read and Write operations. When the control word is
read, bit D7 will always be at logic “1”, as this implies control word mode information.

Control Word

Fig. 2.2 Mode Definition

Mode Selection
There are three basic modes of operation than can be selected by the system software:
Mode 0 - Basic Input/Output
Mode 1 - Strobed Input/Output
Mode 2 - Bi-directional Bus

When the reset input goes “high”, all ports will be set to the input mode with all 24 port lines
held at a logic “one” level by internal bus hold devices. After the reset is removed, the
82C55A can remain in the input mode with no additional initialization required.

27
The control word register will contain 9Bh. Any port programmed as an output port is
initialized to all zeros when the control word is written.
The modes for Port A and Port B can be separately defined, while Port C is divided into two
portions as required by the Port A and Port B definitions. All of the output registers,
including the status flip-flops, will be reset whenever the mode is changed. Modes may be
combined so that their functional definition can be “tailored” to almost any I/O structure.
For instance: Group B can be programmed in Mode 0 to monitor simple switch closings or
display computational results. Group A could be programmed in Mode 1 to monitor a
keyboard or tape reader on an interrupt-driven basis.

Mode 0 (Basic Input / Output)


This functional configuration provides simple input and output operations for each of the
three ports. No handshaking is required data is simply written to or read from a specific port.

Mode 0 Basic Functional Definitions:


• Two 8-bit ports and two 4-bit ports
• Any Port can be input or output
• Outputs are latched
• Input are not latched
• 16 different Input/Output configurations possible

Note: PPI is used in Mode 0 to perform the experiments listed in this manual. Mode 0
definitions and Mode 0 combinations are listed in i386EX.h file. For more details related to
82C55A device, refer to the datasheet of the device.

Port C Single Bit Set/Reset Feature


When PPI is programmed to be used in Mode 0 any of the eight bits of Port C can be Set or
Reset using a single output instruction sent to Control word as shown in Fig. 2.3. This feature
reduces software requirements in control-based applications. When Port C is being used as
status/control for Port A or B, these bits can be set or reset by using the Bit Set/Reset
operation just as if they were output ports. Refer to i386EX.h file for control word
configuration to use this feature.

28
Control Word

Fig. 2.3 BIT SET/RESET Format

EDC-M540 contains a PPI device mounted on SBC. Upon Reset PPI is configured as:
Port A: Input
Port B: Output
Port C: PC.0 ~ PC.3 – Input
PC.4 ~ PC.7 – Output

Port A is decoded at 60H and is terminated at 10-pin header J2 as mentioned in Table 2-2.

Port A (J2): I/O Address 60H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PA.7 PA.6 PA.5 PA.4 PA.3 PA.2 PA.1 PA.0
Pin J2-10 J2-9 J2-8 J2-7 J2-6 J2-5 J2-4 J2-3 J2-2 J2-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

Table 2-2

Port A is decoded at 61H and is terminated at 10-pin header J3 as mentioned in Table 2-3.

Port B (J3): I/O Address 61H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0
Pin J3-10 J3-9 J3-8 J3-7 J3-6 J3-5 J3-4 J3-3 J3-2 J3-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

Table 2-3

Port A is decoded at 62H and is terminated at 10-pin header J8 as mentioned in Table 2-4.

29
Port C (J8): I/O Address 62H

Bit 9 8 7 6 5 4 3 2 1 0
Name N/C N/C PC.7 PC.6 PC.5 PC.4 PC.3 PC.2 PC.1 PC.0
Pin J8-10 J8-9 J8-8 J8-7 J8-6 J8-5 J8-4 J8-3 J8-2 J8-1
Function - - IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT

Table 2-4

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project 82C55A.ide located in c:\bc45\i386EX\85C55.
5. Selection option Project -> Build All. This will compile the program and will create
82C55A.exe file.
6. Upload the 82C55A.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Execute the program. Program menu will be displayed in interface software window
as shown below:

Press Enter to Return to Main Menu...


Press ESC to Exit…
82C55A TEST MENU
1- PORT A TEST
2- PORT B TEST
3- PORT C TEST

9. Connect PortA(J2) to PortB(J3) using 10-pin data cable. Port A is configured as an Input
Port, while Port B is configured as an Output Port.
10. Press key 1 to select option 1.
11. Program will display data sent by Port B and will display data received at Port A.
12. Press Enter key to return to Main Menu.
13. Connect PortB(J3) to LEDs(J21) using 10-pin data cable.
14. Port B is configured as an output port.
15. Press key 2 to select option 2. Program will send data to Port B and it can be verified by
the LED’s status.
16. Press Enter key to return to Main Menu.
17. Connect PortC(J8) to LEDs(J22) using 10-pin data cable.
18. Port C is configured as an Output Port.
19. Press key 3 to select option 3. Program will send data to Port C and it can be verified by
the LED status.
20. Press Enter key to return to Main Menu.
21. Press Esc key to exit from program.

30
EXPERIMENT 3
COMMUNICATION WITH PC USING UART

Objective:
To understand the communication with PC using UART

Theory:
Communication (COM) port is used to send/receive asynchronous data to/from
microprocessor. COM port or Serial port is an industry standard. COM port is used by many
devices, like modems, routers, switches, personal computers, GPS modules, serial LCD’s,
digital multi-meters and GSM modules etc for data transfer.

MS-DOS and Windows environment refer to serial ports as COM ports. EDC-M540 contains
a fully functional UART equivalent to National Semiconductor 16C450 UART. This UART
is located at I/O address 3F8h. UART contains 7 registers for configuration / status
indication. Location of internal register at I/O address is tabulated in Table 3-1.

Register I/O Address Location

Register I/O
DLAB A2 A1 A0 Register
Address
0 0 0 0 Receiver buffer (read), transmitter holding register (write) / 3F8h
Divisor Latch Low (DATA)
0 0 0 1 Interrupt enable / Divisor Latch High (IER) 3F9h
X 0 1 0 Interrupt identification (read only) / (IER) 3FAh
X 0 1 1 Line control register(LCR) 3FBh
X 1 0 0 Modem control register(MCR) 3FCh
X 1 0 1 Line status register(LSR) 3FDh
X 1 1 0 Modem status register(MSR) 3FEh
X 1 1 1 Scratch 3FFh
1 0 0 0 Divisor latch (LSB)
1 0 0 1 Divisor latch (MSB)

Table 3-1

Details related to UART configuration and control registers are tabulated in Table 3-3. By
using these configuration registers user can control the functionality of UART.

When the high bit of the LCR (DLA) is set, the divisor value can be written to DATA and
IER. DATA contains the low byte and IER contains the high byte. To determine the required
divisor, divide 115200 by the required baud rate. Program the divisor with the nearest integer
value. When access to the divisor value is no longer required, clear the DLA bit.

UART base address is at I/O location 3F8h and it is named as COM1 (J1). COM1 pins are
connected to 10-pin header J1 as shown in Table 3-2.

UART – USB converter is also provided on the trainer, so data from the EDC-M540 UART
can be transferred to PC using standard USB port. When connected to PC, this will create a
virtual COM port.

31
COM1 (J1): I/O Address 3F8H

Bit 9 8 7 6 5 4 3 2 1 0
Name NC GND NC DTR CTS TXD RTS RXD DSR DCD
Pin J1-10 J1-9 J1-8 J1-7 J1-6 J1-5 J1-4 J1-3 J1-2 J1-1
Function GND GND - OUT IN OUT OUT IN IN IN

Table 3-2

UART Register Configuration

7 6 5 4 3 2 1 0
Base Receive/Transmit Holding Register / Divisor Latch Low (DATA)
Data In, Data Out
Base+1 Interrupt Enable Register / Divisor Latch High (IER)
0 0 0 0 Modem Receive Transmit Receive
Status Line Status Buffer Buffer Full
Empty
Base+2 Interrupt Identification Register (IIR)
Reserved Reserved Reserved Reserved Reserved Interrupt Source: Interrupt
00=Modem Status Pending
0=Pending
01=Transmit Buffer empty
1=Not
10=Receive Buffer Full
Pending
11=Receiver Line Status
Base+3 Line Control Register (LCR)
Divisor Send Parity: Stop Bits: Word Length:
Latch Break 000=None, 001=Odd, 011=Even, 0=1, 1=2 00=5, 01=6
Access
101=Mark, 111=Space 10=7, 11=8
Base+4 Modem Control Register (MCR)
0 0 0 Loop Ext. Int. Out1 RTS DTR
Back Enable
Test
Base+5 Line Status Register (LSR)
Reserved Transmit Transmit Break Framing Parity Error Overrun Receive
Register Buffer Interrupt Error Error Buffer Full
Empty Empty
Base+6 Modem Status Register (MSR)
DCD RI DSR CTS D D D D
DCD RI DSR CTS

Table 3-3

32
Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project UART_EX.ide located in
c:\bc45\i386EX\UART.
5. Selection option Project -> Build All. This will compile the program and will create
UART_EX.exe file.
6. Upload the UART_EX.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Connect COM1(J1) to RS-232 I/P(J27) using 10-pin data cable. This will connect COM1
to UART – USB converter.
9. Connect UART – USB section to PC using USB cable.
10. This will install Virtual Serial Port drivers to the PC. This can be verified using Device
Manager, as this will show COM4 port under Ports(COM & LPT) section, as shown in
Fig. 3-1

Fig. 3-1

11. Start another session of Hyper Terminal by executing hypertrm.exe and select COM4 for
communication as shown in Fig. 3-2.
12. Select the Port Settings as shown in Fig. 3-3.
Bits per Second: 57600
Hardware Control: None

33
Fig. 3-2

Fig. 3-3

34
23. Now tile both the sessions of Hyper Terminal horizontally and execute the program
UART.exe in i386 Hyper Terminal window. Program menu will be displayed in interface
software window as shown below:

Press ESC to Exit...


Connect COM1 (J1) to RS-232 I/P(J27)
Program will echo the data typed in PC COM Port window…

13. Now type some letters or numbers inside the UART Hyper Terminal window.
14. ASCII value of the letter or number typed in this window is displayed in the i386 Hyper
Terminal window and the same letter is echoed in UART Hyper Terminal window, as
shown in Fig. 3-3

Fig. 3-3

15. Program keeps checking the receive buffer status of the EDC-M540 UART located at
03F8H. When we transmit data using PC COM4 port, then this data is received by the
UART and this data is transmitted back to PC COM4 port by the UART located at
03F8H.
16. Press Disconnect icon to disconnect from PC COM4 Port and close the Hyper Terminal
Session.
17. Press Esc key to exit from the program.

35
EXPERIMENT 4
7- SEGMENT DISPLAY

Objective:
To understand the concept multiplexing 7-segment displays

Theory:
7-segment is an important display device that is used to display information readable for
common user. Several 7-segment displays can be connected in a system. Each 7-segment
display has 7-segments that contain LED and one decimal point, so 8-bit port is needed to
display data on 7-segment display. These displays are either common Anode or common
Cathode type.

In order to display data on multiple displays, we need to multiplex them using single 8-bit
data port. EDC-M540 has four common Anode type 7-segment displays. Data pins of all the
displays are connected together. We can control the ON or OFF behavior of the display by
controlling their common Anode pins. So we will assign 8-bit port for 7-segment and a 4-bit
port to control common Anode pins.

7-Segment Control (J19):

Bit 7 6 5 4 3 2 1 0
Name D4 D3 D2 D1
Pin J19-8 J19-7 J19-6 J19-5 J19-4 J19-3 J19-2 J19-1
Function N/C N/C N/C N/C D4 D3 D2 D1
Table 4-1
7-Segment Display (J20):

Bit 7 6 5 4 3 2 1 0
Name 8 4 2 1 8 4 2 1
Pin J20-8 J20-7 J20-6 J20-5 J20-4 J20-3 J20-2 J20-1
Function Dp a B c d e f g
Table 4-2

LED segments are arranged on the 7-segment display as shown in the Fig. 4-1. User can
display different combination on 7-segment by turning ON or turning OFF each segment.

Fig. 4-1

36
Table 4-3 tabulates the possible data that can be displayed on 7-segment display.

Display dp A B C D E F G Hex
Data Value
0 1 0 0 0 0 0 0 1 0x81
1 1 1 0 0 1 1 1 1 0xCF
2 1 0 0 1 0 0 1 0 0x92
3 1 0 0 0 0 1 1 0 0x86
4 1 1 0 0 1 1 0 0 0xCC
5 1 0 1 0 0 1 0 0 0xA4
6 1 0 1 0 0 0 0 0 0xA0
7 1 0 0 0 1 1 1 1 0x8F
8 1 0 0 0 0 0 0 0 0x80
9 1 0 0 0 0 1 0 0 0x84
A 1 0 0 0 1 0 0 0 0x88
b 1 1 1 0 0 0 0 0 0xE0
C 1 0 1 1 0 0 0 0 0xB1
D 1 1 0 0 0 0 1 0 0xC2
E 1 0 1 1 0 0 0 0 0xB0
F 1 0 1 1 1 0 0 0 0xB8
dp 0 1 1 1 1 1 1 1 0x7F
TABLE 4-3

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project Seg7.ide located in c:\bc45\i386EX\7Segment.
5. Selection option Project -> Build All. This will compile the program and will create
seg7.exe file.
6. Upload the seg7.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Connect Port C(J8) to J19 and Port A(J2) to J20 using 10-bit data cable.
9. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect Port C(J8) to J19


Connect Port A(J2) to J20

Press ESC to Exit...

10. After a delay of 2sec the program will start to send the data to each 7-segment as
mentioned in Table 4-3.
11. Verify that the data displayed is according to the calculated values.
12. Press Esc key to exit from program.

37
EXPERIMENT 5
CONTROLLING CHARACTER LCD

Objective:
To Control Character LCD using 82C55A Device

Theory:
Character LCD module is based on S6A0069 dot matrix LCD driver & controller. This
controller is versatile device. Character LCD module used in this training system is a 16X4
module, which means it has 16 characters and 4 lines. Using this module, we can display 5X7
dots character. This module is pre-programmed such that character displayed is equivalent to
ASCII code of that character. So we can display letter ‘a’ by sending 41h to its data bus.

As with other devices, this also contains data bus and control signals. Table 5-1 tabulates the
functions of control signals:

LCD Control Signals

RS R/W E Operation Performed


0 0 1 Instruction Write operation (MPU writes Instruction code into IR)
0 1 1 Read Busy Flag (DB7) and address counter (DB0 - DB6)
1 0 1 Data Write operation (MPU writes data into DR)
1 1 1 Data Read operation (MPU reads data from DR)

Table 5-1

E = Enable
RS = Register Select
Read Operation R/W = 1
Write Operation R/W = 0

LCD module data bus connected to J17 and control port is connected to J18. Description of
Data Bus I/O pins connected to J17 is tabulated in Table 5-2 and description of control
signals I/O pins connected to J18 is tabulated in Table 5-3.

Data Port: (J17)

Bit 7 6 5 4 3 2 1 0
Name D7 D6 D5 D4 D3 D2 D1 D0
Pin J17-8 J17-7 J17-6 J17-5 J17-4 J17-3 J17-2 J17-1
Function IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT
Port B PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0

Table 5-2

38
Control Port: (J18)

Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C N/C EN R/W RS
Pin J18-8 J18-7 J18-6 J18-5 J18-4 J18-3 J18-2 J18-1
Function - - - - - IN IN IN
Port F PF.7 PF.6 PF.5 PF.4

Table 5-3

To perform experiment Data Port (J17) is connected to Port B and Control Port (J18) is
connected to Port F. This Module must be initialized after each power on reset. Fig 5.1
describes the initialization command sequence. Refer to lcd.c for hex values related to
initialization sequence. Refer to S6A0069.pdf for detailed command format for each register
of LCD module.

Note: In case of 4-line display, choose 1-line mode to select 2-lines and 2-line mode to
select 4-lines.

Fig 5.1 Initialization Sequence

39
Character LCD Addressing:
This information relates to the Character LCD module used in EDC-M540 based on
S6A0069 dot matrix LCD driver & controller or equivalent. The controller contains 80 bytes
of Display Data Random Access Memory which is usually referred to as DDRAM. When
the controller is used with a 40 x 2 display (forty characters on each of two rows) the
operation is quite straightforward and that operation will be explained first.

Each of the other configurations introduces one or more quirks so it is best to understand the
operation of the 40 x 2 before proceeding to the description of the operation of any of the
others.
DDRAM address contains 7-Bits, so the address is from 00h to 27h for the first line and 40h
to 67h for the second line. This gap in the addresses is due to the fact that MSB bit of
DDRAM address AC6 =1 for second row. This causes the address of second row to start
from 40h instead of 28h.

Now as the DDRAM configuration register is of 8-bits, so AC7 is always 1. Hence when we
issue command to set the DDRAM address we will add 80h to the actual DDRAM address,
this will be the value written to DDRAM register. This is shown in Table 5-4.

Set DDRAM Address command format

Table 5-4

So the DDRAM configuration of 40X2 Character LCD will be as follows:

Now if we have 16X4 character LCD, then its DDRAM configuration will be as follows:

DDRAM address Command format for each line of 16X4 LCD will be:

Line 1: 0x80 ~ 0x8F


Line 2: 0xC0 ~ 0xCF
Line 3: 0x90 ~ 0x9F
Line 4: 0xD0 ~ 0xDF

40
Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project LCD.ide located in c:\bc45\i386EX\LCD.
5. Selection option Project -> Build All. This will compile the program and will create
LCD.exe file.
6. Upload the LCD.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect Port B (J3) to Data Port J17 of Character LCD


Connect Port F (J7) to Control Port J18 of Character LCD
Press Enter when Ready...

9. Connect Port B (J3) to J17 of Character LCD and Port F (J7) to J18 of Character LCD
using 10-pin data cable.
10. Press Enter Key to start the program. Firstly, it will initialize the LCD and then it will
wait for the user to input data from keyboard.
11. ASCII Data received from keyboard will be displayed on LCD.
12. If required, adjust the Contrast knob to view character displayed on LCD.
13. After the end of 16 characters, program will automatically adjust DDRAM address for
next line.
14. Press Esc to exit from the program.

41
EXPERIMENT 6
CONTROLLING GRAPHICAL LCD

Objective:
To Control Graphical LCD using 82C55A Device

Theory:
Graphical LCD used in EDC-M540 is 128X64 pixels, based on ST7920 controller. As with
other devices, this module also has a Data Bus and control signals. When writing to the
controllers the CS pin will be selected to turn on the controller. ST7920 LCD
controller/driver IC can display alphabets, numbers. It supports 3 kinds of bus interface,
namely 8-bit, 4-bit and serial. All functions, including display RAM, Character Generation
ROM, LCD display drivers and control circuits are all in a one-chip solution. With a
minimum system configuration.

Display Data RAM (DDRAM)


There are 64x2 bytes RAM spaces for the Display Data RAM. It can store display data such
as 16 characters (16x16) by 4 lines or 32 characters (8x16) by 4 lines.

Characters Displayed by the LCD

Fig. 6.1 GLCD Character Layout

42
Parallel Interface:
ST7920 is in parallel mode by pulling up PSB pin. ST7920 can select 8-bit or 4-bit bus
interface by setting the DL control bit in “Function Set” instruction. MPU can control RS,
RW, E and DB0…DB7 pins to complete the data transmission.

8-Bit Bus Mode Timing Fig. 6.2

LCD Initialization Sequence

43
LCD Instruction Set

Graphical LCD module data bus connected to J15 and control port is connected to J16.
Description of Data Bus I/O pins connected to J15 is tabulated in Table 6-2 and description of
control signals I/O pins connected to J15 is tabulated in Table 6-3.

44
Data Port: (J15)

Bit 7 6 5 4 3 2 1 0
Name D7 D6 D5 D4 D3 D2 D1 D0
Pin J15-8 J15-7 J15-6 J15-5 J15-4 J15-3 J15-2 J15-1
Function IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT IN/OUT
Port B PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0

Table 6-2
Control Port: (J16)

Bit 7 6 5 4 3 2 1 0
Name N/C N/C RST CS2 SB E R/W RS
Pin J16-8 J16-7 J16-6 J16-5 J16-4 J16-3 J16-2 J16-1
Function - - IN IN IN IN IN IN
Port C PC.5 PC.4 PC.3 PC.2 PC.1 PC.0

Table 6-3

To perform experiment, Data Bus (J15) is connected to Port B and Control Signals are
connected to Port C.

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project STGLCD.ide located in
c:\bc45\i386EX\STGLCD.
5. Selection option Project -> Build All. This will compile the program and will create
STGLCD.exe file.
6. Upload the STGLCD.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect Port B (J3) to J15 of Graphical LCD


Connect Port C (J8) to J16 of Graphical LCD
Press Any Key when Ready...

9. Connect Port B (J3) to J15 of Graphical LCD and Port C (J8) to J16 of Graphical LCD
using 10-pin data cable.

45
10. Press Enter Key to start the program.
11. Firstly, it will initialize the LCD and will display the corresponding message.
12. Then it will display 4 lines of text message on GLCD as shown below:

TEST MESSAGE
ST7920 GLCD R2
ST7920 GLCD R3
ST7920 GLCD R4

13. Program will exit after displaying the fonts on GLCD.

46
EXPERIMENT 7
CONTROLLING KEYPAD AND JOYSTICK

Objective:
To Control Keypad and 5-way Joystick using 82C55A Device

Theory:
Keypad is a matrix of tact switches. It plays very important part in Human Machine Interface.
This enables the user to input values to the embedded system. This value can be a
temperature level or a lock code for a door. Its construction is fairly simple. This matrix is
represented by Rows and Columns as shown in Fig. 7.1

Fig. 7.1 4X4 Matrix Keypad

Keypad Working Principle


We will connect an O/P port to ROW pins and I/P port to COL pins. All the COL pins are
pulled at +5V logic level. Initially all the ROW pins are also provided with +5V logic level.
Now we will provide a 0V logic level to only ROW 1 pin, all other ROW pins will be at +5V
logic level, and input the value of COL pins. We will repeat the process for ROW 2, 3 and 4
and then again for ROW1. Hence our program keeps scanning for the pressed key. ROW and
COL pins are provided on 10-pin header J24 as described in Table 7-1.

As an example assume that user has pressed key 2 when ROW1 is at 0V logic level, so COL2
pin will be at 0V logic level where as all other COL pins will be at +5V logic level. Hence we
get a 4-bit digital value of 1 0 1 1. Hence it will be determined that Key 2 is pressed by the
user. So whenever key 2, 5, 8 and 0 will be pressed we will get a 4-bit digital value of 1 0 1 1
but the key pressed will be determined by the ROW pin at 0V logic level. 4-bit digital values
for all the keys are tabulated in Table 7-2.

47
ROW & COL Pins (J24)

Bit 7 6 5 4 3 2 1 0
Name ROW4 ROW 3 ROW2 ROW1 COL 4 COL 3 COL2 COL1
Pin J24-8 J24-7 J24-6 J24-5 J24-4 J24-3 J24-2 J24-1
Function IN IN IN IN OUT OUT OUT OUT
Port C PC.7 PC.6 PC.5 PC.4 PC.3 PC.2 PC.1 PC.0

Table 7-1

4-Bit Keypad Map

R4=0 Possible Combinations When R4 is Low


C4 C3 C2 C1 Hex Value Key Pressed
1 1 1 0 0EH *
1 1 0 1 0DH 0
1 0 1 1 0BH #
0 1 1 1 07H Dial
R3=0 Possible Combinations When R3 is Low
C4 C3 C2 C1 Hex Value Key Pressed
1 1 1 0 0EH 7
1 1 0 1 0DH 8
1 0 1 1 0BH 9
0 1 1 1 07H Menu
R2=0 Possible Combinations When R2 is Low
C4 C3 C2 C1 Hex Value Key Pressed
1 1 1 0 0EH 4
1 1 0 1 0DH 5
1 0 1 1 0BH 6
0 1 1 1 07H Back
R1=0 Possible Combinations When R1 is Low
C4 C3 C2 C1 Hex Value Key Pressed
1 1 1 0 0EH 1
1 1 0 1 0DH 2
1 0 1 1 0BH 3
0 1 1 1 07H Reject

Table 7-2

Joystick Working Principle


Joy stick used in EDC-M540 is basically a 5-way tactile switch which has a common pole.
This pole connects to five different positions, such as UP, DOWN, LEFT, RIGHT and
CENTRE as shown in Fig. 7.2. Joystick pins are provided on 10-pin header J23 as shown in
Table 7-3.

48
Fig. 7.2 Joystick Schematic

Joystick Pins (J23)


Bit 7 6 5 4 3 2 1 0
Name N/C N/C COM A CNTR C D B
Pin J23-8 J23-7 J23-6 J23-5 J23-4 J23-3 J23-2 J23-1
Function - - GND IN IN IN IN IN
Port B PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0

Table 7-3

Common of joystick is at 0V logic level. A, B, C, D and CNTR are pulled up to +5V logic.
Software inputs the value of port with which the joystick is connected. When a user makes
contact with pin ‘A’, then this pin goes low and all other pins remain at +5V logic level. So
we get an 8-bit digital value. Keypad program will always put zero to PB.6 and PB.7. All
possible 8-bit values are tabulated in Table 7-4.

Joystick Map

Port B PB.7 PB.6 PB.5 PB.4 PB.3 PB.2 PB.1 PB.0 Hex Value
Joystick Pin N/C N/C COM A CNTR C D B
No Key Pressed 0 0 0 1 1 1 1 1 1FH
CENTER pressed 0 0 0 1 0 1 1 1 17H
LEFT pressed 0 0 0 1 1 0 1 1 1BH
DOWN pressed 0 0 0 1 1 1 0 1 1DH
RIGHT pressed 0 0 0 0 1 1 1 1 0FH
UP pressed 0 0 0 1 1 1 1 0 1EH

Table 7-4

49
Joystick lever must be pressed correctly to get the required values. Fig. 7.3 shows the correct
movement of the lever. If the lever is moved in any other direction, then the required digital
value will not be obtained and the program will not display the correct output.
For Center push the lever downwards in the center.

Fig. 7.3 Joystick Lever

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project Keypad.ide located in c:\bc45\i386EX\Keypad.
5. Selection option Project -> Build All. This will compile the program and will create
Keypad.exe file.
6. Upload the Keypad.exe file using UP command.
7. Connect PORT C(J8) to J24 Keypad using 10-pin cable.
8. Connect PORT B(J3) to J23 Joystick using 10-pin cable.
9. Use dir command to verify that file is uploaded to the flash disk.

50
10. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect PORT C (J8) to Keypad (J24)


Connect PORT B (J3) to Joystick(J23)

Press Any Esc Key to Exit


Press Key on 4X4 Keypad to Display Data
Press Joy Stick to Display Data

11. Press Key 2 and the program will display ROW data, COL data and the key pressed by
the user as follows:

Row Scanned = R4 Column Data = d Key Pressed = 2

12. Verify the data for each key.


13. Now push joystick knob upwards, program will display the following:

Joy Stick Data = UP

14. Similarly pull the joystick knob in down ward direction, then push in left ward direction,
then push in right ward direction and then press the knob down for center button
connection. Each time joystick knob is pressed, software will display the data received
from the joystick.
15. Press Esc key to exit from the program.

51
EXPERIMENT 8
DIRECTION CONTROL OF DC MOTOR

Objective:
To Control Direction of DC Motor

Theory:
An electric motor is a device which converts electrical energy into mechanical energy. A
common motor works on direct current. So, it is also called DC motor. When a rectangular
coil carrying current is placed in a magnetic field, a torque acts on the coil which rotates it
continuously. When the coil rotates, the shaft attached to it also rotates and thus it is able to
do mechanical work.

Parts of a DC Motor
DC Motor consists of an armature, commutator and brushes as shown in Fig. 8.1

Fig. 8.1 Parts of a DC Motor

Armature
A DC motor consists of a rectangular coil made of insulated copper wire wound on a soft iron
core. This coil wound on the soft iron core forms the armature. The coil is mounted on an
axle and is placed between the cylindrical concave poles of a magnet.

Commutator
A commutator is used to reverse the direction of flow of current. Commutator is a copper ring
split into two parts C1 and C2. The split rings are insulated from each other and mounted on
the axle of the motor. The two ends of the coil are soldered to these rings.
They rotate along with the coil. Commutator rings are connected to a battery. The wires from
the battery are not connected to the rings but to the brushes which are in contact with the
rings.

Brushes
Two small strips of carbon, known as brushes press slightly against the two split rings, and
the split rings rotate between the brushes. The carbon brushes are connected to a DC source.

52
Working of a DC Motor
When the coil is powered, a magnetic field is generated around the armature as shown in Fig.
8.2.

Fig. 8.2 Working of a DC Motor

The left side of the armature is pushed away from the left magnet and drawn towards the
right, causing rotation. When the coil turns through 900, the brushes lose contact with the
commutator and the current stops flowing through the coil. However the coil keeps turning
because of its own momentum. Now when the coil turns through 1800, the sides get
interchanged. As a result the commutator ring C1 is now in contact with brush B2 and
commutator ring C2 is in contact with brush B1. Therefore, the current continues to flow in
the same direction. The Efficiency of the DC Motor Increases by:
• Increasing the number of turns in the coil
• Increasing the strength of the current
• Increasing the area of cross-section of the coil
• Increasing the strength of the radial magnetic field

Armature of DC motor requires large current. We will use a current driver to drive a DC
Motor. To control the direction of a DC motor we will use an H-bridge, this enables us to
change the polarity of Armature of a DC motor. This causes to motor to operate in reverse
direction as shown in Fig. 8.3

53
Fig. 8.3 Bi-Directional DC Motor Control

DC Motor control pins are connected to 10-pin header J31 as tabulated in Table 8-1.

DC Motor Pins (J31)

Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C IR O/P PWM B A
Pin J31-8 J31-7 J31-6 J31-5 J31-4 J31-3 J31-2 J31-1
Function - - - - OUT IN IN IN
Port F - - - - PF.7 PF.6 PF.5 PF.4

Table 8-1

Note: Always put Power Switch to OFF position, when stepper is not in use. This will
ensure the safety of H-bridge.

54
Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project Motor_ex.ide located in c:\bc45\i386EX\Motors.
5. Selection option Project -> Build All. This will compile the program and will create
Motor_ex.exe file.
6. Upload the Motor.exe file using UP command.
7. Connect PORT F (J7) to DC Motor (J31) using 10-pin cable.
8. Put Power Switch to ON position.
9. Use dir command to verify that file is uploaded to the flash disk.
10. Execute the program. Program menu will be displayed in interface software window as
shown below:

TEST MENU
1-Stepper Clock Wise
2-Stepper Counter Clock Wise
3-DC Motor Counter Clock Wise
4-DC Motor Clock Wise
5-R/C Servo 0 Degree
6-R/C Servo 45 Degree
7-R/C Servo 90 Degree
8-R/C Servo 135 Degree
9-R/C Servo 180 Degree

10. Select option 3. Program will display the bitwise values of Port F. Verify that motor is
moving in Counter Clock wise direction.
11. Now press Enter key to display main menu and Select option 4. Program will display the
bitwise values of Port F. Verify that motor is moving in Clock wise direction.
12. Press Enter key to display main menu.
13. Press Esc key to exit from program.
14. Put Power switch in OFF position.

55
EXPERIMENT 9
DIRECTION CONTROL OF STEPPER MOTOR

Objective:
To Control Direction of Stepper Motor

Theory:
A stepper motor (or step motor) is a brushless DC electric motor that divides a full rotation
into a number of equal steps as show in Fig. 9.1. The motor's position can then be
commanded to move and hold at one of these steps without any feedback sensor (an open-
loop controller), as long as the motor is carefully sized to the application.

Fig. 9.1 Stepper Motor

Working Principle
DC brush motors rotate continuously when voltage is applied to their terminals. Stepper
motors, on the other hand, effectively have multiple "toothed" electromagnets arranged
around a central gear-shaped piece of iron. The electromagnets are energized by an external
control circuit, such as a microcontroller. To make the motor shaft turn, first, one
electromagnet is given power, which makes the gear's teeth magnetically attracted to the
electromagnet's teeth. When the gear's teeth are aligned to the first electromagnet, they are
slightly offset from the next electromagnet. When the next electromagnet is turned on and the
first is turned off, the gear rotates slightly to align with the next one, and from there the
process is repeated. Each of those slight rotations is called a "step", with an integer number of
steps making a full rotation as shown in Fig. 9.2 a,b,c, and d. In that way, the motor can be
turned by a precise angle.

56
(a) (b) (c) (d)

Fig. 9.2 Stepper Motor ‘step’

Stepping motors come in two varieties, permanent magnet and variable reluctance (there are
also hybrid motors, which are indistinguishable from permanent magnet motors from the
controller's point of view). Lacking a label on the motor, you can generally tell the two apart
by feel when no power is applied. Permanent magnet motors tend to "cog" as you twist the
rotor with your fingers, while variable reluctance motors almost spin freely (although they
may cog slightly because of residual magnetization in the rotor). You can also distinguish
between the two varieties with an ohmmeter. Variable reluctance motors usually have three
(sometimes four) windings, with a common return, while permanent magnet motors usually
have two independent windings, with or without center taps. Center-tapped windings are used
in unipolar permanent magnet motors.

Stepping motors come in a wide range of angular resolution. The coarsest motors typically
turn 90 degrees per step, while high resolution permanent magnet motors are commonly able
to handle 1.8 or even 0.72 degrees per step.

For both permanent magnet and variable reluctance stepping motors, if just one winding of
the motor is energized, the rotor (under no load) will snap to a fixed angle and then hold that
angle until the torque exceeds the holding torque of the motor, at which point, the rotor will
turn, trying to hold at each successive equilibrium point.

Bipolar Motors

Fig. 9.3 Bipolar Stepper Motor Wiring

Bipolar permanent magnet and hybrid motors are constructed with exactly the same
mechanism as is used on unipolar motors, but the two windings are wired more simply, with
no center taps. Thus, the motor itself is simpler but the drive circuitry needed to reverse the

57
polarity of each pair of motor poles is more complex. The schematic in Figure 9.3 shows how
such a motor is wired.

The drive circuitry for such a motor requires an H-bridge control circuit for each winding. H-
bridge allows the polarity of the power applied to each end of each winding to be controlled
independently. The control sequences for single stepping such a motor are shown in Fig. 9.4.

A
B

C
D

INH1
0

INH2 0

Fig. 9.4 Bipolar Stepper Motor Control Sequence

Bipolar Stepper motor is used in EDC-M540. H-bridge circuit is built to drive the stepper
motor. Control sequence given to H-bridge is as shown in Fig. 9.4. INH1 and INH2 are
connected to Power ON/OFF switch provided on EDC-M540. This ensures that the H-bridge
is in OFF condition when not in use.

H-bridge circuit connected to stepper motor is shown in Fig. 9.5. This circuit is controlled by
logic values given to A, B, C and D inputs these inputs are provided at 10-pin header J30 as
shown in Table 9-1. Output of this circuit is capable to drive a load of 1.5A.

Stepper Motor Pins (J30)

Bit 7 6 5 4 3 2 1 0
Name N/C N/C N/C N/C D C B A
Pin J30-8 J30-7 J30-6 J30-5 J30-4 J30-3 J30-2 J30-1
Function - - - - IN IN IN IN
Port F - - - - PF.7 PF.6 PF.5 PF.4

Table 9-1

58
Fig. 9.4 H-bridge Drive Circuit

Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project Motor_ex.ide located in c:\bc45\i386EX\Motors.
5. Selection option Project -> Build All. This will compile the program and will create
Motor_ex.exe file.
6. Upload the Motor.exe file using UP command.
7. Connect PORT F (J7) to Stepper Motor (J30) using 10-pin cable.
8. Put Power Switch to ON position.
9. Use dir command to verify that file is uploaded to the flash disk.

59
10. Execute the program. Program menu will be displayed in interface software window as
shown below:

TEST MENU
1-Stepper Clock Wise
2-Stepper Counter Clock Wise
3-DC Motor Counter Clock Wise
4-DC Motor Clock Wise
5-R/C Servo 0 Degree
6-R/C Servo 45 Degree
7-R/C Servo 90 Degree
8-R/C Servo 135 Degree
9-R/C Servo 180 Degree

15. Select option 1. Program will display the bitwise values of Port F. Verify that motor is
moving in Clock wise direction.
16. Now press Enter key to display main menu.
17. Select option 2. Program will display the bitwise values of Port F. Verify that motor is
moving in Counter Clock wise direction.
18. Press Enter key to display main menu.
19. Press Esc key to exit from program.
20. Put Power switch in OFF position.

60
EXPERIMENT 10
DIRECTION CONTROL OF R/C MOTOR

Objective:
To R/C Servo Motor

Theory:
One type of DC motor is a Servo Motor. Servo Motor is a device which uses error-sensing
feedback signals to determine and control the position of a motor shaft. The term
“servomechanism” closely relates to servo motors which refer to any device that uses error-
sensing feedback to correct the performance of a system.

The servo motor works on the phenomenon of the automatic closed-loop system. The
controller is required for this closed-loop system. This controller is composed of a
comparator and a feedback path. It has one output and two inputs. In this, for producing an
output signal, the comparator is used to compare the required reference signal and this output
signal is sensed by the sensor. The input signal for the motor is termed as a feedback signal.

Fig. 10.1 Servo Motor Block Diagram

On the basis of the feedback signal, the motor starts working. Comparator signal is called a
logic signal of the motor. The motor would be ON for the desired time when the logical
difference is higher and the motor would be OFF for the desired time when the logical
difference is lower. Basically, a comparator is used to decide that motor would be ON or
OFF. Proper functioning of the motor can be done with the help of a good controller.

61
Fig. 10.2 Internal Parts of a Servo Motor

Servo Command
Servos are controlled by sending them a pulse of variable width. The signal wire is used to
send this pulse. The parameters for this pulse are that it has a minimum pulse, a maximum
pulse, and a repetition rate. Given the rotation constraints of the servo, neutral is defined to be
the position where the servo has exactly the same amount of potential rotation in the
clockwise direction as it does in the anti-clockwise direction. It is important to note that
different servos will have different constraints on their rotation but they all have a neutral
position, and that position is always around 1.5 milliseconds (ms).

Continuous Pulses to RC Servo

The angle is determined by the duration of a pulse that is applied to the signal wire. This is
called Pulse Width Modulation. The servo expects to see a pulse every 20 ms. The length of
the pulse will determine how far the motor turns. For example, a 1.5 ms pulse will make the
motor turns to a 90 degree position (neutral position).

When these servos are commanded to move, they will move to the position and hold that
position. If an external force pushes against the servo while the servo is holding a position,
the servo will resist from moving out of that position. The maximum amount of force the
servo can exert is the torque rating of the servo. Servos will not hold their position forever
though; the position pulse must be repeated to instruct the servo to stay in position.

62
Procedure:
1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project Motor_ex.ide located in c:\bc45\i386EX\Motors.
5. Selection option Project -> Build All. This will compile the program and will create
Motor_ex.exe file.
6. Upload the Motor.exe file using UP command.
7. Connect PORT F (J7) to R/C Servo using 10-pin cable.
8. Put Power Switch to ON position.
9. Use dir command to verify that file is uploaded to the flash disk.
10. Execute the program. Program menu will be displayed in interface software window as
shown below:

TEST MENU
1-Stepper Clock Wise
2-Stepper Counter Clock Wise
3-DC Motor Counter Clock Wise
4-DC Motor Clock Wise
5-R/C Servo 0 Degree
6-R/C Servo 45 Degree
7-R/C Servo 90 Degree
8-R/C Servo 135 Degree
9-R/C Servo 180 Degree

21. Select option 5. Program will display the Servo position.


22. Similarly select other options to move the R/C servo to the respective position.
23. Press Esc key to exit from program.
24. Put Power switch in OFF position.

63
EXPERIMENT 11
ANALOG TO DIGITAL CONVERTER

Objective:
To Control Analog to Digital Converter

Theory:
Analog to digital converter converts an analog signal into weighted binary voltage signals.
ADC0804 is installed on the base board which is an 8-bit A/D converter and works on TTL
standards. Following figure shows the complete working block diagram of ADC0804.

64
ADC0804 is a multi-feature device and can be operated in free running mode where it just
converts the in-coming signal into digital form sends it to its output data bus or it can be
interfaced with microprocessor based devices through its four control lines, which are:

- CS - RD - WR -INTR

On the high-to-low transition of the WR input, the internal SAR latches and the shift-register
stages are reset, and the INTR output will be set high. As long as the CS input and WR input
remain low, the A/D will remain in a reset state. Conversion will start from 1 to 8 clock
periods after at least one of these inputs makes a low-to- high transition. After the requisite
number of clock pulses to complete the conversion, the INTR pin will make a high-to-low
transition. This can be used to interrupt a processor, or otherwise signal the availability of a
new conversion. A RD operation (with CS low) will clear the INTR line high again.

Following timing diagram shows how to command ADC to start conversion:

Next timing diagram shows how to read the data from ADC which shows timing details after
the INTR pin has generated an interrupt signal by getting low in upper diagram.

65
After this procedure INTR will automatically set high to “1”.

For timing units refer to device datasheet and also to run ADC in free running mode i.e. with
minimum control signals required.

A/D converter section has 0 – 5V Analog source in order to provide test voltages to the A/D
converter. Make connection as shown in Fig. 10.1 to provide test voltage to the A/D
converter. Analog Source potentiometer decreases its output when turned clockwise and
increases its value when turned counter-clockwise.

Fig. 10.1

Procedure:

1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project ADC.ide located in c:\bc45\i386EX\ADC.
5. Select option Project -> Build All. This will compile the program and will create adc.exe
file.
6. Upload the adc.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Rotate Analog Source potentiometer to fully clockwise. This will output 0V at TP2.

66
9. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect PORT C(J8) to J10 (ADC Data)


Connect PORT B(J3) to J26 (ADC Control)
Connect PORT A(J2) to J21 (LEDs)
Connect ANALOG SOURCE TP2 to ANALOG IN

Press Esc Key to Exit

10. After some delay the program will start to display the digital data received from A/D
converter.
11. Now slowly turn the potentiometer in counter-clockwise direction. As we move the LEDs
start to lit up showing the digital value received from A/D converter.
12. Tabulate the digital value received against the Analog input voltage at TP2 in Table 10-1.
13. Verify the experiment results with the theoretical values mentioned in the datasheet of the
A/D converter.
14. Press Esc key to exit from program.

TABLE 10-1
ADC Voltage ADC Voltage ADC Voltage ADC Voltage
Hex at TP2 Hex at TP2 Hex at TP2 Hex at TP2
Value Value Value Value

67
EXPERIMENT 12
DIGITAL TO ANALOG CONVERTER

Objective:
To Control Digital To Analog Converter

Theory:
The DAC0800 series are monolithic 8-bit high-speed current-output digital-to-analog
converters (DAC) featuring typical settling times of 100 ns. When used as a multiplying
DAC, monotonic performance over a 40 to 1 reference current range is possible. The
DAC0800 series also features high compliance complementary current outputs to allow
differential output voltages of 20Vp-p with simple resistor loads.

Fig. 12.1 DAC0800 Block Diagram

The reference-to-full-scale current matching of better Others than ±1 LSB eliminates the need
for full-scale trims in most applications, while the nonlinearities of better than ±0.1% over
temperature minimizes system error accumulations.

Fig. 12.2 Current to Voltage Conversion

Current generated by digital to analog converter is converted to voltage using the equation
shown in Fig. 12.2. Here IREF = VREF / 5000. Value of VREF should be noted from TP1, as
shown in Fig. 12.3.

68
Fig. 12.3 Experiment Setup

Procedure:

1. Connect Console Port to the PC and execute the interface software for EDC-M540
2. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
3. List directory of the files on flash disk of the Trainer by using dir command.
4. Run Borland C++ IDE and open project DAC.ide located in c:\bc45\i386EX\DAC.
5. Select option Project -> Build All. This will compile the program and will create
dac_ex.exe file.
6. Upload the dac_ex.exe file using UP command.
7. Use dir command to verify that file is uploaded to the flash disk.
8. Execute the program. Program menu will be displayed in interface software window as
shown below:

Press ESC to Exit..

Digital Data sent to D/A ..


Press Enter to send next Digital Data to D/A

9. Program will send digital data from 00 Hex to FF Hex sequentially each time the user
presses the Enter key.

69
10. Tabulate the digital and analog values of the digital to analog converter using Table 12-1.

TABLE 12-1
DAC Voltage DAC Voltage DAC Voltage DAC Voltage
Hex O/P Hex O/P Hex O/P Hex O/P
Value Value Value Value

70
EXPERIMENT 13
TO STUDY RELAY MODULE

Objective:
To Understand the Working of Relay

Theory:

The Electromechanical Relay


The term Relay generally refers to a device that provides an electrical connection between
two or more points in response to the application of a control signal. The most common and
widely used type of electrical relay is the electromechanical relay or EMR.
The most fundamental control of any equipment is the ability to turn it “ON” and “OFF”. The
easiest way to do this is using switches to interrupt the electrical supply. Although switches
can be used to control something, they have their disadvantages. The biggest one is that they
have to be manually (physically) turned “ON” or “OFF”. Also, they are relatively large, slow
and only switch small electrical currents.

Electromechanical Relay Construction

Fig 132.1 Relay Construction

In our simple relay above, we have two sets of electrically conductive contacts. Relays may
be “Normally Open”, or “Normally Closed”. One pair of contacts are classed as Normally
Open, (NO) or make contacts and another set which are classed as Normally Closed, (NC) or
break contacts. In the normally open position, the contacts are closed only when the field
current is “ON” and the switch contacts are pulled towards the inductive coil.

In the normally closed position, the contacts are permanently closed when the field current is
“OFF” as the switch contacts return to their normal position. These terms Normally Open,
Normally Closed or Make and Break Contacts refer to the state of the electrical contacts
when the relay coil is “de-energized”, i.e, no supply voltage connected to the relay coil.
Contact elements may be of single or double make or break designs. An example of this
arrangement is shown in Fig. 13.2.

71
Fig. 13.2 Relay Contacts

Electrical Relay Contact Configurations

Where:
C is the Common terminal
NO is the Normally Open contact
NC is the Normally Closed contact

8-channel relay module uses SPDT relays. One of the more important parts of any electrical
relay is its coil. This converts electrical current into an electromagnetic flux which is used to
mechanically operate the relays contacts. The main problem with relay coils is that they are
“highly inductive loads” as they are made from coils of wire. Any coil of wire has an
impedance value made up of resistance ( R ) and inductance ( L ) in series (LR Series
Circuit).

As the current flows through the coil a self induced magnetic field is generated around it.
When the current in the coil is turned “OFF”, a large back emf (electromotive force) voltage
is produced as the magnetic flux collapses within the coil (transformer theory).

72
This induced reverse voltage value may be very high in comparison to the switching voltage,
and may damage any semiconductor device such as a transistor, FET or micro-controller used
to operate the relay coil as shown in Fig. 13.3.

Fig. 13.3 Relay Drive Circuit

One way of preventing damage to the transistor or any switching semiconductor device, is to
connect a reverse biased diode across the relay coil. When the current flowing through the
coil is switched “OFF”, an induced back emf is generated as the magnetic flux collapses in
the coil. This reverse voltage forward biases the diode which conducts and dissipates the
stored energy preventing any damage to the semiconductor transistor.

When used in this type of application the diode is generally known as a Flywheel Diode,
Free-wheeling Diode and even Fly-back Diode, but they all mean the same thing. Other types
of inductive loads which require a flywheel diode for protection are solenoids, motors and
inductive coils.

73
Fig. 13.3 Experiment Setup

Procedure:
1. Install the Add-On carefully onto the EDC-M540 trainer. Make sure all the headers are
correctly placed, then exert pressure on the header from top to fix them onto EDC-M540
trainer.
2. Connect Console Port to the PC and execute the interface software for EDC-M540
3. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
4. List directory of the files on flash disk of the Trainer by using dir command.
5. Run Borland C++ IDE and open project Relay_ex.ide located in c:\bc45\i386EX\Relay.
6. Selection option Project -> Build All. This will compile the program and will create
Relay_ex.exe file.
7. Upload the Relay_ex.exe file using UP command.
8. Connect the J9 of Relay module with J2 of Port A using 10-pin IDC cable.
9. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect 10-pin cable to Relay (J9)


Connect 10-pin cable PortA (J2)

Press Esc Key to Exit

10. Program will turn ON each relay sequentially.


11. Press Esc key to exit from program.

74
EXPERIMENT 14
UNDERSTANDING DOT MATRIX LED DISPLAY

Objective:
To Understand the Working of a Dot Matrix LED Display

Theory:
Unlike 7 segment displays you can use dot matrix displays to generate alpha, numeric, or
custom character output. This is s a quick introduction to the basics of using monochrome
LED dot matrix displays with microcontrollers.

Structure and Operation of Dot Matrix Displays


In a LED dot matrix display the LEDs are located at the column and row intersections of the
matrix. LEDs in the same row are connected together as are LEDs in the same column. Fig.
13.1 shows two common configurations for LED matrix displays.

Fig. 14.1 Dot Matrix Configurations

Accessing Individual LEDs

You turn on an individual LED by setting its row and column pins to the proper polarity. For
example, referring to figure 3, in the CCAR matrix on the left the switch in row 1 is closed
(shown in red) causing a positive voltage level to be applied to the anodes of all of the LEDs
in that row.

75
The switch in column 2 is also closed which ties the cathodes of all of the LEDs in that
column to ground. The LED at the intersection of column 2 and row 1 is forward biased and
turns on. Fig. 13.2 shows circuit for both type of LEDs.

Fig. 14.2 LED operation circuit.

Multiplexing
Because of the limited number of pins you can only display one row or one column of LEDs
at a time. To display the entire matrix you need to multiplex the columns or the rows. That is,
display each column or row one at a time and do it so quickly that all of the columns or rows
appear to be visible at the same time.

Fig. 14.3 Multiplexing the LEDs

76
Controlling and displaying dot matrix is a complex task and requires a microcontroller or a
dedicated circuit. Dot matrix modules uses MAX7219 IC to control the functions of Dot
Matrix.

The MAX7219/MAX7221 are compact, serial input/output common-cathode display drivers


that interface microprocessors (μPs) to 7-segment numeric LED displays of up to 8 digits,
bar-graph displays, or 64 individual LEDs. Included on-chip are a BCD code-B decoder,
multiplex scan circuitry, segment and digit drivers, and an 8x8 static RAM that stores each
digit. Only one external resistor is required to set the segment current for all LEDs.
Functional diagram is shown in Fig. 14.4.

Fig. 14.4 Functional Diagram of MAX7219

Details regarding registers and configuration values, refer to datasheet of MAX7219 and the
sample source code of dot matrix.

77
Fig. 14.5 Experiment Setup

Procedure:
1. Install the Add-On carefully onto the EDC-M540 trainer. Make sure all the headers are
correctly placed, then exert pressure on the header from top to fix them onto EDC-M540
trainer.
2. Connect Console Port to the PC and execute the interface software for EDC-M540
3. Turn ON the Trainer and verify that the prompt is displayed by pressing Enter key
several times.
4. List directory of the files on flash disk of the Trainer by using dir command.
5. Run Borland C++ IDE and open project Matrix.ide located in c:\bc45\i386EX\Matrix.
6. Selection option Project -> Build All. This will compile the program and will create
matrix.exe file.
7. Upload the matrix.exe file using UP command.
8. Connect PortC (J8) to J(50) of Dot Matrix using 10-pin IDC cable.
9. Execute the program. Program menu will be displayed in interface software window as
shown below:

Connect PortC(J8) to J50 of Dot Matrix

9. Following messages will be displayed on terminal:

MAX7219 Init Start ...

Matrix Initialized ...

Displaying Text On Matrix ...

10. Now the program will display Alphabet A to Z and then numbers 0 to 9 sequentially on
both Dot Matrix Displays.
11. After displaying all the values, program will exit.

78
LIST OF ACCESSORIES

1. Experiment Manual
2. Relay Module
3. Dot Matrix Module
4. 2 x USB Cables
5. 3 x 10-pin data cables
6. 2mm patch cord
7. Power Cord

79

You might also like