+ Post New Thread
Results 1 to 14 of 14
  1. #1
    Junior Member level 1
    Points: 230, Level: 2

    Join Date
    Apr 2018
    Posts
    17
    Helped
    0 / 0
    Points
    230
    Level
    2

    AC on/off control with triac directly with mcu without opto

    i need code for ac on/off control without opto to detect zc and and to control triac for on/off in xc8 pic16f628a
    can ny body let me kno with some code how do i implement that....
    tnx

  2. #2
    Super Moderator
    Points: 68,799, Level: 64
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,040
    Helped
    3214 / 3214
    Points
    68,799
    Level
    64

    Re: AC on/off control with triac directly with mcu without opto

    Hi,

    Do you know how to switch a microcontroller port pin HIGH and LOW?
    * If yes: That's it.
    * If no: I recommend to learn it.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisment

        
       

  3. #3
    Super Moderator
    Points: 76,228, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,463
    Helped
    4152 / 4152
    Points
    76,228
    Level
    67

    Re: AC on/off control with triac directly with mcu without opto

    Driving a PIC pin high or low is all it takes but be aware of the problems of isolation and gate polarity. Without an opto-isolator, or maybe a pulse transformer, you have to connect the PIC VSS directly to one side of the AC. That makes it almost impossible to interface to anything else unless it too is tied to one of the AC lines. It can be extremely dangerous if there is any chance of human contact with the PIC or you try to interface to anything else. The other advantage of an opto is if you use one with ZCD (MOC304x for example) you don't have to worry about zero crossing, it does it for you.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  4. #4
    Junior Member level 1
    Points: 230, Level: 2

    Join Date
    Apr 2018
    Posts
    17
    Helped
    0 / 0
    Points
    230
    Level
    2

    Re: AC on/off control with triac directly with mcu without opto

    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	48.8 KB 
