This is my first post on the VESC project forums. I am not sure if this is the right forum to ask this question in so, if this topic would be more suitable for another forum here please do let me know!
To give a bit of context, I am currently working on a 4-wheeled robot. The wheels are mecanum wheels. Each of the wheels is driven by a "TRAMPA 160 KV 637 Out-Runner Motor", each motor in turn being controlled by a VESC MK 4 with the latest firmware (I have used both the latest stable FW release and the test versions being currently released and the described behavior was always the same). The mecanum wheels have a diameter of 254 mm and each motor-wheel pair has a reduction rate of 5,846.
One of the features I am currently trying to implement for this robot is standing still, with all the wheels locked at a fixed position, both on even ground and on a slope. While I am aware there are better and simpler ways of achieving this, currently I am trying to do this just by sending certain commands from the VESCs to the motors and making use just of the motors and their reduction rate. These are the limitations I have to work with currently and the target of this thread is not to research better options of doing this.
Initially I managed to somewhat achieve that desired behavior by sending constant handbraking current to the motors from the VESCs but this approach had its obvious drawbacks (figuring out what would be the necessary handbraking current to stop under various scenarios was not exactly straightforward and just sending a constant value always wasn't doing the trick in every situation). So, I decided to try to approach this by instead sending position control commands when wanting to stand still. I firstly tried doing the position control just with the Hall Sensors which the motors have but, as you might have already figured their resolution was really poor and on top of that, achieving the desired behavior with just Hall Sensors required a lot of tuning for the gains of the position controller. So as a next solution for this I got some AS5047 encoders and made some mounts for them and started playing around with those. The position control with those is amazingly nice once they are properly mounted and configured but there is still one issue that bothers me a lot and I can't seem to figure why it happens.
What happens is that, for some of the encoders, after the whole detection process (which by the way finishes without any issues or faults thrown by the VESC tool), they are detected to be inverted although they clearly are not. I have encoders that are working correctly and once their parameters are detected, they can track the motor position flawlessly and with an error of around 0.3 degrees, but also when I am sending a position control command from the vesc tool, then the position jumps to the expected one. With the ones that have the weird behavior, they are detected as inverted, but when I just turn the motor forwards the encoder is also counting forwards, so clearly it is not inverted. Still, being detected as inverted, almost everything seems to be working fine, until I send a position command. Then, when I send the command (whatever that might be), the motor jumps to a position that is 360-desired_position. So if I send a position control command of let's say 100 degrees, the motor jumps to 260 instead the expected 100. If I try to manually set the "Encoder Inverted" parameter to be "False" for those encoders then nothing works anymore, I can't even drive the motor at all after doing that change. What is interesting is if I leave everything as it is, then everything else works nicely...i can drive the motors and they work smoothly, the only issues is that the position control commands are flipped. And this is a big issue for me as when I am driving the robot as a whole and then I engage the simultaneous position control for all of the motors to keep a specific locked position, the ones that have the encoders with this issue jump to that weird position and this generates a weird shaking from the robot.
This has been puzzling me for the last couple of days and I would greatly appreciate if someone would be kind enough to share some opinions or advice regarding this issue. If any more info regarding the problem and how it is happening is needed, do not hesitate to ask me, I will do my best to try and describe it better.
Sorry for the rather long post, I do hope some people will read through it all! :)