You are here

Position control without encoder

2 posts / 0 new
Last post
bearing
Offline
Last seen: 1 year 8 months ago
Joined: 2022-12-09 02:29
Posts: 2
Position control without encoder

I'm trying to control my motor using position PID control but can't figure out how to get it to work. When I set a position in VESC tool the motor spins wildly and stops in a random spot. Only after setting the same position several times does it eventually rest on the correct position (and this seems to be if it just happens to get close by chance). 

Is it even possible in the current firmware to use position control without an encoder? Using the right "Position angle division" seems to give the right position in the realtime data tab, and if I spin the motor by hand, the "PID pos" graph seems to track the way it should. For now accuracy to <5* should be fine. 

If not, can someone direct me to where I might fiddle with the PID controller in firmware? 

A related question - is it possible to also control speed (or set a max speed) while seeking a new position? I'd like the motor to turn much more slowly. 

For reference I'm using a large hub motor, 10 pole pairs, 5:1 gear ratio, and hall effect sensors. Hardware is 6 mk 5, firmware 6.02. I plan on controlling the vesc over CAN bus but for testing I'm just using VESC tool. 

I'm brand new to VESC, so thanks for any help with this. 

bearing
Offline
Last seen: 1 year 8 months ago
Joined: 2022-12-09 02:29
Posts: 2

Ok, what I'm trying to do isn't supported out of the box - mcpwm_foc_set_pid_pos() has a comment saying "Note that this only works when encoder support is enabled." But obviously it could work given that it sort of almost works now. 

I'm not sure what position control behavior is supposed to look like. For me (with no encoder), it seems that sending the set position command causes one shot of (a lot of) current, which causes the motor to make several revolutions, and then stops. Sending the set position command multiple times eventually causes the motor to rest at the right spot. I don't know if this is a bug or not, given that its not supposed to work at all. The amount of current I think is calculated at the end of foc_run_pid_control_pos() in foc_math.c and is scaled to the max current - bringing down the max current in vesc tool causes the shot of current to be smaller and I can sneak up on my position more quickly without the motor spinning several times. 

I can't figure out what exactly is going on the code and why it should only work with an encoder. Any help with this would be appreciated, it would be useful for me to have this functionality,