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.

Voltage comparator for zero cross detection

Status
Not open for further replies.
I found no problem with a triac but using delay() function is not providing a very long range for firing angle generation.
I thought I could find reference docs for using timer so that I could get good adjustment with timer0 or timer1 so that my pic could trigger the TRIAC with a good long range.

I would like to find a support for generating that delay using those timers techniques but also using push button or potentiometer.

Please help.
 

I found no problem with a triac but using delay() function is not providing a very long range for firing angle generation.
I thought I could find reference docs for using timer so that I could get good adjustment with timer0 or timer1 so that my pic could trigger the TRIAC with a good long range.

I would like to find a support for generating that delay using those timers techniques but also using push button or potentiometer.

Please help.

Your question is solved but your problem is different.
Please define how you shift phase and what you measured with schematic, calculations for scope
 

My problem is not well solved as I want because I would like to have a long range of adjustment means,I could for example create a delay in terms of microseconds but which helps to adjust up to 10ms(because the frequency here is 50HZ),so when I set the delay in terms of milliseconds,the adjustment range very is narrow therefore I can`t simulate for multiple foltage 230VAC----0V having for example 10V step with the potentiometer connected on the RA0 and by analog reading.

The adc value could be used for defining a delay value so the voltage changes.


I was thinking on reading adc as the maximum is 5V and the minimum is 0v THEN

Consider that as multiplication factor and then

create initial delay of 2000 microseconds for example and then
for the next steps
take the adc value(which is float)*the initial values which is 2000us

could you please help me to extend the functionalities of my circuit in that direction or use of timer which I am not familiar with.

In all case I am lloking for a help so that I could have a wide range of adjustument which gives for example 10V of step from 230V to 0V for driving my AC single phase motor.

Please help
 

I meant your ZCS question was solved with a solution.
The next problem is phase control.
The ZCS pulse is often used with a variable one-shot or timer in software such that the end of the interval is the beginning of the trigger as long as the timer is limited before the next ZCS pulse.

The trigger width only needs to be long enough to satisfy the Triac and there is at least 2V across the Triac for it to conduct and latch, therefor if the ZCS pulse was sufficiently narrow it should not trigger the Triac at all but when stretched the line voltage will rise above 2V to enable the Triac to triggered. This minimum pulse width is necessary to trigger full cycle ON at the ZCS point, such as 1% of 340Vp or 10ms = 100us minimum.

Thus you understand I hope that increasing the delay will now reduce the time current is switched on from full cycle and dim the load.

ANalog controllers are quite simple. Instead of detecting ZCS, they simply delay the sine line voltage with two 90 deg LPF to get 180 deg delayed trigger for the "off" condition or end of half cycle. The triac then automatically stops conduction at zero current crossing and if no gate voltage , it is not re-triggered.

I wont be the one assisting you with how to program this.


Below when Pot is min. the time delay is minimal and will conduct full cycle when the DIAC threshold (2V) is reached. Increasing pot to max, turns into a 2 stage phase shifter at 50 Hz.
 
Last edited:

What are you proposing sir,I showed all my capabilities in coding ,couldn`t you help?for enhancing my codes functionalities?
 