ID:	150447
    This has been seen a AN of Microchip.
    Would u tell me how do i go forward, how maintain Gate polarity if u get me details.
    tnx for advice



  5. #5
    Super Moderator
    Points: 68,799, Level: 64
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,040
    Helped
    3214 / 3214
    Points
    68,799
    Level
    64

    Re: AC on/off control with triac directly with mcu without opto

    Hi,

    Now it is different:
    * before you talk about ON/OFF control
    * now it is "dim" and "bright"

    What do you mean with "maintain Gate polarity"?

    The function is as simple as can be:
    * Port pin = HIGH --> triac will trigger
    * Port pin = LOW --> triac will release

    Give (the link to) the document you refer to.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  6. #6
    Junior Member level 1
    Points: 230, Level: 2

    Join Date
    Apr 2018
    Posts
    17
    Helped
    0 / 0
    Points
    230
    Level
    2

    Re: AC on/off control with triac directly with mcu without opto

    Actually would like FIRST with the ckt above with MCU16f628A in liew of MCU12c508>> to control ON/OFF(single button) using 230v/50hz.
    What I have understand, as document ckt is operating at 120/60hz, so value of resistor for zc need to be change>>but what would be that for my operating volt, calculation is expected??
    After that if i able to success, then go forward for next>>ie, dimmer and operation will like one for BRT and for DIM button and this two only operate if above "single button" is ON.

    lINK IS HERE:
    http://ww1.microchip.com/downloads/e...tes/40171a.pdf

    req ur help please ??
    tnx



    •   AltAdvertisment

        
       

  7. #7
    Super Moderator
    Points: 76,228, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,463
    Helped
    4152 / 4152
    Points
    76,228
    Level
    67

    Re: AC on/off control with triac directly with mcu without opto

    The resistor at GP4 isn't critical, all it does is limit the current to the PIC internal clamp diodes to a safe level. I would suggest if you use 230V that you increase it to 30M but using three 10M resistors in series as a single resistor may not be rated to high enough voltage.

    You can use any PIC, the software changes are negligible but the different AC frequency means you have to select a different delay so the triac fires slightly longer after zero crossing. The dimming is achieved by firing through the whole AC cycle or through part of it only. It will be dimmer as the firing point is later after zero crossing so any values calculated for a 16mS (60Hz) AC will need to be bigger for 20mS (50Hz) cycle periods. The delay calculation will depend on the clock speed of the 16F628A.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  8. #8
    Junior Member level 1
    Points: 230, Level: 2

    Join Date
    Apr 2018
    Posts
    17
    Helped
    0 / 0
    Points
    230
    Level
    2

    Re: AC on/off control with triac directly with mcu without opto

    But why getting burnt..
    As per my opinion calculated current 8uA to the pin as extracted by ohms low, i=240/30M = 8uA, and power rating (8*8*30) uWatt. SO, 1/4 watt of 30M is sufficient. But Why getting burnt on power up??
    Thnx



  9. #9
    Super Moderator
    Points: 68,799, Level: 64
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,040
    Helped
    3214 / 3214
    Points
    68,799
    Level
    64

    Re: AC on/off control with triac directly with mcu without opto

    Hi,

    Hard to follow your thoughts:
    * First you want code --> then you refer to a AN that includes code
    * then you want ON/OFF control --> then it seems you want dimming
    * Then you say something that got burnt.... but you donīt show it.

    --> I can only gues that you talk about R3. (but maybe the microcntroller burnt or the triac or anything else... --> give useful and complete infromations)
    * The AN discusses about itīs function and rating
    * if you keep on the AN the resistor will not burn.
    * If your resistor burns, then itīs not the probelm of the schematic and not the problem of the AN
    --> the problem is your circuit.. Thus you have to show us your circuit, if you need help. (photo of your circuit, datasheets of the used resistor...)

    ***
    as already explained:
    as a single resistor may not be rated to high enough voltage
    .. but you talk about power rating...

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  10. #10
    Super Moderator
    Points: 76,228, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,463
    Helped
    4152 / 4152
    Points
    76,228
    Level
    67

    Re: AC on/off control with triac directly with mcu without opto

    What is burning?

    Your calculation is correct, the current is actually 7.667uA and the resistor only dissipates 1.763mW if you assume the RMS voltage as 230V. The problem is that most 1/4W resistors are not rated to high voltage, some are rated to less then 50V and few are rated to as much as 230V. Bear in mind that 230V RMS has a peak voltage of 325V and the resistor(s) have to be rated at a higher voltage than that. Using three standard 1/4W resistors in series should be safe.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  11. #11
    Junior Member level 1
    Points: 230, Level: 2

    Join Date
    Apr 2018
    Posts
    17
    Helped
    0 / 0
    Points
    230
    Level
    2

    Re: AC on/off control with triac directly with mcu without opto

    tnx.
    could u please send me a link where i can get 400v/250v resistor. I have googled but not able to right one. they are not mentioning any voltage level..
    Tnx.



    •   AltAdvertisment

        
       

  12. #12
    Super Moderator
    Points: 68,799, Level: 64
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,040
    Helped
    3214 / 3214
    Points
    68,799
    Level
    64

    Re: AC on/off control with triac directly with mcu without opto

    Hi,

    they are not mentioning any voltage level.
    Every resistor datasheet mentiones the voltage.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  13. #13
    Super Moderator
    Points: 76,228, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,463
    Helped
    4152 / 4152
    Points
    76,228
    Level
    67

    Re: AC on/off control with triac directly with mcu without opto

    If in doubt, do as I suggested earlier and use several resistors in series. If you make each one 10M and use three in series, each will only have 1/3 of the voltage across it. Klaus is quite right though, all respectable suppliers will tell you the rated voltage. For axial resistors it is typically 250V and for SMD it ranges from about 50 to 200V but note that those are MAXIMUM voltages before damage and you need to rate against the peak AC voltages, not the RMS ones in your design. That means you should aim for at least 1.42 times the RMS voltage to be sure and then add a safety margin as well.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  14. #14
    Full Member level 6
    Points: 2,025, Level: 10

    Join Date
    Aug 2017
    Posts
    385
    Helped
    40 / 40
    Points
    2,025
    Level
    10

    Re: AC on/off control with triac directly with mcu without opto

    Test attached dimmer simulation and tell whether that is what you need.

    Any button long press for 3 or more seconds and release = Triac ON/OFF
    INC button short press (less than 3 sec) = Firing Angle Increment
    DEC button short press (less than 3 sec) = Firing Angle Decrement

    I forgot to add MOV. Add am MOV across the mains input. 275 Vrms type.
    Last edited by baileychic; 30th December 2018 at 12:10.



--[[ ]]--