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.

PIC interface to control SSR

Status
Not open for further replies.

Daljeet12

Member level 4
Joined
Jun 16, 2018
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
648
first I just connected sensor at the input and one led at output side and tested code

followng code work for me, when sensor is high LED becomes ON for 1000 ms and if sensor is low LED becomes off

Code

Code:
// 'C' source line config statements

// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#define _XTAL_FREQ 20000000 //Specify the XTAL crystall FREQ
#define PIR RC1
#define LED RD0

void main() //The main function
{
TRISD=0X00; //Instruct the MCU that the PORTD pins are used as Output.
TRISC=0Xff; //Instruct the MCU that the PORTC pins are used as Input.
PORTD=0X00; 

while(1) //Get into the Infinie While loop
{
if(PIR ==1){
LED=1;
__delay_ms(1000); //Wait
}
else{
LED=0;
}
}

}



Now I am trying to control the load (24V DC) via sensor so I used SSR



My SSR is not working with PIC16F877A



**broken link removed**

Image result for unison ssr704b


I am using the same code as used for LED


I have attached driver circuit for Load

PICd.jpg




I have tested if i give 5v input to pin +3 and -4 LED of SSR become turn on



What could be wrong why LED of SSR doesn't turn on when the sensor goes high ?
 

Your logic isn't right: if PIR==1 the relay stays on all the time.

Brian.

Is it active low?

I am checking the state of the sensor

Code:
if (sensor high)
   turn on load
else 
 turn off load

I do not understand what's wrong in my logic
 

when sensor is high LED becomes ON for 1000 ms and if sensor is low LED becomes off
if the sensor stays high it continually triggers 1000mS delays so the relay stays on all the time.
From your description, I think what you want is this:
Code:
if (sensor high)
   turn on load
   delay
   turn off load
else 
 turn off load

Brian.
 

Hi,

Some PICs as well as other ICs are able to sink more current than source.
This it may be an improvement when the relay is connected to VCC and PIC_port..
Then the relay is ON when the port is LOW.

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top