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.

how to synchronize three PWM



Hello

I'm trying to set up three PWM generators together synchronization of, but did not see any signal on the oscilloscope. What am I doing wrong?

I have Tiva c series TM4C123G LaunchPad Evaluation kit.

 

 

 

Here is my code:

   

    //Enable GPIO and PWM0

   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

   SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

   //PWM0 PB6,7 GEN0

   GPIOPinConfigure(GPIO_PB7_M0PWM1);

   GPIOPinConfigure(GPIO_PB6_M0PWM0);

   //PWM0 PB4,5 GEN1

   GPIOPinConfigure(GPIO_PB4_M0PWM2);

   GPIOPinConfigure(GPIO_PB5_M0PWM3);

   //PWM0 PE4,5 GEN2

   GPIOPinConfigure(GPIO_PE4_M0PWM4);

   GPIOPinConfigure(GPIO_PE5_M0PWM5);

   //GPIO as PWM

   GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

   GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);

   GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_4);

   GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_5);   

    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_4);

   GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5);

    //PWM0_GEN0

   PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_SYNC);

   PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, max);

   PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, max*0.25);

   PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT |PWM_OUT_1_BIT , true);

   PWMGenEnable(PWM0_BASE, PWM_GEN_0);

   //PWM0_GEN1

  PWMGenConfigure(PWM0_BASE, PWM_GEN_1,( PWM_GEN_MODE_DOWN | PWM_GEN_MODE_SYNC));

  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, max);

  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, (max*0.5));

  PWMOutputState(PWM0_BASE, PWM_OUT_2_BIT |PWM_OUT_3_BIT , true);

  PWMGenEnable(PWM0_BASE, PWM_GEN_1);

   //PWM0_GEN2

  PWMGenConfigure(PWM0_BASE, PWM_GEN_2,( PWM_GEN_MODE_DOWN | PWM_GEN_MODE_SYNC));

  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, max);

  PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, (max*0.75));

  PWMOutputState(PWM0_BASE, PWM_OUT_4_BIT |PWM_OUT_5_BIT , true);

  PWMGenEnable(PWM0_BASE, PWM_GEN_2); 

  //Sync all three: GEN0,1,2 ?

  PWMSyncTimeBase(PWM0_BASE, (PWM_GEN_0_BIT | PWM_GEN_1_BIT | PWM_GEN_2_BIT));

  PWMSyncUpdate(PWM0_BASE, (PWM_GEN_0_BIT | PWM_GEN_1_BIT | PWM_GEN_2_BIT));   

  //Enable interrupt and dead band

  PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0 | PWM_INT_GEN_1  | PWM_INT_GEN_2);

  IntEnable(INT_PWM0_0 | INT_PWM0_1| INT_PWM0_2);

  PWMGenIntTrigEnable(PWM0_BASE,( PWM_GEN_0 | PWM_GEN_1 | PWM_GEN_2), PWM_INT_CNT_ZERO);

  PWMDeadBandEnable(PWM0_BASE, (PWM_GEN_0 | PWM_GEN_1 | PWM_GEN_2), 100, 100);

 

 

What is difference between these parameters ?

PWM_GEN_MODE_SYNC , PWM_GEN_MODE_GEN_SYNC_LOCAL, PWM_GEN_MODE_GEN_SYNC_GLOBAL

 

Chose I correct parameter (PWM_GEN_MODE_SYNC) to PWMGenConfigure?

