easy electronics
Member level 3
Hi Everyone.
i am facing a high noise problem in a relay flasher circuit.
here is circuit diagram and pcb image of shift register pcb for relay
Main code
here are patterns for re
without load all of things works normal.
when i connect any load to output of relays the 74ls595 miss behaves.
it takes noise from any where .
The microcontroller 18f452 works normal either load is connected or not.
My question is "how to remove prevent 74ls595 from noise ".
load voltage is 220vac
load current is 0.5amp for each relay.
i am facing a high noise problem in a relay flasher circuit.
here is circuit diagram and pcb image of shift register pcb for relay
Main code
Code:
#include <18f452.h>
#device ADC=10
#FUSES HS,NOWDT, NOBROWNOUT, NOLVP
#use delay(crystal=4000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
/*
#byte porta=0x05 // porta ram address
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#byte porte=0x09
*/
#byte porta=0xf80 // porta ram address
#byte portb=0xf81
#byte portc=0xf82
#byte portd=0xf83
#byte porte=0xf84
#bit clock=PORTd.0
#bit latch=PORTd.1
#bit data=PORTd.2
#include "flash patt.c"
#include "fountain driver.c"
void test();
int16 process_analog(char i);
int16 var=0;
int16 delay=0;
int t=0;
///////////////////////////////////////////////////////////////////////////////
void main ()
{
setup_adc_ports(ALL_ANALOG);
setup_Adc(adc_clock_internal);
set_tris_d(0x00);
portd=0;
printf("start");
//test();
while(1)
{
for(char i=0;i<6;i++)
{
send_data(i);send_data(i);send_data(i);send_data(i);send_data(i);send_data(i);send_data(i);send_data(i);
t=process_analog(0);printf("\n\r%u"t);
delay=t/25; delay=delay*1000;printf("\n\rdelay%Lu"delay);
printf("\n\rI=%u"i);
delay_ms(delay);
output_toggle(pin_b7);
}
}
}
///////////////////////////////////////////////////////////////////////////////
void test()
{
while(1)
{
write595(0xffff);
write595(0xffff);
write595(0xffff);latch=1;delay_ms(10);latch=0;
delay_ms(1000);
write595(0x0000);
write595(0x0000);
write595(0x0000);latch=1;delay_ms(10);latch=0;
delay_ms(1000);}
}
/////////function//////////////
int16 process_analog(char i)
{
int32 X;
set_adc_channel(i);
delay_us(100);
x= read_adc();
x=x*90/1023;
x+=30;
return x;
}
Code:
/////////////////////////////////////////////////
void send_data(int i);
void write595(int16 i);
int16 long_convert(int16 i);
////////////////////////////////////////////////////
void send_data(int i)
{
delay_ms(10);
write595(pat[i][0]);
write595(pat[i][1]);
write595(pat[i][2]);
latch=1;
delay_ms(50);
latch=0;
}
//////////
void write595(int16 i)
{
i=long_convert(i);
data=bit_test(i,15);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,14);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,13);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,12);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,11);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,10);delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,9); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,8); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,7); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,6); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,5); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,4); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,3); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,2); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,1); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
data=bit_test(i,0); delay_us(100);clock=1;delay_us(200);clock=0;delay_us(200);
}
///////////////////////////////////////////////////////////////////////
int16 long_convert(int16 i)
{
int16 temp=0;
#bit bit0=temp.0
#bit bit1=temp.1
#bit bit2=temp.2
#bit bit3=temp.3
#bit bit4=temp.4
#bit bit5=temp.5
#bit bit6=temp.6
#bit bit7=temp.7
#bit bit8=temp.8
#bit bit9=temp.9
#bit bit10=temp.10
#bit bit11=temp.11
#bit bit12=temp.12
#bit bit13=temp.13
#bit bit14=temp.14
#bit bit15=temp.15
bit0 =bit_test(i,7);
bit1 =bit_test(i,6);
bit2 =bit_test(i,5);
bit3 =bit_test(i,4);
bit4 =bit_test(i,3);
bit5 =bit_test(i,2);
bit6 =bit_test(i,1);
bit7 =bit_test(i,0);
bit8 =bit_test(i,15);
bit9 =bit_test(i,14);
bit10 =bit_test(i,13);
bit11 =bit_test(i,12);
bit12 =bit_test(i,11);
bit13 =bit_test(i,10);
bit14 =bit_test(i,9);
bit15 =bit_test(i,8);
return temp;
}
here are patterns for re
Code:
const int16 pat[135][3] =
// F 8 F 8 F 8
{
0b0000000000000000,0b0000000000000000,0b0000000000000000,//0 loop1
0b0000000000000000,0b0000000000000000,0b0000000000000001,//1
0b0000000000000000,0b0000000000000000,0b0000000000000011,//2
0b0000000000000000,0b0000000000000000,0b0000000000000101,//3
0b0000000000000000,0b0000000000000000,0b0000000000001001,//4
0b0000000000000000,0b0000000000000000,0b0000000000010001,//5
0b0000000000000000,0b0000000000000000,0b0000000000100001,//6
0b0000000000000000,0b0000000000000000,0b0000000001000001,//7
0b0000000000000000,0b0000000000000000,0b0000000010000001,//8
0b0000000000000000,0b0000000000000000,0b0000000100000001,//9
0b0000000000000000,0b0000000000000000,0b0000001000000001,//10
0b0000000000000000,0b0000000000000000,0b0000010000000001,//11
0b0000000000000000,0b0000000000000000,0b0000100000000001,//12
0b0000000000000000,0b0000000000000000,0b0001000000000001,//13
0b0000000000000000,0b0000000000000000,0b0010000000000001,//14
0b0000000000000000,0b0000000000000000,0b0100000000000001,//15
0b0000000000000000,0b0000000000000000,0b0000000000000111,//16 loop2
0b0000000000000000,0b0000000000000000,0b0000000000011001,//17
0b0000000000000000,0b0000000000000000,0b0000000001100001,//18
0b0000000000000000,0b0000000000000000,0b0000000110000001,//19
0b0000000000000000,0b0000000000000000,0b0000011000000001,//20
0b0000000000000000,0b0000000000000000,0b0001100000000001,//21
0b0000000000000000,0b0000000000000000,0b0110000000000001,//22
0b0000000000000000,0b0000000000000000,0b0000000000000001,//23
0b0000000000000000,0b0000000000000000,0b0111111111111111,//24
0b0000000000000000,0b0000000000000000,0b0000000000000001,//25
0b0000000000000000,0b0000000000000000,0b0111111111111111,//26
0b0000000000000000,0b0000000000000000,0b1000000000000000,//27 loop3
0b0000000000000000,0b0000000000000001,0b1000000000000000,//28
0b0000000000000000,0b0000000000000010,0b1000000000000000,//29
0b0000000000000000,0b0000000000000100,0b1000000000000000,//30
0b0000000000000000,0b0000000000001000,0b1000000000000000,//31
0b0000000000000000,0b0000000000010000,0b1000000000000000,//32
0b0000000000000000,0b0000000000100000,0b1000000000000000,//33
0b0000000000000000,0b0000000001000000,0b1000000000000000,//34
0b0000000000000000,0b0000000010000000,0b1000000000000000,//35
0b0000000000000000,0b0000000100000000,0b1000000000000000,//36
0b0000000000000000,0b0000001000000000,0b1000000000000000,//37
0b0000000000000000,0b0000010000000000,0b1000000000000000,//38
0b0000000000000000,0b0000100000000000,0b1000000000000000,//39
0b0000000000000000,0b0000000000000011,0b1000000000000000,//40
0b0000000000000000,0b0000000000001100,0b1000000000000000,//41
0b0000000000000000,0b0000000000110000,0b1000000000000000,//42
0b0000000000000000,0b0000000011000000,0b1000000000000000,//43
0b0000000000000000,0b0000001100000000,0b1000000000000000,//44
0b0000000000000000,0b0000110000000000,0b1000000000000000,//45
0b0000000000000000,0b0000000000000000,0b1000000000000000,//46
0b0000000000000000,0b0000111111111111,0b1000000000000000,//47
0b0000000000000000,0b0000000000000000,0b1000000000000000,//48
0b0000000000000000,0b0000111111111111,0b1000000000000000,//49
0b0000000000000000,0b0001000000000000,0b0000000000000000,//50 loop4
0b0000000000000000,0b0011000000000000,0b0000000000000000,//51
0b0000000000000000,0b0101000000000000,0b0000000000000000,//52
0b0000000000000000,0b1001000000000000,0b0000000000000000,//53
0b0000000000000001,0b0001000000000000,0b0000000000000000,//54
0b0000000000000010,0b0001000000000000,0b0000000000000000,//55
0b0000000000000100,0b0001000000000000,0b0000000000000000,//56
0b0000000000001000,0b0001000000000000,0b0000000000000000,//57
0b0000000000010000,0b0001000000000000,0b0000000000000000,//58
0b0000000000100000,0b0001000000000000,0b0000000000000000,//59
0b0000000001000000,0b0001000000000000,0b0000000000000000,//60
0b0000000000000000,0b0111000000000000,0b0000000000000000,//61
0b0000000000000001,0b1001000000000000,0b0000000000000000,//62
0b0000000000000110,0b0001000000000000,0b0000000000000000,//63
0b0000000000011000,0b0001000000000000,0b0000000000000000,//64
0b0000000001100000,0b0001000000000000,0b0000000000000000,//65
0b0000000000000000,0b0001000000000000,0b0000000000000000,//66
0b0000000001111111,0b1111000000000000,0b0000000000000000,//67
0b0000000000000000,0b0001000000000000,0b0000000000000000,//68
0b0000000001111111,0b1111000000000000,0b0000000000000000,//69
0b0000000000000000,0b0000000000000000,0b0000000000000000,//70 complete off
0b0000000000000000,0b0000000000000000,0b0000000000000000,//71 complete off
0b0000000000000000,0b0001000000000000,0b1000000000000001,//72 loop5
0b0000000000000000,0b0001000000000000,0b1000000000000011,//73
0b0000000000000000,0b0001000000000000,0b1000000000000101,//74
0b0000000000000000,0b0001000000000000,0b1000000000001001,//75
0b0000000000000000,0b0001000000000000,0b1000000000010001,//76
0b0000000000000000,0b0001000000000000,0b1000000000100001,//77
0b0000000000000000,0b0001000000000000,0b1000000001000001,//78
0b0000000000000000,0b0001000000000000,0b1000000010000001,//79
0b0000000000000000,0b0001000000000000,0b1000000100000001,//80
0b0000000000000000,0b0001000000000000,0b1000001000000001,//81
0b0000000000000000,0b0001000000000000,0b1000010000000001,//82
0b0000000000000000,0b0001000000000000,0b1000100000000001,//83
0b0000000000000000,0b0001000000000000,0b1001000000000001,//84
0b0000000000000000,0b0001000000000000,0b1010000000000001,//85
0b0000000000000000,0b0001000000000000,0b1100000000000001,//86
0b0000000000000000,0b0001000000000001,0b1000000000000001,//87
0b0000000000000000,0b0001000000000010,0b1000000000000001,//88
0b0000000000000000,0b0001000000000100,0b1000000000000001,//89
0b0000000000000000,0b0001000000001000,0b1000000000000001,//90
0b0000000000000000,0b0001000000010000,0b1000000000000001,//91
0b0000000000000000,0b0001000000100000,0b1000000000000001,//92
0b0000000000000000,0b0001000001000000,0b1000000000000001,//93
0b0000000000000000,0b0001000010000000,0b1000000000000001,//94
0b0000000000000000,0b0001000100000000,0b1000000000000001,//95
0b0000000000000000,0b0001001000000000,0b1000000000000001,//96
0b0000000000000000,0b0001010000000000,0b1000000000000001,//97
0b0000000000000000,0b0001100000000000,0b1000000000000001,//98
0b0000000000000000,0b0011000000000000,0b1000000000000001,//99
0b0000000000000000,0b0101000000000000,0b1000000000000001,//100
0b0000000000000000,0b1001000000000000,0b1000000000000001,//101
0b0000000000000001,0b0001000000000000,0b1000000000000001,//102
0b0000000000000010,0b0001000000000000,0b1000000000000001,//103
0b0000000000000100,0b0001000000000000,0b1000000000000001,//104
0b0000000000001000,0b0001000000000000,0b1000000000000001,//105
0b0000000000010000,0b0001000000000000,0b1000000000000001,//106
0b0000000000100000,0b0001000000000000,0b1000000000000001,//107
0b0000000001000000,0b0001000000000000,0b1000000000000001,//108
0b0000000000000000,0b0001000000000000,0b1000000000000111,//109
0b0000000000000000,0b0001000000000000,0b1000000000011001,//110
0b0000000000000000,0b0001000000000000,0b1000000001100001,//111
0b0000000000000000,0b0001000000000000,0b1000000110000001,//112
0b0000000000000000,0b0001000000000000,0b1000011000000001,//113
0b0000000000000000,0b0001000000000000,0b1001100000000001,//114
0b0000000000000000,0b0001000000000000,0b1110000000000001,//115
0b0000000000000000,0b0001000000000011,0b1000000000000001,//116
0b0000000000000000,0b0001000000001100,0b1000000000000001,//117
0b0000000000000000,0b0001000000110000,0b1000000000000001,//118
0b0000000000000000,0b0001000011000000,0b1000000000000001,//119
0b0000000000000000,0b0001001100000000,0b1000000000000001,//120
0b0000000000000000,0b0001110000000000,0b1000000000000001,//121
0b0000000000000000,0b0111000000000000,0b1000000000000001,//122
0b0000000000000001,0b1001000000000000,0b1000000000000001,//123
0b0000000000000110,0b0001000000000000,0b1000000000000001,//124
0b0000000000011000,0b0001000000000000,0b1000000000000001,//125
0b0000000001100000,0b0001000000000000,0b1000000000000001,//126
0b0000000001111111,0b1111111111111111,0b1111111111111111,//127 loop6 all flash
0b0000000000000000,0b0001000000000000,0b1000000000000001,//128
0b0000000001111111,0b1111111111111111,0b1111111111111111,//129
0b0000000000000000,0b0001000000000000,0b1000000000000001,//130
0b0000000001111111,0b1111111111111111,0b1111111111111111,//131
0b0000000000000000,0b0001000000000000,0b1000000000000001,//132
0b0000000000000000,0b0000000000000000,0b0000000000000000,//133
};
without load all of things works normal.
when i connect any load to output of relays the 74ls595 miss behaves.
it takes noise from any where .
The microcontroller 18f452 works normal either load is connected or not.
My question is "how to remove prevent 74ls595 from noise ".
load voltage is 220vac
load current is 0.5amp for each relay.