I'm using NXPS32K144.
On the DC motor, we have two hall sensors and I want to calculate the motor speed and the motor position.
We need to use the interruption function. What kind of block should I use ? ISR blocks ? FTM blocks ? Have you got an example to show me ?
Hello @KiteSurfer ,
As a starting point to measure speed and motor position using hall sensors, you can use the "BLDC_ClosedLoop_s32k144" model that is part of the S32K1xx MBDT. This example uses GPIO read to get the default hall sensor state, then it uses the GPI ISR to get the updated hall sensor state. And besides that, we use a PIT interrupt to count the time between two hall sensor transitions.
Another example that you can use is the "mcb_pmsm_foc_hall_MCSPTE1AK144" model that is part of the "Field-Oriented Control of PMSM Using NXP™ S32K144 Kit" addon that you can find in Matlab addons. This example uses GPIO read and FTM as time counter, but the hall sensors and FTM are read in an ADC interrupt that is triggered at a periodic time.