Hello,find here the codes I am using;I changed a little bit and want to change the firing angle using switch buttons but I am not succeeding to do that with proteus and microc,please could you let me know other mathematics and coding I have to handle?
Code:
unsigned char FlagReg;
sbit ZC at FlagReg.B0;
void main(void)
{
PORTB=0;
TRISB=0X01;
PORTA=0XFF;
TRISA=0XFF;
PORTC=0;
TRISC=0X00;
ANSELA=0X00;
OPTION_REG.INTEDG=0;//interrupt on falling edge
INTCON.INTF=0; //clear flag bit
INTCON.INTE=1;  //Enable external interrupt
INTCON.GIE=1;   //Enable Global interrupt
INTCON.PEIE=1;  //Enable peripheral interrupt
 while(1)
 {
 if(ZC)
 {
if(!PORTA.B1)
{
  delay_ms(2);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
  else if(!PORTA.B2)
  {
  delay_ms(4);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
   else if(!PORTA.B3)
  {
  delay_ms(6);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
  
  else
  {
  delay_ms(2);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  
  }
  
 }
 }
}
void interrupt(void)
{
 if(INTCON.INTF==1)
 {
  ZC=1;
  INTCON.INTF=0;
 }
}

schema.png
 

Attachments

  • schema.pdf
    17.1 KB · Views: 66
Last edited by a moderator:

I presume, the current sourced by R10 will be never sufficient to trigger MOC3021. Unfortunately the supply voltage is unknown. Read a datasheet, apply ohms law.
 

snubber circuit for TRIAC calculations

Hello Dear,I am implementing a circuit which may control the speed of an AC single phase motor(AC Fan) controlled by a TRIAC interfaced to a Microcontroller,I written the codes when simulating with Proteus I judged that the circuit is well functioning but when the codes are loaded and the Fan is connected the voltage is at 220VAC/50HZ.

So I can`t change the speed with my provided switches,could you please advise and let me know the determination of snubber circuit components?

I am using PIc16F1936,find the codes here below using MicroC and the circuit is attached.
PHP:
unsigned char FlagReg;
sbit ZC at FlagReg.B0;
void main(void)
{
PORTB=0;
TRISB=0X01;
PORTA=0XFF;
TRISA=0XFF;
PORTC=0;
TRISC=0X00;
ANSELA=0X00;
OPTION_REG.INTEDG=0;//interrupt on falling edge
INTCON.INTF=0; //clear flag bit
INTCON.INTE=1;  //Enable external interrupt
INTCON.GIE=1;   //Enable Global interrupt
INTCON.PEIE=1;  //Enable peripheral interrupt
 while(1)
 {
 if(ZC!=0)
 {
if(!PORTA.B1)
{
  delay_ms(2);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
  else if(!PORTA.B2)
  {
  delay_ms(4);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
   else if(!PORTA.B3)
  {
  delay_ms(6);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  }
  
  else if(!PORTA.B4)
  {
  delay_ms(8);
  PORTC.B6=1;
  delay_us(250);
  PORTC.B6=0;
  ZC=0;
  
  }
  
 }
 }
}
void interrupt(void)
{
 if(INTCON.INTF==1)
 {
  ZC=1;
  INTCON.INTF=0;
 }
}
 

Attachments

  • circuit.zip
    138.7 KB · Views: 59
Last edited:

Hello,FvM,the supply voltage is of 12V as VCC of the transistor and then the R10 is reduce up to 1.8Kohm till now I don`t get good result,could you refer to this and guide?
The current of the MOC3020 used not MOC3021 and current sourced by the BC548 are confusing so I am unable to calculate the right things,could you please guide?

Regards
 

MOC3020 current is not sourced by a transistor, in so far I don't understand the problem. Maximum required trigger current can be as high as 30 mA according to datasheet, maximum LED voltage drop is 1.5 V, so according to ohms law R10 = 10.5V/30 mA = 350 ohm.

A snubber may be required to avoid triac/opto triac self triggering, particularly with inductive load or distorted mains voltage. You find circuit suggestions in MOC3020 data sheet. But apparently unwanted self triggering isn't your problem right now.
 

Dear FvM,I have now adjusted the values as you advised but no success,I checked with proteus in simulation the program is running very well and I can adjust the delay time,unfortunately I can`t control the TRIAC with microcontroller when the codes are loaded in the PIC.
I am suspecting that some electronic component is the source of fault of current or voltage which may give proper working conditions but I am always getting 149V when the motor is connected on the circuit.Please could you help me to solve the problem and make the moor works as expected?The bulb is connected on the circuit because in proteus I can`t find an AC Motor.
Find the codes here,the circuit is also attached:
PHP:
unsigned char FlagReg;
sbit ZC at FlagReg.B0;

void interrupt()
{
 if(INTCON.INTF==1)
 {
  ZC=1;
  INTCON.INTF=0;
 }
}


void main()
{
PORTB=0;
TRISB=0x01; //RB0 input for interrupt
PORTC=0;
TRISC=0x00;    //portc set as output for driving The TRIAC
ANSELA=0x00;    //Cleared for using
OPTION_REG.INTEDG=1;//interrupt on falling edge
INTCON.INTF=0; //clear flag bit
INTCON.INTE=1;  //Enable external interrupt
INTCON.GIE=1;   //Enable Global interrupt
INTCON.PEIE=1;  //Enable peripheral interrupt
 while(1)
 {
if(ZC){

  delay_ms(4);
  PORTC.B6=1;
  delay_us(450);
  PORTC.B6=0;
  ZC=0;
    }
 }
 }
Please advise.!!
 

Attachments

  • Forum_Ok.png
    Forum_Ok.png
    68.9 KB · Views: 71
  • forum.pdf
    13.7 KB · Views: 60

Hello,I analyzed that with my snubber the current passes through snubber and then the PIC can`t control the triac I connected a bulb on my circuit but the microcontroller can`t control it.
I implemented the circuit of https://mlabsbd.wordpress.com/?s=dimmer with snubber components values of 47Ohms and 470nF(here I used 240nF),could you please help me to well make my circuit in operation?
Across the load I am measuring maximum AC Voltage of 110VAC but I want to be making a dimmer as a testing and then move to a fan controller with PIC where the switches helps in setting different firing angles with settings the delay time.
Refer to my circuit in attachment.

PHP:
/***********************************************************************
controlling  AC Fan with single phase AC Motor
MCU: PIc16f877A; X-Tal: 4MHz(External)
***********************************************************************/
// PIN difine...
#define Fan             PORTD.B0
#define Zero            PORTB.B0

#define Plus_Button     PORTC.B2
#define Minus_Button    PORTC.B3
#define Buzzer          PORTD.B6

// global variables
unsigned int current=5;
unsigned int ch_cnt=0;

// Interrupt ...
void interrupt()
{
     while(Zero==0)
     {
       ch_cnt++;
       while(ch_cnt<=105-current)
       {
        Fan = 0;
        break;
       }
       while(ch_cnt>=105-current)
       {
        Fan = 1;
        break;
       }
       break;
     }
     while(Zero==1)
     {
       Fan = 0;
       ch_cnt = 0;
       break;
     }
    // Timer settings
    TMR0IF_bit = 0;
    TMR0 = 250;
}// interrupt


unsigned int time_delay=0;
void main()
{
 //TRISIO = 0b00110001;
 TRISD=0XF0;
 PORTD=0;
 TRISC=0X0F;
 OPTION_REG = 0x81;
 TMR0 = 220;
 INTCON = 0xA0;
 TMR0IE_bit = 1;// enable timer0
  while(1)
  {
       while(!Minus_Button)
       {
         if(current<90)
         {
          current+=10;
          Delay_ms(20);
         }
         else
         {
          current = 100;
         }
         Buzzer = 1;
         Delay_ms(80);
         Buzzer = 0;
         time_delay = 0;
         break;
       }
       while(!Plus_Button)
       {
          if(current>11)
          {
            current-=10;
            Delay_ms(20);
          }
          else
          {
           current = 0;
          }
          Buzzer = 1;
          Delay_ms(80);
          Buzzer = 0;
          time_delay = 0;
          Delay_ms(20);
          break;
      }

  }// While
}// void main

The codes are also provided herein.

Please help me to think and handle this issue.
 

Attachments

  • circuit_Ok.png
    circuit_Ok.png
    280.2 KB · Views: 80

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top