Vous êtes sur la page 1sur 6

AC power control with triac and PIC microcontroller 16F628A

Triac
The triac is a device able to drive in both directions, it is useful for use in controlling AC power, has a
pin through which driving is controlled.

schematic symbol of the triac

Driving begins when a minimum current magnitude is entered IG T positive or negative by the gate (G
Pin), once the triac becomes conductive, the gate loses control and the triac remain conducting until
the current flowing between A1 and A2 is less than a current maintenance IHIf we need the triac again
lead must launch another pulse of current in the gate, even though there are more ways to fire the
triac, for this purpose we will only use we have mentioned. Control Phase If we connect the Vac
source directly to the burden and assuming that the "lOAD" is purely resistive load, the power load is
given by:

P= V2A CR

Where:
VA C: Is the effective voltage of the sine wave

R: The value the resistive load.


Now, what happens if we allow current to the load is transferred only from a certain angle shot which
we will call ""The voltage reaching the load would waveform green as shown below.

Phase Control

You can take any value between 0 Y radians, the average power load receiving function
of angle shooting , It is given by the formula:
The angle

P= 1[ A s i n ( ) ]2R d

P= A22 R[ - + 12without( 2 ) ]
Where TOis the amplitude of the sine wave.
By symmetry of the problem is only necessary to integrate p i. In the same way if we calculate the
effective voltage of the new "sine chunked" wave function of the angle

we have:
Vr m s= A2 --[ - + 12without( 2 ) ]---------------

Then we plot the dependence between the angle " "Average power"P"And the effective voltage wave
chunked"Vr m s"

Angle shot chart, Efficient Power and Voltage

The chart above shows how varying the firing angle (axis X) Of the triac, we can vary the power
supplied to the load. In the chart,Vm to x is the maximum effective value corresponding to the actual
value of a complete sine wave that is TO2
A typical circuit for handling loads in AC is like the following figure:

Circuit 1 for power variation with triac

The process to conduct the microcontroller to vary power by triac comprises the following steps:

1:
2:
3:
4:

Detect beginning of a new medium wave cycle


Wait a time t corresponding to the angle alpha
Send the trigger signal to the control circuit
Return to step 1

To detect the beginning of a half cycle wave, which will use this circuit to connect output pin External

Interrupt.

Circuit 2, for detecting zero crossing of the sine wave.

In the circuit 2 show the waveforms generated at each stage of shaping circuit, this circuit is
responsible for conditioning the network signal for the PIC16F628A detect each half cycle of the
network, through the external interrupt (pin B0) .

Circuit 3, complete circuit to test the sample.

The code used to test the circuit is next, it is used is using the internal oscillator to 4MHz:

1:
2:
3:
4:

#include "16f628a.h"
#use delay (clock = 4000000)
#use standard_io (a)
#use standard_io (b)

5: #FUSES NOWDT // No Watch Dog Timer


6: #FUSES INTRC_IO // Internal RC Osc, no CLKOUT
7: #FUSES PUT // Power Up Timer
8: #FUSES protected from PROTECT // Code reads
9: #FUSES NOBROWNOUT // No brownout reset
10: #FUSES // MCLR Master Clear pin enabled
11: #FUSES NOLVP // No low voltage prgming, B3 (PIC16) or B5 (PIC18) used for
I / O
12: #FUSES NOCPD // No EE protection
13: #FUSES RESERVED // Used to Set the FUSE bits reserved
14: #DEFINE PIN_TTRIAC1 PIN_A3
15: #DEFINE PIN_TTRIAC2 PIN_b2
16: // The program works as follows:
17: // The waveshaping circuit, connected to pin INT0
18: // causes an interrupt is generated at each start of half cycle of the
sine wave
19: // network, so to 60Hz, an interrupt is generated every 1 / (2 * 60Hz) =
8.33ms
20: // When the interruption occurs, from routine EXT_ISR
21: // the INT_T0 interrupt is enabled and the TIMER0 register is loaded with
a value "k"
22: // Then comes the Timer0 overflow interrupt, and fire the triac,
23: // the value of "k" will be made continuously varied to achieve an effect
Flash
24: # int_TIMER0
25: INT_T0 void (void)
26: {
27: output_high (PIN_TTRIAC1);
28: output_high (PIN_TTRIAC2);
29: delay_us (10);
30: output_low (PIN_TTRIAC1);
31: output_low (PIN_TTRIAC2);
32: disable_interrupts (INT_TIMER0);
33:}
34: int k = 0;
35: #int_EXT
36: EXT_isr void (void)
37: {
38: set_timer0 (K--);
39: enable_interrupts (INT_TIMER0);
40:}
41: void config (void)
42: {

43: setup_timer_1 (T1_DISABLED);


44: setup_timer_2 (T2_DISABLED, 0.1);
45: setup_ccp1 (CCP_OFF);
46: setup_comparator (NC_NC_NC_NC);
47: setup_vref (FALSE);
48: enable_interrupts (INT_EXT);
49: ext_int_edge (l_to_h); // external interrupt by rising edge
50: setup_timer_0 (RTCC_INTERNAL | RTCC_DIV_32); // timer overflow with
maximum t = 1 / (2 * 60Hz) = 8.33ms
51: enable_interrupts (GLOBAL);
52: disable_interrupts (Int_Timer0); // we disable interrupt timer 0
53: set_tris_b (1);
54: set_tris_a (0);
56:}
57: void main (void)
58: {
59: config ();
61: while (true)
62: {
63: //
64:}
65:}

Vous aimerez peut-être aussi