2024-01-04
02:09 AM
- last edited on
2024-01-04
03:27 AM
by
Lina_DABASINSKA
Hi, I have managed to get my ipm motor running with hall sensors. I can run the motor with motor pilot no problem. I can run the motor down to zero rpm and in reverse direction. I have it running with a pwm signal generated on an arduino in forward rotation. The code generated by MC Workbench only allows for forward rotation. Can anyone tell if it is actually possible to get the motor to run in forward and reverse with a pwm signal.
Solved! Go to Solution.
2024-01-12 05:40 PM
Ok I managed to get it working. I couldn’t manage to get it working properly by defining a mid point in the pwm though I’m sure it can be done. I ended up defining new values for Ton_nmin and Ton_nmax and Ton-ndelta and creating a new case for ESC_NEGATIVE_RUN. A bit of messing around but I can now control the motor from min to max speed both pos and neg and stop the motor. Seems to be working as I hoped it would. Thanks
2024-01-05 01:18 PM
Hello @TRowe ,
As you mentioned, the library allows to spin the motor in both direction. It is just a question of the sign of the target speed (which is done by the MC Pilot).
The PWM input command is managed by a state machine in esc.c file and is a bit different.
The target speed in ESC_POSITIVE_RUN is computed as follow :
2024-01-09 04:32 PM
Hi Cedric,
Thank you for the reply, I have been working on trying to implement the changes you have suggested but im not having much luck. At this point i have updated some of the esc.c file in the armed case and the esc positive run case but my motor still only operates in forward rotation exactly as it did before i made the changes. i have added this to the definintions.
#define Ton_0Speed_value 1460
#define PWM_MIN 1060
#define PWM_MAX 1860
#define PWM_RANGE (PWM_MAX - PWM_MIN)
I have added this to the armed case
if (pHandle->Ton_value >= pESC_params->Ton_min)
{
// Determine the direction based on the zero RPM reference (Ton_0Speed_value)
if (pHandle->Ton_value <= Ton_0Speed_value)
{
// Calculate speed for reverse rotation
new_speed = ((Ton_0Speed_value - pHandle->Ton_value) * (pESC_params->speed_min_valueRPM) / (Ton_0Speed_value - pESC_params->Ton_min));
}
else
{
// Calculate speed for forward rotation
new_speed = ((pHandle->Ton_value - Ton_0Speed_value) * (pESC_params->speed_max_valueRPM) / (pESC_params->Ton_max - Ton_0Speed_value));
}
/* Next state */
/* This command sets what will be the first speed ramp after the
I have added this to the esc positive run case
if (pHandle->Ton_value <= Ton_0Speed_value)
{
// Calculate speed for reverse rotation
new_speed = ((Ton_0Speed_value - pHandle->Ton_value) * (pESC_params->speed_min_valueRPM) / (Ton_0Speed_value - pESC_params->Ton_min));
}
else
{
// Calculate speed for forward rotation
new_speed = ((pHandle->Ton_value - Ton_0Speed_value) * (pESC_params->speed_max_valueRPM) / (pESC_params->Ton_max - Ton_0Speed_value));
}
if (MC_GetSTMStateMotor1() == RUN
I have not disabled any of the security as you mentioned in your previous reply, is it a requirement for
introducing negative rotation? if not ill probably just leave it alone. Could you please provide me
some more information as I have tried based on your previous reply but i cant get it working.
Thanks, Tony
2024-01-12 05:40 PM
Ok I managed to get it working. I couldn’t manage to get it working properly by defining a mid point in the pwm though I’m sure it can be done. I ended up defining new values for Ton_nmin and Ton_nmax and Ton-ndelta and creating a new case for ESC_NEGATIVE_RUN. A bit of messing around but I can now control the motor from min to max speed both pos and neg and stop the motor. Seems to be working as I hoped it would. Thanks
2024-06-13 02:04 PM
I hate to bother you by necroing a six-month-old thread, but I'm trying to do the same thing: bidirectional motor control with a zero speed of 1500us pulse width.
Could you explain in more detail how you modified esc.c to achieve bidirectional control?