Reset encoder counter causes a jump
5 years 6 months ago #29531073
by Brogath
Reset encoder counter causes a jump was created by Brogath
When I reset the encoder counter via script using setcommand(_C, 1, 0) the motor jumps a bit.
It seems a high amount of amps is briefly blasted through the motor before it calms down.
After the burst the motors work normally and i cannot see any problems while they run.
The motors are in closed-loop speed mode while the vehicle is driving.
The motors are set to open-loop before I reset the encoder count.
Once reset, the motors are set back to closed-loop
This is the code:
setconfig(_MMOD, 1, 0)
setconfig(_MMOD, 2, 0)
setcommand(_C, 1, 0)
setcommand(_C, 2, 0)
setconfig(_MMOD, 1, 1)
setconfig(_MMOD, 2, 1)
The motor command is always 0 when this piece of code is run.
I am using a MDC2230
It seems a high amount of amps is briefly blasted through the motor before it calms down.
After the burst the motors work normally and i cannot see any problems while they run.
The motors are in closed-loop speed mode while the vehicle is driving.
The motors are set to open-loop before I reset the encoder count.
Once reset, the motors are set back to closed-loop
This is the code:
setconfig(_MMOD, 1, 0)
setconfig(_MMOD, 2, 0)
setcommand(_C, 1, 0)
setcommand(_C, 2, 0)
setconfig(_MMOD, 1, 1)
setconfig(_MMOD, 2, 1)
The motor command is always 0 when this piece of code is run.
I am using a MDC2230
Please Log in or Create an account to join the conversation.
- roboteq
5 years 6 months ago #29531074
by roboteq
Replied by roboteq on topic Reset encoder counter causes a jump
The controller runs through a loop every 1ms. You need to allow at least that much time for a change to take effect. Add wait statements as shown:
setconfig(_MMOD, 1, 0)
setconfig(_MMOD, 2, 0)
wait(5)
setcommand(_C, 1, 0)
setcommand(_C, 2, 0)
wait(5)
setconfig(_MMOD, 1, 1)
setconfig(_MMOD, 2, 1)
setconfig(_MMOD, 1, 0)
setconfig(_MMOD, 2, 0)
wait(5)
setcommand(_C, 1, 0)
setcommand(_C, 2, 0)
wait(5)
setconfig(_MMOD, 1, 1)
setconfig(_MMOD, 2, 1)
Please Log in or Create an account to join the conversation.
5 years 6 months ago #29531083
by Brogath
Replied by Brogath on topic Reset encoder counter causes a jump
5mS did not fully solve the problem, it often worked well for one motor but the other still made a jump.
Increasing the wait command to 10mS appears to have solved the matter as it has not occured since the change.
Thank you for your assistance.
Increasing the wait command to 10mS appears to have solved the matter as it has not occured since the change.
Thank you for your assistance.
Please Log in or Create an account to join the conversation.
Moderators: tonysantoni
Time to create page: 0.082 seconds