Hi,
I'm developing a motor control program with simulink using the Motor Contol Toolbox. I am currently using the following boards:
- TWR-KV31F120M
- TWR-MC-LV3PH
And the controlled motor is a BLDC type: Linix 45ZWN24-40.
I need to read the hall sensors signal to make a trapezoidal control, so I configure them in input edge capture blocks connected to FTM2_CH0 (PTB18),FTM2_CH1 (PTB19),FTM1_CH1 (PTA13) pins, as it says in user manual, then I read the pin logic via GPIO to know the motor position.
But when I try to read the signal logic via GPIO input, I can see that FTM1_CH1 is the only one that detects rising and falling edges so is toggled. The other two channels detect nothing. One of them is always on while the other is off. Am I doing something wrong? Does FTM need to be initialized in some way to work in capture mode?
Thank you all.
Hi, Mikel,
I see that you have to read all the the pin logic in the FTM capture ISR to determine the rotor position. I suppose that you do not configure the pins correctly. pls follow up the procedure:
1)configure the PTB18, 19 and PTA13 in ALT3 as FTM function by the PORTx_PCRy register.
2)set the FTM2_CH0/FTM2_CH1/FTM1_CH1 pin in capture mode by writting the FTMx_CnSC
3)read the pin logic by reading the GPIOx_PDIR register.
I do not develop the test code to confirm, pls have a try.
BR'
Xiangjun rong
Thanks for your reply.
That is exactly what I am doing but the FTM is not detecting edges. Maybe I should ask in the other section related to MATLAB/Simulink.