jean12
Advanced Member level 2
- Joined
- Aug 27, 2013
- Messages
- 529
- Helped
- 5
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 18
- Activity points
- 5,497
first of all you should detect zero cross of your line power, show you a circuit although you can fine ICs over the net ( such as HT46R47 )
secondly for controlling the heater find and optotriac ( MOC3052 is my recommendation. don't choose an optotriac with zerocross).
finally after detecting the zero cross you are able to control the fire triac and trigger time.
In this link https://tahmidmc.blogspot.in/2013/06/ac-power-control-with-thyristor-pulse.html
When ever there is a zero crossing INT0 will detect it and ZC is made high.
TRIAC conducts in both direction. If you want to reduce power to 50% then you have to fire triac for 90 degrees in each half cycle of AC. Trigger TRIAC at Zero crossing. Freq = 50 Hz (AC).
T = 0.2 sec.
90 degree of half cycle is 0.005 sec = 50 ms.
Fire triac for 50 ms when ever there is a zero crossing.
t = 0, triac fires for 50 ms, 50% of haff cycle is conducted. Next 50% is not conducted. Then another ZC occurs and conducts negative half cycles' 50% and repeats.
#include"16f877a.h"
#device adc=10
#fuses HS,NOWDT,NOLVP,NODEBUG,NOCPD
#use delay(clock=4M)
#int_ext
int value,delaya;
unsigned long value1;
unsigned int value2;
void isrext()
{
output_D(0xff);
delay_ms(1000);
}
void main()
{
set_tris_a(0xff);
set_tris_b(0x01);
set_tris_d(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(False);
int x=0;
enable_interrupts(int_ext);
enable_interrupts(global);
ext_int_edge(L_TO_H);
while(1)
{
delay_us(20);
read_adc(adc_start_only);
delay_us(20);
value=read_adc(adc_read_only);
value1=(value*500)/1023;
value2=value1;
delaya=(value2*20)/5;
output_high(PIN_D0);
delay_ms(delaya);
output_low(PIN_D0);
}
}
I supposed that the variable resistor maximum voltage is 5V and then when it ia being adjusted 0V..........5V
we will be having a delay of :(20ms/value of voltage on resistors)/5V
Why don't you zip and post your CCS C project files and Proteus file. Why do you expect others to Create a project and test your code and Simulation?
#include"16f877a.h"
#device adc=10
#fuses HS,NOWDT,NOLVP,NODEBUG,NOCPD
#use delay(clock=4M)
#int_ext
int value,delaya;
unsigned long value1;
unsigned int value2;
void isrext()
{
output_c(0xff);
delay_ms(1000);
}
void main()
{
set_tris_a(0xff);
set_tris_b(0x01);
set_tris_c(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(False);
int x=0;
enable_interrupts(int_ext);
enable_interrupts(global);
ext_int_edge(L_TO_H);
while(1)
{
delay_us(20);
read_adc(adc_start_only);
delay_us(20);
value=read_adc(adc_read_only);
value1=(value*500)/1023;
value2=value1;
delaya=(value2*20)/5;
output_high(PIN_c6);
delay_ms(delaya);
output_low(PIN_c6);
}
}
Post your CCS C project files zipped. You just posted the Proteus file.
#include"16f877a.h"
#device adc=10
#fuses HS,NOWDT,NOLVP,NODEBUG,NOCPD
#use delay(clock=4M)
#int_ext
//--------------START of variable for Pulse delay definition---------------
int valuet;
unsigned long value1;
unsigned int value3,delaya;
//--------------Ends of variable for Pulse delay definition---------------
//--------------START OF variable for temperature reading---------------
byte const digit[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //Changed this as there was error in the previous one
char display[2];
int value;
unsigned long volt;
unsigned int value2;
//--------------END OF variable for temperature reading---------------
void isrext()
{
output_c(0xff);
delay_ms(1000);
}
void main()
{
set_tris_a(0xff);
set_tris_b(0x01);
set_tris_c(0x00);
set_tris_d(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);
//setup_adc_ports(AN0_AN1);
setup_vref(False);
int x=0;
enable_interrupts(int_ext);
enable_interrupts(global);
ext_int_edge(H_TO_L);
while(1)
{
//------------------Temperature reading and display
set_adc_channel(0);
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
//volt=(value*500)/1023; //I changed this part of the code
volt=(value*500)/1023;
value2=volt;
delay_us(1);
output_high(PIN_D1);
display[0]=value2/10;
output_B(digit[display[0]]);
output_low(PIN_D0);
delay_ms(1);
output_high(PIN_D0);
display[1]=value2%10;
output_B(digit[display[1]]);
output_low(PIN_D1);
delay_ms(1);
set_adc_channel(1);
delay_us(20);
read_adc(adc_start_only);
delay_us(20);
valuet=read_adc(adc_read_only);
value1=(valuet*500)/1023;
value3=value1;
//delaya=(value3*20)/10;
delaya=(value3);
output_high(PIN_c6);
delay_ms(delaya);
output_low(PIN_c6);
}
}
You can't do that. You need dp in SSD. So, you need 8 pins for SSD. Use other PORT for SSD if you want to use INT0 for detecting ZC. Use PORTC for SSD and INT0 for ZC.
You want to allow triac to conduct from 0 to 90 degree of AC 220V? Peak is 220V rms. 0 to 220V means 0 to 90 degree. When you detect ZC then conduct triac only for 0.005 sec. (F = 50 Hz)
Code C - [expand] 1 2 3 4 5 if(ZC){ fireGate = ~fireGate; if(fireGate)GATE = 1; else GATE = 0; }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?