This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with ac dimmer circuit with nRF51822

hi,

i tried to make a ac dimmer circuit controlled with dc

i use nrf51822

this is my dimmer circuit

image description

aaand this one is zero crossing detector

image description

finally this is my mbed code;

DigitalOut trigger(p15);

DigitalIn zero(p14);

int main()

{

    while(1)  

    {

        if (zero==1) 

        {

            wait_us (5000);  
                
            trigger = 1;      
             
            wait_us (100);  

            trigger = 0;     

        } 

    }

}

i just want to dim my light %50, but it always blinking.

can anyone help me and tell me what is my mistake?

Parents
  • First of all, the h11aa1 symbol does not seem to be correct. h11aa1 is an AC optocoupler, as can be seen from a quick search on google.

    Second; you have connected the base of the phototransistor, this should in most cases be left open. You should connect the collector (pin 5) to the microcontroller (as can be seen in the google search). With your configuration the zero pin on nRF (p14) is always high, which means that the code will trigger the triac approximately every 5ms.

  • You should also use GPIOTE, TIMER and PPI instead of doing wait_us and polling pin in main. When using code that run asynchronously, like the SoftDevice, this code will not work because interrupts can happen during the wait_us and the timing will be wrong. With GPIOTE, PPI and TIMER the triggering of the triac can happen automatically without using the CPU.

Reply
  • You should also use GPIOTE, TIMER and PPI instead of doing wait_us and polling pin in main. When using code that run asynchronously, like the SoftDevice, this code will not work because interrupts can happen during the wait_us and the timing will be wrong. With GPIOTE, PPI and TIMER the triggering of the triac can happen automatically without using the CPU.

Children
No Data
Related