I'm still working with something based on AN3206. I'm trying to figure out what's wrong with my commutation, and I started reading back the theta from the eTPU. It doesn't make any sense to me.
I have a 4000 count encoder and a motor with two pole pairs. According to the function description theta = (2 * encoder)/4000, so theta should advance twice for each cycle. However, it isn't even synchronized with the zero position of the encoder. See the attached plot.
In etpu_pmsmvc.c scale is set to scale = motor_pole_pairs * 0x1000000 / qd_pc_per_rev; .
Since there was not a "get theta" function I added one like this:
fract24_t fs_etpu_pmsmvc_get_theta(uint8_t channel)
{
uint32_t *pba;
pba = fs_etpu_data_ram(channel) + (0x4000 >> 2);
return (fract24_t)(*(pba + ((FS_ETPU_PMSMVC_THETA_OFFSET) >> 2)));
}
Any ideas?
Solved! Go to Solution.
Never mind. I had used the PMWmaster channel instead of the PMSMVC_channel and happened to get back that thing that went from -1 to 1. Now that I've fixed it I get what I expect.
Well, whatever I'm getting back with that fs_etpu_pmsmvc_get_theta() function it isn't theta. Even if I stop the motor rotation I get the same -1 to 1 ramp. I've asked Freescale for the eTPU code that is being generated by the eTPU function selector so I can figure out what's going on.
Never mind. I had used the PMWmaster channel instead of the PMSMVC_channel and happened to get back that thing that went from -1 to 1. Now that I've fixed it I get what I expect.