+ Post New Thread
Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 61 to 80 of 88
  1. #61
    Super Moderator
    Points: 260,279, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,454
    Helped
    13829 / 13829
    Points
    260,279
    Level
    100

    Re: Why this is not working ?

    AC type opto ? There is no diode or bridge then how he get ZC pulses.
    There is a parallel diode, so surely no AC opto-coupler. Simply assume that the circuit is triggering with halfwave zero-crossing signal on both edges.


    1 members found this post helpful.

  2. #62
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Is it 1N4148 ?



    •   AltAdvertisement

        
       

  3. #63
    Super Moderator
    Points: 260,279, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,454
    Helped
    13829 / 13829
    Points
    260,279
    Level
    100

    Re: Why this is not working ?

    Is it 1N4148 ?
    Probably. Anything goes.


    1 members found this post helpful.

  4. #64
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Ok.

    Three buttons dimmer. I will soon post the PCB layout files.


    Edit: There is a bug. The negative half cycle is not controlling. Why ?
    Last edited by milan.rajik; 28th February 2015 at 16:29.



  5. #65
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    The negative half cycle is not controlling
    Don't use 220V for Vsin rather use 50V as earlier.
    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.


    1 members found this post helpful.

  6. #66
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Yes, you are right. 220V was the problem in Proteus. Works fine with 50V VSINE. Here is new code.


    Edit: Eagle PCB files attached for three buttons dimmer.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    
    unsigned char milliSec = 0, i = 0;
     
    //Timer0
    //Prescaler 1:4; TMR0 Preload = 6; Actual Interrupt Time : 1 ms
     
    //Place/Copy this part in declaration section
    void InitTimer0() {
        OPTION_REG = 0x81;
        TMR0 = 6;
        INTCON |= 0x20;
    }
     
    void interrupt() {
     
         if(INTF_bit) {          //ZC occurs once every 10 ms
            INTF_bit = 0;
            i = 0;
            if(milliSec == 0) {
                 GP5_bit = 1;
                 Delay_us(50);    //INTF occurs once every 10 ms. So, it is safe to use 50 us delay
                 GP5_bit = 0;
            }
            else InitTimer0();
         }
         
         if(T0IF_bit) {        //Timer interrupt occurs every 1 ms
            T0IF_bit = 0;
            TMR0 = 6;
            //Enter your code here
            if(i++ == milliSec) {
                  GP5_bit = 1;
                  T0IE_bit = 0;
                  Delay_us(80);  // 50 us delay in a 1 ms timer interrupt is not a problem
                  GP5_bit = 0;
            }
        }
    }
     
    void initialize() {
         INTEDG_bit = 0;
         INTF_bit = 0;
         INTE_bit = 1;
         PEIE_bit = 1;
         GIE_bit = ~GIE_bit;
         //milliSec = EEPROM_Read(0);              //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware
         //Delay_ms(20);
    }
     
    void main() {
     
         ANSEL = 0x00;
         CMCON0 = 0x07;
         TRISIO = 0x07;
         GPIO = 0x00;
         IOC = 0x00;
         
         while (1) {
     
                if(GP0_bit) {
                    Delay_ms(50);
                    while(GP0_bit);
                    if(milliSec < 9)++milliSec;
                    //EEPROM_Write(0, milliSec);     //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware
                    //Delay_ms(20);
                }
                else if(GP1_bit) {
                    Delay_ms(50);
                    while(GP1_bit);
                    if(milliSec > 0)--milliSec;
                    //EEPROM_Write(0, milliSec);     //There is no option to load eeprom file in Proteus for 12F683, So, uncomment this code while testing in hardware
                    //Delay_ms(20);
                }
                
                else if(GP3_bit) {
                    Delay_ms(50);
                    while(GP3_bit);
                    initialize();
                }
         }
    }

    - - - Updated - - -

    Edit : Final PCB layout files for POT Dimmer and Three buttons Dimmer attached.

    Sunrom 16 bit Dimmer module reverse engineered. Code + Simulation attached.
    Last edited by milan.rajik; 28th February 2015 at 17:19.



  7. #67
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    Making it with less and cheap parts to reduce cost if mains isolation is not required.

    Software need to be modified to work on rising edge and falling edge to detect zero crossing.
    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.


    1 members found this post helpful.

  8. #68
    Advanced Member level 4
    Points: 8,209, Level: 21
    Achievements:
    7 years registered
    paulfjujo's Avatar
    Join Date
    Jun 2008
    Location
    France 01120
    Posts
    1,324
    Helped
    269 / 269
    Points
    8,209
    Level
    21

    Re: Why this is not working ?

    yes, it is simpler , but you don't control the 2 alternances.



  9. #69
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    you don't control the 2 alternances
    Now with modified code,

    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.



  10. #70
    Advanced Member level 4
    Points: 8,209, Level: 21
    Achievements:
    7 years registered
    paulfjujo's Avatar
    Join Date
    Jun 2008
    Location
    France 01120
    Posts
    1,324
    Helped
    269 / 269
    Points
    8,209
    Level
    21

    Re: Why this is not working ?

    is your power supply (for the PIC) made from AC source ?
    like trouh a Capacitor reactance ( 0,1µF?) + Rprotect +diode + Capacitor +voltage regulator ?
    or by battery + voltage regulator

    or simulation only ?



  11. #71
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    It is simulation only but 5V can be generated like this

    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.



  12. #72
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    @ALERTLINKS

    Post the code if possible for POT dimmer. When POT value is min, load should be OFF and when max, full power should be provided to it.

    - - - Updated - - -

    @ALERTLINKS

    Did you write code in assembly language ?

    I have attached new versions of codes for

    Three button dimmer
    Pot dimmer
    sunrom 16 bit dimmer (I don't know which 8 pin PIC sunrom dimmer uses. I have used 12F683)

    But still in three button dimmer there is a slight varying of firing pulse after every ZC. Why ? Every time the same ISR has to execute and so same time has to be taken to fire TRIAC.

    - - - Updated - - -

    Edit: See attached microchip application note image. They have used 12C508. Can I connect 20 Meg reisistor to INT pin of other PIC MCus and feed 120V to resistor ? Does all PICs pins have those to ESD protection diodes for the internal MOSFETs ?

    I am planning to get 5V for PIC12F683 from transformerless power supply and feed 240V AC to INT pin through a 40 Meg resistor and drive the gate of Triac directly from PIC pin.

    - - - Updated - - -

    Edit 2:

    Nobody is answereing. Here is my low cost dimmer based on PIC12F683. In actual hardware there will be no 1N4148 or I can add it also but there will be a resistor between GP5 and Gate. I have a question related to Proteus simulation. Why gate signal is strange ? It is similar to triac signal. If I disconnect GP5 from gate and check the signal then signal is ok.
    Last edited by milan.rajik; 1st March 2015 at 18:56.



  13. #73
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Four Channel Dimmer using PIC18F45K22. 8 MHz clock is used. Proteus 8.1 SP1 simulation files attached. Use the 2 channel dimmer simulation file. Proteus just can't simulate 4 channel dimmer atleast on my system. I am sure the dimmer will work on hardware.

    Press the ON/OFFx button of a channel. Initial value on pressing ON/OFF button is 0 power. Use INCx or DECx button to increment or decrement the power.

    - - - Updated - - -

    I tested only the firing pulse for 4 channels and they work fine. It was just Proteus simulation problem. It just can't simulate 4 analog signals at the same time. The buttons work fine. I will add eeprom code to hold the milliSec value in memory.

    - - - Updated - - -

    @paulfjujo

    See if you can use this transformerless power supply. It is rated for 30V 1A. Additionally you can add a 7812, 7809 or 7805 to get voltages for PIC and relays.

    http://www.electroschematics.com/549...-power-supply/



  14. #74
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    I use flowcode for programing. I have generated train of pulses for trigger. It helps better firing the triac.I have used 10bit ADC and it is translated into nearly 1000 steps. I think I shall develop it into three stage battery charger using iron core transformer.
    By the way, the 16bit dimmer, it is not 16bit but 4bit and 16 steps.
    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  15. #75
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Yes, you are right. It is 4 bit dimmer and 16 steps. Please post the flowcode file. I need a flicker free firing of triac.


    @ALERTLINKS

    Please provide flowcode file or C code for 256 step dimmer.

    - - - Updated - - -

    Edit 2:

    Somebody has done similar to me.

    https://arduinodiy.wordpress.com/201...immer-arduino/
    http://forum.arduino.cc/index.php?topic=6970.70;wap2
    http://doityourselfchristmas.com/for...hp/t-6358.html
    Last edited by milan.rajik; 2nd March 2015 at 06:05.



  16. #76
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    This is good only to simulate and prove the concept. Actually I have used c code in it that's why it does not simulate in flowcode. Without comments, it will be difficult to understand. I personally prefer to write my own rather than trying to understand someone else's code that what is happening.
    To make it a real hardware further considerations are needed. For example what happens when mains frequency changes.
    It will work worst than a regular passive dimmer when there is a spike on its input. As it is interrupt driven, it will suddenly respond to it and the whole timing will be disturbed.
    A remedy to it would be to allow interrupt through a window from 9mS-11mS.
    First confirm valid synch to mains frequency for 2=3 cycles and only then apply the PWM. Mains frequency may change a few cycle above or below. Calculations are based on 50Hz. At low level setting this can play a havoc. A more sophisticated system would be to determine mains frequency and then calculate the required timings for PWM.
    There should also be remedy against false triggering because it may damage if full voltages are applied to certain systems. Anyway it depends on application.

    - - - Updated - - -

    C and hex file with better timings.
    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.


    1 members found this post helpful.

  17. #77
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Yes, I thought about mains frequency drifting. I have to think about how to handle that. Here I am attaching code for sunrom 256 step dimmer. Test and tell me if the working is fine.

    See image 1. It is the simulation of your pot dimmer. Why the signal is like that. It is as if triac is conducting from 90 degress to 180 degrees and then instead of conducting from 270 degrees to 360 degrees it appears as if it is conducting from 360 degrees to 270 degrees. Why ? Did you do that intentionally ?

    Are you firing triac 5 ms after ZC ?


    Also see my 256 step dimmer image. It shows triac conducting from some 90 degrees to 180 degrees and then from 270 degrees to 360 degrees.
    Last edited by milan.rajik; 2nd March 2015 at 09:02.



  18. #78
    Advanced Member level 4
    Points: 10,130, Level: 24
    ALERTLINKS's Avatar
    Join Date
    Dec 2003
    Location
    Pakistan
    Posts
    1,259
    Helped
    398 / 398
    Points
    10,130
    Level
    24

    Re: Why this is not working ?

    I think it is working good except it does not restart when all inputs are once set to zero if it is not intentionally made it it so.
    It can withstand hi-voltages from triac's-gate only in simulation.
    About my circuit, I have connected bulb on upper side and taking sample from there, so the voltages on scope are reversed.
    I know. I know. And once more - I don't know.
    I am too old and would not have enough knowledge to judge, and only have made some remarks in order not to be called ignorant.


    1 members found this post helpful.

  19. #79
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    Yes, when extreme values 0x00 and 0xFF are reached then it is not functioning. I have to fix it. If you start the simulation with any value other than 0x00 and 0xFF then it works fine.



  20. #80
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Why this is not working ?

    How should I handle drifting mains frequency in code ? Should I create a lookup table for Timer0 preload values for different frequencies or should I calculate frequency of AC mains and calculate timer0 preload value and use it ?



--[[ ]]--