Hey everyone,
We are using TWR-KV58F220M along with TW-MC-LV3PH motor control module and Linix 45zwn24-40 motor.
We are using MCUXpresso IDE and SDK with the sensorless BLDC example. We want to integrate the HALL input decoder but we were unable to find any reference for that.
Our use case is to synchronize two motors so that they can run at same RPM and stops at synchronized positions.
As we run the motor, it first goes into the alignment state. The drift of motors during alignment state is different every time for both the motors so they become out of sync. When the motors stop, they are always at the different position.
So is there any project that consists of hall input decoder from which I can take reference from or any idea how can I implement position control for the motors.
Thanks.
Hi, Animesh,
I do not think that you needs alignment stage if you control a BLDC with Hall sensors, when you start to spin a motor, just read the hall sensor logic, then switch the stator based a predefined table, it is okay.
Hope it can help you
BR
Xiangjun rong
Okay. Is there any reference for reading the hall sensor logic.?
Thanks.
Hi, Animesh,
As you know that you can use either Hall sensor or Encoder to control BLDC, now, you use encoder sensor, it is okay. If you use encoder, you do not need to use capture mode of FTM and read hall logic.
The FTM1/FTM2 of KV58 support quadraure mode, in other words, if you configure FTM2 in quadrature mode, the FTM2 can counts the encoder signals. On TWR-MC-LV3PH boards,there is a J8 connector, the ENC_PHASE_A/ENC_PHASE_B are encoder signal, both the signal are connected to PTE22/FTM2_CH0/XB_IN2/FTM2_QD_PHA and PTE23/FTM2_CH1/XB_IN3/FTM2_QD_PHB on TWR-KV58 board, after you configure the pins as FTM2_QD_PHA and FTM2_QD_PHB and configure the FTM2 as quadrature mode, it is okay.
How many edges for the phaseA and PhaseB for one mechanical revolution?
Hope it can help you
BR
Xiangjun Rong
Thanks for the response. It helped.
I looked at the sensorless SDK example for KV5x and found that the PTE22 pins are configured as XB_IN2.
{pin_num: '41', peripheral: ENC, signal: 'PHASE, A', pin_signal: PTE22/FTM2_CH0/XB_IN2/FTM2_QD_PHA}
{pin_num: '41', peripheral: ENC, signal: 'PHASE, A', pin_signal: PTE22/FTM2_CH0/XB_IN2/FTM2_QD_PHA}
But, I am unsure about how can I configure this pin as capture function and how I will be able to read the logic of hall sensor. Can you help me with that?
Also I found that only pins for Phase A and Phase B are configured as XB_IN2, so do I have to configure the same for Phase C also?
Thanks,
Animesh
Hi, Animesh,
Pls refer to section 44.1.8 FTM Hall sensor support in RM of KV58, I copied it here.
The KV58 has an internal EOR circuit, which can EOR of FTM2_CH0/1 and FTM1_CH1 and connect the EOR circuit output to the FTM2_CH1. If SIM_SOPT9[FTM1ICH1SRC]=0, FTM1_CH1 piad signal is the capture signal, if SIM_SOPT9[FTM1ICH1SRC]=1, exclusive OR of FTM2_CH0,FTM2_CH1, and FTM1_CH1 is the capture signal.
Regarding the question how to configure the pin FTM2_CHx as capture function, this is the procedure, for example
PTB19/CAN0_RX FTM2_CH1 FTM3_CH3 FLEXPWM1_B1/FTM2_QD_PHB/FB_OE_b
1)Enable PTB port gated clock
SIM_SCGC5|=0x01<<10;
2)configure as PTB19 as FTM2_CH1 function
PORTB_PCR19|=0x03<<8;
3)SIM_SOPT9|=0x01<<10; //set FTM2ICH1SRC bit
4)enable FTM2 gated clock
SIM_SCGC6|0x01<<26;
5)configure the FTM2_CH1 as capture function.
FTM2_C1SC[MSnB:MSnA]=2b'00;
FTM2_C1SC[ELSnB:ELSnA]=2b'11; //Capture onRising or FallingEdge
Pls refer to 44.4.6 Channel (n) Status And Control (FTMx_CnSC)
6You can read the GPIOB19 input register to get the logic level of PTB19 pin at the reading time even the pin is configured as FTM2_CH1 function.
Hope it can help you
BR
Xiangjun Rong
Hi xiangjun.rong,
Thank you so much for the help. We are now able to get the positions based on the hall sensor input from Phase A and Phase B. We are getting 8 steps in one rotation.
However, is there any way we can using this position encoding from hall sensor for starting motor from a specific position, say start position, every time, or stop at a specific position, say destination, every time we stop the motor.
Thanks and regards,
Animesh
Hi, Animesh,
Do you use Hall sensor or encoder sensor? The Hall sensor can output 3 signals:Hall A/B/C. But the encoder can output only PhaseA and PhaseB two signals.
BR
Xiangjun Rong
Hi Xiangjun,
We are using the encoder sensor. Yes, the data is from PhaseA and PhaseB only.
Hi, Animesh,
As you know that the Linix 45zwn24-40 motor has integrated a hall sensor, the sensor signal can be connected to J8 connector on the TW-MC-LV3PH, then the three hall signals are routed to FTM channel pins, for example
ENC_PHASE_A is pin 3 of J8 on TWR-MC-LV3PH, it is connected to A34 of the gold finger, and connected to FTM2_QD_PHA, FTM2_QD_PHA/PTE22 for KV58, which pin is PTE22/FTM2_CH0/XBAR0_IN2/FTM2_QD_PHA.
When the PTE22 pin is configured as capture function, the rising/falling edge of PTE22 can trigger capture interrupt, in the capture ISR, you can read the logic of the hall signal, and determine which stator will be switched based on a table.
Regarding your requirement that you want to synchronize two BLDC motors, we have the solution to spin a BLDC with speed control, each BLDC motor is controlled separately, we have not the example to run two BLDC synchronizedly.
I have not found the BLDC motor control with KV5x, this is an reference design for BLDC plus hall sensor:
3-Phase BLDC Motor Control Reference Design|NXP
This is the BLDC motor control example code for KV family.
Arm® Cortex®-M4|Kinetis® KV3x Real-time Control MCUs|NXP
Hope it can help you
BR
Xiangjun Rong