KV11 Combine PWM mode TRIAC control?

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

KV11 Combine PWM mode TRIAC control?

970 Views
azematalam
Contributor I

I am using FTM combine mode to generate some sort of pulses that will be sent to triac. (FTM0 channel 0 and 1)

I want to connect the zero cross signal to FTM hardware trigger pin (PTB3). Can I achieve  FTM register reloading on every zero cross detection by using hardware synchronization?

For combine mode signal generation I used FRDMkv1 ftm_combine_pwm example with little modification. Also tried to setup hardware synchronization using PTB3 but that seems to not reacting at all. When comparing signal that should simulate zero cross detection and firing angle signal (that I am creating using combined mode), firing angle signal is "moving". Frequency doesn't seem that is changing, but pulse time, and angle of pulse change.

I want to have ON period of this signal that will control triac always with almost the same difference from zero cross detection. Is combine pwm mode with hardware synchronization way to achieve this?

Is there example code of FTM hardware synchronization?

Thanks.

0 Kudos
5 Replies

680 Views
azematalam
Contributor I

Hi Felipe Garcia, 

thanks for the document.  I tried changing some parts of the code, but the code still doesn't work. Regarding the init for CMP0_OUT, do I need to do anything else to initialize PTC5 as CMP0_OUT?

PORT_SetPinMux(PORTC, 5U, kPORT_MuxAlt6);

SIM->SOPT4 = ((SIM->SOPT4 &
/* Mask bits to zero which are setting */
(~(SIM_SOPT4_FTM0TRG2SRC_MASK)))

/* FlexTimer 0 Hardware Trigger 2 Source Select: CMP0 output drives FTM0 hardware trigger 2. */
| SIM_SOPT4_FTM0TRG2SRC(0x00u));

Regarding FTM counter synchronization my expectation is that on every trigger counter will reset, and my pulse is always the same distance from zero crossing pulse.

No matter what I try my signals stays pretty much the same.

0 Kudos

680 Views
azematalam
Contributor I
It took me little time to figure out that I need to connect zero cross detection to the analog comparator, and to initialize compare the output to be hardware synchronization trigger. Now it seems that is working.
PORT_SetPinMux(PORTC, 5U, kPORT_MuxAlt6);
PORT_SetPinMux(PORTC, 6U, kPORT_PinDisabledOrAnalog);

SIM->SOPT4 = ((SIM->SOPT4 &

(~(SIM_SOPT4_FTM2TRG2SRC_MASK)))

| SIM_SOPT4_FTM2TRG2SRC(0x00u));

SIM->SCGC4 |= SIM_SCGC4_CMP(1);
CMP0->CR1 = 0;
CMP0->CR0 = 0;
CMP0->CR1 = CMP_CR1_PMODE_MASK | CMP_CR1_EN_MASK;
CMP0->FPR = 0;
CMP0->DACCR = CMP_DACCR_DACEN_MASK | CMP_DACCR_VRSEL_MASK | CMP_DACCR_VOSEL(0x1F);
CMP0->MUXCR = CMP_MUXCR_PSEL(0) | CMP_MUXCR_MSEL(7);
CMP0->SCR = CMP_SCR_CFF_MASK | CMP_SCR_CFR_MASK;
0 Kudos

680 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Azema Talam,

Sorry for the delay reply and thanks for sharing the update. Do you have any more questions I can help you with?

Best regards,

Felipe

0 Kudos

680 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Azema Talam,

 

Please check the following document where it is shown how to implement FTM hardware and software synchronization. The application note includes some code examples you could try.

 

PWM Synchronization Using Kinetis Flextimers 

 

I hope this helps.

 

Have a great day,
Felipe

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

680 Views
azematalam
Contributor I

So I looked again at the documentation and it seems that TRIG2 – is not connected to the FTM1_FLT0 pin.

I tried using PTC5 - CMP0_OUT but it still doesn't work. 

This is my code. 

CLOCK_EnableClock(kCLOCK_PortC);
CLOCK_EnableClock(kCLOCK_Ftm0);
/* PORTC5 (pin 50) is configured as CMP0_OUT */
PORT_SetPinMux(PORTC, 5U, kPORT_MuxAlt6);

SIM->SOPT4 = ((SIM->SOPT4 &
/* Mask bits to zero which are setting */
(~(SIM_SOPT4_FTM0TRG2SRC_MASK)))

/* FlexTimer 0 Hardware Trigger 2 Source Select: CMP0 output drives FTM0 hardware trigger 2. */
| SIM_SOPT4_FTM0TRG2SRC(0x00u));
FTM0->FMS = 0;

FTM0->MODE = FTM_MODE_WPDIS(1) | FTM_MODE_INIT(1);

FTM0->MODE |= FTM_MODE_FTMEN(1);

FTM0->MODE |= FTM_MODE_PWMSYNC(0);

FTM0->COMBINE |= FTM_COMBINE_COMBINE0(1) | FTM_COMBINE_COMP0(1);
FTM0->COMBINE |= FTM_COMBINE_SYNCEN0(1);
FTM0->CONTROLS[0].CnSC=FTM_CnSC_ELSB_MASK;
FTM0->CONTROLS[1].CnSC=FTM_CnSC_ELSB_MASK;

FTM0->SC = 7;
FTM0->MOD = 4883;
FTM0->CNTIN = 1;

FTM0->CONTROLS[0].CnV=FTM_CnV_VAL(1900);
FTM0->CONTROLS[1].CnV=FTM_CnV_VAL(2000);

// FTM0->DEADTIME = FTM_DEADTIME_DTPS(3) | FTM_DEADTIME_DTVAL(7);

FTM0->SYNCONF = FTM_SYNCONF_SYNCMODE(1) |FTM_SYNCONF_HWTRIGMODE(1) | FTM_SYNCONF_HWWRBUF(1) | FTM_SYNCONF_HWRSTCNT(1) | FTM_SYNCONF_CNTINC(1) ;

FTM0->SYNC |= FTM_SYNC_TRIG2(1)| FTM_SYNC_REINIT(1) ;

FTM0->SC|=FTM_SC_CLKS(1);

0 Kudos