AC Dimmer + lpc1114

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AC Dimmer + lpc1114

1,737 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sun Sep 01 18:26:15 MST 2013
Dear,

I'm trying to use the lpcxpresso 1114 to make an simple AC dimmer (in future I want to control it with CAN), basic I have an zero cross circuit connected to an interruption, this interruption will wait some time (to achieve the desired phase angle) and active an triac for certain amount of time, usually one pulse with few microseconds, my code for test is very simple, I'm trying to use the 32 bit timer to obtain the microsecond delay, but the ac load (in this case a light bulb), only blinks without fade effect, some one can share experiences whit this kind of circuit?


void PIOINT2_IRQHandler(void)
{
  uint32_t regVal;
  regVal = GPIOIntStatus( PORT2, 1 );
  if ( regVal )
  {
GPIOIntClear( PORT2, 1 );
  }

    delay32Ms(5000); // time to achieve the angle // 180º = 8333 microseconds // 60 hz
    GPIOSetValue( TRIAC_PORT, TRIAC_BIT, 1 ); 
    delay32Ms(10); // hit the triac for 10 microseconds
    GPIOSetValue( TRIAC_PORT, TRIAC_BIT,  0); 

  return;
}

Regards,
HCanova 
0 Kudos
Reply
5 Replies

1,704 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Mon Sep 02 17:49:20 MST 2013
Hi,

this is my timer code,
 LPC_SYSCON->SYSAHBCLKCTRL |=  0x00000400;


void delay32Ms( uint32_t delayInMs)
{

uint32_t test;

    LPC_TMR32B1->TCR = 0x02;/* reset timer */
    LPC_TMR32B1->PR  = 0x00;/* set prescaler to zero */

 

    LPC_TMR32B1->MR0 = delayInMs * ((SystemCoreClock/LPC_SYSCON->SYSAHBCLKDIV) / 1000000); 


    LPC_TMR32B1->IR  = 0xff;/* reset all interrrupts */
    LPC_TMR32B1->MCR = 0x04;/* stop timer on match */

    LPC_TMR32B1->TCR = 0x01;/* start timer */
  
    /* wait until delay time has elapsed */

    while (LPC_TMR32B1->TCR & 0x01);


  return;
}



I'will try to scope the output, but I need to find (or buy) one oscilloscope

thanks
0 Kudos
Reply

1,704 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Mon Sep 02 05:20:23 MST 2013
And you have enabled SYSAHBCLKCTRL?
Please scope the clkout pin of your controller to see if the internal timings are correct.
For clkout pin configuration read sections 3.5.21, 3.5.22 en 3.5.23 of user manual 10398
0 Kudos
Reply

1,704 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Mon Sep 02 04:32:23 MST 2013
Sorry

I modified the function to obtain microsecond delay, but didn't changed the name, basic the MR0 of the timer is sysclock/1000000.
in this case 48000000/1000000 * delay

thanks
0 Kudos
Reply

1,704 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Mon Sep 02 04:30:19 MST 2013

Quote: serge
Is delay32Ms(xx) milliseconds or microseconds?
And are you sure?




Sorry, I modified the function to obtain microseconds delay, but I didn't changed the name, basic the MR0 of the timer is sysclock/1000000 (48000000/1000000)

Thanks
0 Kudos
Reply

1,704 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Mon Sep 02 04:20:28 MST 2013
Is delay32Ms(xx) milliseconds or microseconds?
And are you sure?
0 Kudos
Reply