This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530 PWM Definitions Part4

Other Parts Discussed in Thread: CC2530

Hi Guys,

I already had success to configuring my dimmer device, as I posted before in PWM Definitions Part 1, 2 and 3.

I included electronics components to do the LED Light Driver, but during the test I observed that the light LED lamp flicking bellow 75%. I suspect that it occurring because the Timer settings, specially Freq/Period (halTimer1SetPeriod (4292); // 233Hz) defined to Timer 1. 

Somebody had an experience like that to advise how to fix it?

Someone has some article to help me understand this better?


to help me understand this better?

Bellow You can see timer 1 settings in timer.c file:

void HalTimer1Init (halTimerCBack_t cBack)
{
T1CCTL0 = 0; /* Make sure interrupts are disabled */
T1CCTL1 = 0; /* Make sure interrupts are disabled */
T1CCTL2 = 0; /* Make sure interrupts are disabled */
T1CCTL3 = 0; /* Make sure interrupts are disabled */
T1CCTL4 = 0; /* Make sure interrupts are disabled */

/* Setup prescale & clock for timer0 */
halTimerRecord[HW_TIMER_1].prescale = HAL_TIMER1_16_PRESCALE;
halTimerRecord[HW_TIMER_1].clock = HAL_TIMER_32MHZ;
halTimerRecord[HW_TIMER_1].prescaleVal = HAL_TIMER1_16_PRESCALE_VAL;

/* Setup Timer1 Channel structure */
halTimer1Channel[0].TxCCTL = TCHN_T1CCTL;
halTimer1Channel[0].TxCCL = TCHN_T1CCL;
halTimer1Channel[0].TxCCH = TCHN_T1CCH;

halTimerRecord[HW_TIMER_1].configured = TRUE;
halTimerRecord[HW_TIMER_1].opMode = HAL_TIMER1_OPMODE_UPDOWN;
halTimerRecord[HW_TIMER_1].channel = 0;
halTimerRecord[HW_TIMER_1].channelMode = 0;
halTimerRecord[HW_TIMER_1].intEnable = FALSE;
halTimerRecord[HW_TIMER_1].callBackFunc = cBack;
Timer1MaxCount = halTimer1SetPeriod (4292); // 233Hz

halTimerSetPrescale (HW_TIMER_1, halTimerRecord[HW_TIMER_1].prescale);
halTimerSetChannelMode (HW_TIMER_1, halTimerRecord[HW_TIMER_1].channelMode);
halTimer1SetChannelCCTL(HAL_T1_CH0, 0, 1, HAL_TIMER1_CH0_CMP_MODE_SET_ON_COMP, 1, HAL_TIMER1_CH_CAP_MODE_NO);
halTimer1SetChannelCCTL(HAL_T1_CH1, 0, 1, HAL_TIMER1_CHn_CMP_MODE_CLR_ON_COMP_SET_ON_0, 1, HAL_TIMER1_CH_CAP_MODE_NO);
halTimer1SetChannelCCTL(HAL_T1_CH2, 0, 1, HAL_TIMER1_CHn_CMP_MODE_CLR_ON_COMP_SET_ON_0, 1, HAL_TIMER1_CH_CAP_MODE_NO);
halTimer1SetChannelCCTL(HAL_T1_CH3, 0, 1, HAL_TIMER1_CHn_CMP_MODE_CLR_ON_COMP_SET_ON_0, 1, HAL_TIMER1_CH_CAP_MODE_NO);
halTimer1SetChannelCCTL(HAL_T1_CH4, 0, 1, HAL_TIMER1_CHn_CMP_MODE_CLR_ON_COMP_SET_ON_0, 1, HAL_TIMER1_CH_CAP_MODE_NO);

halTimer1SetChannelDuty (HAL_T1_CH1, 0);
halTimer1SetChannelDuty (HAL_T1_CH2, 0);
halTimer1SetChannelDuty (HAL_T1_CH3, 0);
halTimer1SetChannelDuty (HAL_T1_CH4, 0);


/* set timer 1 operating mode */
T1CTL &= ~(HAL_TIMER1_OPMODE_BITS);
T1CTL |= HAL_TIMER1_OPMODE_UPDOWN;

BR

Alex

  • Hi Guys,

    I´ve found some discussions on internet and I believe that this behavior is related to timing or synchronism between PWM signal (square wave) and Load electrical wave, I have seen two possibilities that can generate this behavior Zero-Cross or Phase-Angle. 

    I believe that I need to change some parameters in timer.c maybe PWM time period, percentage duty cycle and others.

    Somebody had a similar problem?

    BR

    Alex

  • Hi Alex,

    You are more than welcome to alter the PWM frequency and observe the changes, however being an application-specific issue this question is not well suited for this forum as it does not directly involve a problem with the MCU or mesh networking.

    Regards,
    Ryan
  • I don't see similar trouble in our design but as Ryan replied, it's welcome to alter the PWM frequency and observe the changes.
  • Hi Ryan, thanks a lot for your assistance.

    I have doubts if I need to change also prescale & clock for timer 1.

    Do you have any article or AN to help me with this decision?

    BR
    Alex
  • Thanks Mr YK. I´ll make experience changing the frequency.
    But I think that I need to include an additional circuit to detect Zero Crossing to synchronize timer.

    I´ll let you know!
    BR
    Alex
  • Hi Mr YK and Ryan,

    I understand the phenomena that explain better why the LED light is flickering. They can see waves form bellow:

    The PWM Signal (square wave), used to trigger the TRIAC, needs to establish a synchronism/timing with senoidal electrical wave. To do it, I built an external circuit (zero crossing detector) to connect, an I/O port, trough on CC2530.  The Zero Crossing detector change the output port to LEVEL UP (3.3V) when Electrical wave goes through to zero.

    I thing that to inspect the CC2530 input port including a conditional functions (if then or else) , connected through Zero Crossing detector, and through his port stop timer to permit timing between waves.

    I´ll use the inspection at this code point:

    void halTimer1SetChannelDuty (uint8 channel, uint16 promill)

    {
    #define MIN_PROMILL 20
    uint16 count;

    if (promill < MIN_PROMILL)
    promill = 0;

    /* Load count = ((sec/tick) x clock) / prescale */
    count = (uint16)( ((uint32)(Timer1MaxCount) * promill + 500)/ 1000 );
    count = ( (count >= Timer1MaxCount) ? Timer1MaxCount-1 : (count == 0 ? 1 : count) );

    halTimer1SetChannelCount(channel, count)

    Do you think it is right way to implement zero crossing detection? or better to use interruptions?

    BR

    Alex

  • If you need to synchronize/timing with sine electrical wave, I think CC2530 is not that resourceful or powerful enough for doing this and Zigbee RF thing together. I would suggest you to use another MCU to do this.

  • Mr YK, Thanks a lot!!!!

    I suspected that the CC2530 had not powerful to do it.

    I will work on two fronts, 1st to implement via UART communication with an external module already ready and that makes it from a partner of mine and 2st to study the MCU TI MSP430 with a medium-term alternative mine.

    But in the 1st option I need to design by my side (CC2530) an serial protocol, via UART, to communicate with external module. 
    If I need help to do it, please, can you help me?

    BR

    Alex

  • Mr YK,
    Thank you for the help that has always been given to me!!!!
    BR
    Alex