Thanks for your advice.

  • pavel T���borsk��� said:
    did not see any signal on the oscilloscope.

    That's never good - nor fun.  Rather than provide a cookbook - list here short/sweet means to bring PWM Generator 0 to life.  (one hopes)  With success - this can systematically be modeled - generalized to your 3 Generator goal.

    a) Have you properly set your System Clock - via: SysCtlClockSet() ?  note: not the same as (b) below.

    b) May not be required - but just in case - SysCtlPWMClockSet(SYSCTL_PWMDIV_1);  // full speed PWM

    c) SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); // your code used here

    d) SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);  // again, your code

    e) GPIOPinConfigure(GPIO_PB6_M0PWM0);  //  note - one pin per pinconfig

    f) GPIOPinConfigure(GPIO_PB7_M0PWM1);

    g) GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6 | GPIO_PIN_7);  // note any/all pins per pintype

    h)  PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);  // your code - but for NO_SYNC for now...

    i)  PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, max); // prefer "max" change to 30000 for test

    j) PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, max*0.25);  // prefer 15000 for 50% duty cycle

    k) PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, max*0.25);  // prefer 15000 for 50% duty cycle

    l) PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT , true);  // your code

    m)  PWMGenEnable(PWM0_BASE, PWM_GEN_0);  // your code

    n) while(1)   {}

    Suggest that you avoid the complications introduced by interrupts @ this early stage.  Above code listing should set-up PB6/PB7 as PWM Gen 0 - and cause each channel to output @ 50% duty cycle.

    Always fear holding code "hostage" by your (unstated) use of "max."  Suggest "hard values" so results are xtal clear.  Have also killed any/all attempts to Sync - this early stage.  (later will add)

    If you alter code to that shown here - report/confirm PWM outputs - I'll go further into your Sync issues - but always find KISS best - let's get the basics working & "proceed by refinement."

     

  • Thanks for the advice.

    This code works. I see signal on the oscilloscope (PB6, PB7- invert) with dead time

    duty cycle is 50%

    unsigned int max=3000;

    unsigned int pulse=1500;

    void PWM0_IntHandler(void) //  here  change duty cycle.

    {

     PWMGenIntClear(PWM0_BASE,PWM_GEN_0,PWM_INT_CNT_ZERO);

      // here change  pulse value for GEN_0 

      PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,pulse);  

    }

    int main(void)

    {
    SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);      

    GPIOPinConfigure(GPIO_PB6_M0PWM0);

    GPIOPinConfigure(GPIO_PB7_M0PWM1);   

    GPIOPinTypePWM(GPIO_PORTB_BASE,(GPIO_PIN_6 | GPIO_PIN_7)); 
    PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_DOWN| PWM_GEN_MODE_NO_SYNC));
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, max);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0);

    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT |PWM_OUT_1_BIT , true);

    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    PWMDeadBandEnable(PWM0_BASE, (PWM_GEN_0), 10, 10);

    PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0 );

    IntEnable(INT_PWM0_0);

    PWMGenIntTrigEnable(PWM0_BASE,( PWM_GEN_0 ), PWM_INT_CNT_ZERO);

    while (1)

      {

     //here  change max (frequency) value for GEN_0 

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, max);

       }

    }

     

    Now try me to get the signal to Gen1 (PB4, PB5-invert) GEN2 (PE 4,PE 5-invert) Total 6 outputs. I need to synchronize the time base for all three (GEN0, GEN1, GEN2). With one PWM period will interrupt. The interrupt will change the value in the function PWMPulseWidthSet () for each GEN0, GEN1, GEN2.

     

    What is the next step make it work?

     

     

  • Glad you followed code advice supplied - not yet sure if your additions are correct and/or in proper order. 

    Always best to "model" that which worked previously.   So - suggest that you follow previous posting - but this time targeting PWM Generators 1 & 2. 

    Still ask - at this early stage - that you avoid any attempt to Sync - again lets establish that the "basics" first work - then proceed further.  (trust that you will find such a systematic approach will pay-off - in the long run) 

    In summary - that added code includes:

    SysCtlPeripheralEnable() (when/where new GPIO Port is added), GPIOPinConfigure(), GPIOPinTypePWM(), PWMGenConfigure() (again w/ NO_SYNC - for now), PWMGenPeriodSet(), and PWMPulseWidthSet() - but in each case targeting those pins serving as PWM Generator 1 & PWM Generator 2.  Code should exactly model that supplied to you earlier - only with names/labels changed as appropriate for each PWM Gen.

    and then,  (note the much broader param. 2 - not the dual parameter usage - your 1st post)

    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT,   true);

    followed by: PWMGenEnable() - called 3 times - once for each PWM Gen.

    This then - should cause all 3 PWM Generators to run - although not yet in Sync.  (that for later)

    Upon your confirmation of this 6 PWM Output success - we'll move toward the Sync...

  • Thank you very much, finally working six outputs.

      

    Code:

     

    int main(void) {

     

    SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

     

    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);  

     

    GPIOPinConfigure(GPIO_PB6_M0PWM0);

    GPIOPinConfigure(GPIO_PB7_M0PWM1);

    GPIOPinConfigure(GPIO_PB4_M0PWM2);

    GPIOPinConfigure(GPIO_PB5_M0PWM3);

    GPIOPinConfigure(GPIO_PE4_M0PWM4);

    GPIOPinConfigure(GPIO_PE5_M0PWM5);   

     

    GPIOPinTypePWM(GPIO_PORTB_BASE,(GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |GPIO_PIN_7));

    GPIOPinTypePWM(GPIO_PORTE_BASE, (GPIO_PIN_4 | GPIO_PIN_5));

     

    PWMGenConfigure(PWM0_BASE, PWM_GEN_0, (PWM_GEN_MODE_DOWN| PWM_GEN_MODE_NO_SYNC));

    PWMGenConfigure(PWM0_BASE, PWM_GEN_1, (PWM_GEN_MODE_DOWN| PWM_GEN_MODE_NO_SYNC));

    PWMGenConfigure(PWM0_BASE, PWM_GEN_2, (PWM_GEN_MODE_DOWN| PWM_GEN_MODE_NO_SYNC));

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 3000);

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 3000),

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 3000),

     

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 1500);     //duty cycle is 50%.    or add PWM_OUT_1 ?

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 1000);     //duty cycle is 33%.    or add PWM_OUT_3 ?

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, 500);       //duty cycle is 16%.    or add PWM_OUT_5 ?

     

    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT,   true);

     

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 10, 10);// here  enable too PWM_OUT_1 -invert  ?

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_1, 10, 10); // here enable too  PWM_OUT_3 -invert ?

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_2, 10, 10);// here enable too  PWM_OUT_5 -invert  ?

     //value of 10 means that Deadband is (1/40)*10 us?  I have PWMclock - 40Mhz

     

    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    PWMGenEnable(PWM0_BASE, PWM_GEN_1);

    PWMGenEnable(PWM0_BASE, PWM_GEN_2);

     

    while(1)

    {}

    }

    Would like to move toward the Sync.

     

  • Hi 

    Can you please help me on how to synchronize the three generators? I have used following code to synchronize the generators. Still i'm not able to see the good result.

    PWMSyncTimeBase(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    PWMSyncUpdate(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

     I'm using generator 0,2 and 3.

    Regards,

    Dilgush

  • Dilgush Idikkula said:
    i'm not able to see the good result.

    While more original than (famed) "Does not Work!" your writing fails to overwhelm w/care, detail, precision.

    Who determines, "good result" and by what method did you test/verify your conclusion?

    Two function calls you provide are unlikely to enable comprehensive diagnosis.   That said - bombardment here w/other than "just the PWM set-up facts" tends to blind your helper staff to your real issue.

    Adequate, focused detail - as always - may assist us in achieving, "good result..."

  • Hello Dilgush,

    How have you configured the PWM Generators will affect the Synchronization feature. Have you correctly passed the parameter for Sync Enable during configuration via the API PWMGenConfigure?

    Regards
    Amit
  • Hi Amit,

    Here is the configuration which i have done.

    void InitPWM(void)
    {
    SYSCTL_RCGC0_R=SYSCTL_RCGC0_PWM0;


    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    GPIOPinConfigure(GPIO_PB6_M0PWM0);

    GPIOPinConfigure(GPIO_PB7_M0PWM1);

    GPIOPinConfigure(GPIO_PE4_M0PWM4);

    GPIOPinConfigure(GPIO_PE5_M0PWM5);

    GPIOPinConfigure(GPIO_PC4_M0PWM6);

    GPIOPinConfigure(GPIO_PC5_M0PWM7);

    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);

    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_4);

    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5);

    GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_4);

    GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_5);

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 833); //for 48kHz PWM

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 833); //PWM Module base address/pwm generator/pwm period

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, 833);


    PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);

    PWMGenIntTrigEnable(PWM0_BASE,PWM_GEN_0,PWM_TR_CNT_ZERO); //Enable the trigger for the PWM0 for the ADC0 trigger

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,400);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4,500);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6,600);

    PWMSyncTimeBase(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    PWMSyncUpdate(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 0, 0); // Dead band on rising and falling edges

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_2, 0, 0);

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_3, 0, 0);

    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT |PWM_OUT_1_BIT |PWM_OUT_4_BIT |PWM_OUT_5_BIT |PWM_OUT_6_BIT | PWM_OUT_7_BIT, true);

    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    PWMGenEnable(PWM0_BASE, PWM_GEN_2);

    PWMGenEnable(PWM0_BASE, PWM_GEN_3);
    }

    I'm getting phase shifted PWM signals. what i need is all three pairs to be synchronized, so that i can use the PWMs for space vetor modulation.

  • Hello Dilgush

    Then why is the Generator being configured with PWM_GEN_MODE_NO_SYNC parameter?

    Regards
    Amit
  • Thanks Amit... posting here late.
    I have got the working six synchronized pulses for SVPWM by synchronising after enabling the all three generators. This made the pulses to be center aligned.
    void InitPWM(void)
    {
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    GPIOPinConfigure(GPIO_PB6_M0PWM0);

    GPIOPinConfigure(GPIO_PB7_M0PWM1);

    GPIOPinConfigure(GPIO_PE4_M0PWM4);

    GPIOPinConfigure(GPIO_PE5_M0PWM5);

    GPIOPinConfigure(GPIO_PC4_M0PWM6);

    GPIOPinConfigure(GPIO_PC5_M0PWM7);

    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);

    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_4);

    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5);

    GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_4);

    GPIOPinTypePWM(GPIO_PORTC_BASE, GPIO_PIN_5);

    PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN |
    PWM_GEN_MODE_NO_SYNC);

    PWMSyncTimeBase(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    PWMSyncUpdate(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 1666); // for 48kHz PMW.

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 1666);

    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, 1666);



    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0,1600);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4,500);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6,700);

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 16, 16); // Dead band on rising and falling edges 200nSecs

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_2, 16, 16);

    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_3, 16, 16);

    PWMGenIntTrigEnable(PWM0_BASE,PWM_GEN_0,PWM_TR_CNT_ZERO);

    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT|PWM_OUT_4_BIT|PWM_OUT_5_BIT|PWM_OUT_6_BIT|PWM_OUT_7_BIT, false);

    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    PWMGenEnable(PWM0_BASE, PWM_GEN_2);

    PWMGenEnable(PWM0_BASE, PWM_GEN_3);

    PWMSyncTimeBase(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT); //this made all three PWM to be synced. After enabling the all three PWMs.

    PWMSyncUpdate(PWM0_BASE,PWM_GEN_0_BIT|PWM_GEN_2_BIT|PWM_GEN_3_BIT);

    }

    Regards

    Dilgush
  • Hello Dilgush,

    Thanks for bringing back the code to the forum.

    Regards
    Amit