TRIAC simulation is not working right

Status
Not open for further replies.

cool.man

Full Member level 6
Joined
May 29, 2008
Messages
323
Helped
42
Reputation
84
Reaction score
29
Trophy points
1,308
Location
Earth
Activity points
3,307
Hi Guys
I am trying to simulate a simple circuit called Dimmer Circuit. I wrote some lines for PIC16F877A microcontroller. I want to swtich Triac based on microcontroller output. Partially it is working fine. Negative portion of AC source is operating as desired but Positive portion of AC source is not operating, Can you look into the circuit and guide me where is the problem?




Channel A -> Zero Crossing Signal
Channel B -> AC Source
Channel C -> Microcontroller signal to TRIAC
Channel D -> Actual output

following is the code
Code:
#include <16F877A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(crystal=20000000)

int increment_scr = 0;

#int_EXT // Zero Crossing Interrupt
void EXT_isr(void)
{
    output_low(PIN_B2);
    delay_ms(increment_scr);
    output_high(PIN_B2);
    delay_ms(1);
    output_low(PIN_B2);
    //delay_ms(increment_scr);
}


void main()
{
    set_tris_b(0b0000001);  // setting the I/O pins of port B --> 1 pin will be set as input --- 0 as digital output
    
    enable_interrupts(INT_EXT);   // enabling external interrupt
    ext_int_edge(H_TO_L);         // external interrupt raise when signal goes from high to low
    enable_interrupts(GLOBAL);    // all interrupt are enabled

   while(1)
   {
      if(input(PIN_D0) != 1) // If push Button pressed then increment the value.
      {
         while(input(PIN_D0) != 1){}
      
         if (increment_scr >=9) increment_scr = 9;
         else increment_scr++;
      }
      
      if(input(PIN_D1) != 1) // If push Button pressed then decrement the value.
      {
         while(input(PIN_D1) != 1){}
      
         if (increment_scr <=0) increment_scr = 0;
         else increment_scr--;
      }
   }
}

Kindly have a look and guide me

Thanks
 

According to waveforms, MOC3021 LED current is below the specified maximal trigger threshold of 15 mA.
 

Thanks @FvM . I changed the resistor value to 100 Ohms but still same response
 

O.K., I didn't look thoroughly at the waveform. Problem is self-triggering of the circuit rather than not triggering. Thus it's not LED current related.

I'm a bit surprized that this problem appears in a simulation with purely resistive load. In real hardware, it occurs with inductive load or non-sinusoidal voltage input and can be usually fixed by a snubber across the triac.
 

Hi,

I see no reason for self triggering either.
Even the triac datasheet shows no difference in quadrant I and III operation.

Thus maybe a simulator problem.
In this case it shows "wrong fail"

But even if it shows this circuit as correctly working.... the real circuit may fail.
Mainly because it misses capacitors. Bulk and fast power supply capacitors as well as debouncing capacitors at the pusbuttons.

Simulators: blessing or curse?

Klaus
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…