Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

programming for relay

Status
Not open for further replies.

bikash123

Member level 2
Joined
Feb 19, 2012
Messages
48
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Tezpur University
Activity points
1,672
Dear Friends, i have some problems with relay . which is interface with PIC microcontroller. Plz suggest me what will be the program.
 

Dear bikash123,

the relay is a electronics device when current flow on it's coil the state is inverted. It mean N.O converted to N.C and N.C converted to N.O. So the output from micro controller is digital so we use 1 or 0. we deal with relay only two states 1 or 0 upon the application required. we use interface as in image

MCU_relay_interface.JPG

use R1=1k
R2=10k
 

Thanks Sir for suggestion. but what would be program for it. how to write it? I am using micro c as my compiler. I am just using it in between solar module and battery. Plz give me one example related with this so that i will solve it.
 

dear bikash123,

the only thing you have to do is just connect one of your mcu's pins to the r1 in the schematic given by #MAAM# , and provide logic 1 to the pin you connected.

that is so easy,

considereing you connected your relay to pic's C0 pin; you should type

Code:
PORTC.F0 = 1

you can hear the tick sound from your relay

bye the way i dont use micro c i just found the statement from its manuel

here is manuel **broken link removed**
 

dear bikash123,

the only thing you have to do is just connect one of your mcu's pins to the r1 in the schematic given by #MAAM# , and provide logic 1 to the pin you connected.

that is so easy,

considereing you connected your relay to pic's C0 pin; you should type

Code:
PORTC.F0 = 1

you can hear the tick sound from your relay

bye the way i dont use micro c i just found the statement from its manuel

here is manuel **broken link removed**

please do this.
 

Let's assume you're using PORTC 0 (like adnan mentioned above).

To make current pass through the relay coil, the transistor should be turned on. It's base is connected via a resistor to RC0.

So, in the code, whenever, you need to turn make current go through the relay coil, you have to use:

Code:
PORTC.B0 = 1;
or
Code:
PORTC.F0 = 1;
or
Code:
RC0_bit = 1;

To stop current flow through the coil, you have to use:

Code:
PORTC.B0 = 0;
or
Code:
PORTC.F0 = 0;
or
Code:
RC0_bit = 0;

When RC0 is high (1), the transistor is turned on and current flows through the relay coil.
When RC0 is low (0), the transistor is turned off and current does not flow through the relay coil.

You should learn about the PIC I/O operations. Otherwise, you'll face problems when writing codes. Read about associated registers, writing data to bytes and also bit manipulation.

Here is a free book about programming PICs with mikroC: https://www.mikroe.com/eng/products/view/285/book-pic-microcontrollers-programming-in-c/

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top