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.

Interfacing a TRIAC to a PIC16F73

Status
Not open for further replies.

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
Hello,I would like to interface a TRIAC to a PIC for ac single phase motor control,I referred to Tahmid blog but I want to make this with a variable firing angle using a potentiometer on AN0 of the PIC and interrupt on RB0 for detecting the zero corss detection,soon I post the circuit but in any case,could you please refer to https://tahmidmc.blogspot.com/2012/10/zero-crossing-detection-with-pic16f877a.html and https://tahmidmc.blogspot.com/2013/06/power-control-with-thyristor-phase.html for zero cross detection and help me to implement my circuit codes suing the potentiometer for firing angle adjustment or using a two push button:
Button 1: for increasing the firing angle
button2:for decreasing the firing angle

Please help!!
 

Taking the part of the code that fires the TRIAC:


Code C - [expand]
1
2
3
4
5
6
7
8
while (1){
           if (ZC){ //zero crossing occurred
              delay_ms(2);
              PORTD.B0 = 1; //Send a pulse
              delay_us(250);
              PORTD.B0 = 0;
              ZC = 0;
           }



The argument of the function delay_ms() is what define the firing angle.
Actual value - 2ms - leads almost full power to the load.

To achieve what you want, you could declare on initialization of the code, an int variable, e.g: angle.
replace the above line 3 of the code by delay_ms(angle);

Within the while(1) loop, you could add somewhere a code to read and increment/decrement the angle accordingly ( perhaps additional debouncing time will be required ):


Code C - [expand]
1
2
3
4
5
6
if ( PORTD.B1 )
     /** Decrease power **/
     if ( ++angle > 8 ) = angle = 8 ;  // ensures that firing angle will not exceed 8,333ms
if ( PORTD.B2 )
     /** Increase power **/
    if ( angle-- == 0 ) = angle = 0 ;



Not tested, just try !

- - - Updated - - -

You can find this Tahmid's article published right here in Edaboard Blog section.

 

I have been trying the above codes but failed to complete,check the circuit in attachment here.I would like to speed-up or down a ventilator using those two push buttons interfaced with Microcontroller PIC16F73B.
the buttons help to increase or decrease the firing angle of the TRIAC which is interfaced to a PIC.please help they are below,the bulb in use with the circuit will be replaced by a vnetilator for physical implementation,I have referred to Tahmid blog
 

Attachments

  • Lighting_System.rar
    26.9 KB · Views: 102

check the circuit in attachment here

There is no schematic attached, at least not compatible with any known browser image formats.

- - - Updated - - -

I have been trying the above codes but failed to complete

In addition, you did not exactly what I said.

There is an else command in code not mentioned above.
You also are not instantiating anywhere the function dutychanger().
 

IN the attachment here you find a pdf schematic and the codes I am using in microc,I changed my mind a little bit,I would like to adjust the speed with a potentiometer,when reading adc value as it can`t exceed 5V,that value has to be used to create a required delay for firing the TRIAC.


unfortunately this statement can`t work
int v1;
unsigned int v;
v=ADC_read(0);
v1=v*5/1023;
delay_ms(v1)
with
ADCON0=0X81;
ADCON1=0X00;

Also the simulation in proteus a bridge rectifier is giving wrong signal,the scope shows a complete sine wave.


Dear andre,I used your codes as you indicated previously but they don`t execute.!!
Please help
 

Attachments

  • Lighting_System.rar
    67.4 KB · Views: 93
Last edited:

Dear andre,I used your codes as you indicated previously but they don`t execute.!!

No, you didn't.

The else clause is still there on the last attachment, as well there are other changes that you made on code, therefore it's hard to precisely determine the cause/effect of a change when you do multiples at once.
 

I did,
but it is not the ones I posted because with your codes the target was to use the push buttons but me,I would like to use a potentiometer and make proper voltage conversion so the value read from potentiometer be used as delay in ms,of course the +5V must be adapted to the complete range of half period.

can you also help to make simulation using bridge rectifier with proteus?

Why before on #2 you said angle should never exceed 8?

Please help,thanks
 

With experience I had using some triac, I realized that the minimum power output of the triac is close to 90degree of the phase angle. So for 50hz the total adjustable time is less than 5ms, I use 4ms. This means the potentiometer variation will be from 0-4ms. Or adc ranges will be equivalent to 0-4ms time.
Finally this is the delay time you observed after zero crossing before you fire the gate on with a pulse.
 

Hi,

Why don´t you read MOC3201 datasheet?

There is a section called "application information".

Correct your schematic.


Klaus
 

I did,
but it is not the ones I posted because with your codes the target was to use the push buttons but me,I would like to use a potentiometer and make proper voltage conversion so the value read from potentiometer be used as delay in ms,of course the +5V must be adapted to the complete range of half period.

No, you didn't. I gave you a tip to solve the initial problem, but you even had not informed if at least it solved or not THAT PROBLEM, once up to now, the code you posted is not as I said. You are now asking a solution using the A/D result as a phase selector. Unless you remove the else command from there, we'll not be able to know if the problem lies on the code placed at the main routine or on the code placed at the interrupt routine.

can you also help to make simulation using bridge rectifier with proteus?

Another incremental change in the original design. A standard rectifier have no utility on that because a Triac is a static switch, unless you now plan to make a PWM control. First you wanted to make a phase control, now supposed a switched rectifier ?

Why before on #2 you said angle should never exceed 8?

I was assuming a mains frequency of 60Hz, being 8,333ms the half period of a sinewave. In fact, the correct term is not angle, but rather delay ( or even phase ?).
 

Hello,Andre_Temprom;what if the CCP Interrupt is used and then a comparator is added to detect when the sine wave crosses zero point and at that time the CCP be activated to deliver a delay for firing angle setting?The problem is reading ADC and use it as delay,so the ADC may be delivered to be considered as delay conrresponding to the firing angle.!!

Please help!!

- - - Updated - - -

Dear KlausST ,unfortunately I don`t find a mistake in my circuit!!

Please help!!
 

Hi,

Dear KlausST ,unfortunately I don`t find a mistake in my circuit!!

Don´t you see the resistors in the MOC datasheet? They are missing you your schematic.

Klaus
 

Sir all components are provided as they look like in datasheet but nothing changed,about MOC3020,BTA26-600 and PIC.I started by connecting a bulb(as a pure resistive load) but this also is turning on as long as you connect the circuit but also the PIC output can`t act on the functionalities of the microcontroller.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top