You are currently viewing How to Interface Relay with LPC2148 ARM7 Advanced Development Board

How to Interface Relay with LPC2148 ARM7 Advanced Development Board

Spread the love

The ARM7 LPC2148 Advanced Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s ARM7 ( LPC2148), ARM Advanced Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 32-bit Microcontrollers.

Relay

Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. A relay circuit is typically a smaller switch or device which drives (opens/closes) an electric switch that is capable of carrying much larger current amounts.

Interfacing Relays

Fig. 1 shows how to interface the Relay to microcontroller. There are 2 input channels. Each input is connected to the triggering coil of the respective relay. There are 2 output channels that each correspond to an input. When the input is energized, the relay turns on and the ‘+’ output is connected to +12v. When the relay is off, the ‘+’ output is connected to Ground. The ‘-‘ output is permanently wired to Ground.

Fig. 1 Interfacing Buzzer to Microcontroller
Fig. 1 Interfacing Buzzer to Microcontroller

Interfacing Relay with LPC2148

We now want to control the relay operations by using LPC2148 Advanced Development Board. Here we are using two Relays. The relay consists of a coil and a switch. When the coil is energized, the switch closes, connecting the two contacts together. ULN2803 is used as a driver for port I/O lines, drivers output connected to relay modules. Connector provided for external power supply if needed.

Relay Module: Port P1 pins (Realy1 – P1.20) and Relay2-P1.21) for relay module, make port pins to high, relay will activated.

Pin Assignment with LPC2148

Circuit Diagram to Interface Relay with LPC2148

Circuit Diagram to Interface Relay with LPC2148

Source Code

The Interfacing Relay with LPC2148 program is very simple and straight forward, which control the relays in LPC2148 Primer Board. The relay is working that uses a delay procedure loop based software delay. The C programs are developed in Keil software.

C Program to control Relay in LPC2148

***************************************************************************************

Title : Program to control Relay

***************************************************************************************

#include <LPC214x.h> 
#include <stdio.h> 
#define RLY1 20 //RLY1 (P1.20) 
#define RLY2 21 //RLY2 (P1.21) void main(void) 
{ 
PINSEL2 = 0x00; 
IODIR1 = 1 << 
RLY1; //Configure P1.20 Output IODIR1 |= 1 << 
RLY2; //Configure P1.21 Output while(1) //loop forever 
{ 
IOSET1 = 1 <
< RLY1; Delay(); 
IOCLR1 = 1 << 
RLY1; D
Delay(); 
IOSET1 = 1 << RLY2; Delay(); 
IOCLR1 = 1 << RLY2; Delay(); 
} 
} 
void Delay() 
{ 
unsigned int i,j; 
for(i=0;i<2000;i++) 
for(j=0;j<900;j++)
;
} 

To compile the above C code you need the KEIL software. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In KEIL, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without LPC2148 Advanced Development Board.

The Flash Magic software is used to download the hex file into your microcontroller IC LPC2148 through UART0.

Testing the Relay with LPC2148

Give +3.3V power supply to LPC2148 Board; the Relay module is connected with LPC2148 Advanced Development Board. When the program is downloading into LPC2148 in Advanced Development Board, the Relay output is working that the Relay is ON some time period and the Relay is OFF some other time of period.

If you are not getting any output from Relay, then you just check the jumper connections & check the Relay is connected properly. Otherwise you just check it with debugging mode in KEIL. If you want to see more details about debugging just see the videos in below link.

 How to Create & Debug a Project in KEIL.

General Information

☞For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.

☞Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.

☞Use the exact value crystal shown in schematic.

☞More instructions are available in following articles,

User Manual for NXP LPC213X Advanced Development Board

Creating & Debugging a Project in KEIL

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.