Seems to be the correct values now and the sensor check goes well, but when implementing the generic sensor the motor just shakes, motor runs fine during the sensor calibration.
Yes, the velocity mode depends on torque mode, and you need to tune the PID to match your motor. 20.0 is probably too high for the I term.
The voltage limit of 3/24 is not ideal: this is a low utilisation of the PWM range, all the PWM duty cycles will be very short. It would be better to use a 5V power supply if you only need 3V on the motor.
Which type of motor is it, what’s the winding resistance?
And how many pole pairs has the motor, did you configure it correctly? Its important to get the pole-pair number correct…
Ok, this seems ok. With 3.7Ω phase resistance you can probably go a little higher with the voltage… but 1V motor voltage limit should be enough to move the motor.
I’m new to motor driving but I it will probably be easier when all start to make sense, yes it’s still shake on same place. I appreciate your help!
That’s interesting, encoder is mounted on motor shaft but when I turn motor by hand it goes from 0 to 6.28 quite fast not a full motor turn. Can it be that encoder is calibrated somehow with gearing? Motor gearing is 30x for output shaft, but encoder is not mounted on output shaft…
I dont have access to code right now but it’s same as for torque example but with voltage limit of 3.
I will make a test to see how many times it reaches 2PI radians when made one full motor turn.
This is a strange sensor, but then yes, it sounds like it is somehow calibrated for maybe the output shaft position? Have you checked if the 0-2PI corresponds to one full turn of the output shaft?
→ if yes, then you could divide the value by the gear-down, i.e. 1/30…
But the datasheet you pasted says “Absolute position / revolution (motor side)” - which I would understand to mean before the gear-down…
The SimpleFOC code absolutely cannot work if the sensor does not return 0-2PI corresponding to the rotor position.
Perhaps another explanation is that the byte order is still wrong: maybe we’re using the low byte as the high byte? Then you would seem to get many 0-2PI outputs per revolution…
Is it better if you do: uint16_t rawval16 = (buff[2]<<8) | buff[1];
or does that make it even worse?
This makes it worse if switch so it seems fine, I notice when I turn maybe 5-10 degree of motor shaft it goes from 0 - 2PI, and values looks fine each time.
If I divide the value by the gear-down it jumps only from 0 - 0.21
I made a test with some counter that check each full turn of motor and when it reach 2PI
angle_rad: 0.80 - count: 10
So it tool 10 times to rotate 1 full motor turn and each range from 0-2PI
I tried that too, but now it jumps very fast between 0 - 2PI.
So I suppose some magic math like you made now but it step up 10x? But still makes no sense when encoder states: Absolute position / revolution (motor side)
Yes just small jumps from 0-2PI each degree, like should require to remap the full range ~10xPI2 to 2PI somehow, not sure how to make that. Or maybe increment parameter (adds/subtract during motion) and use that value as raw.
Just spinning ideas
It’s very wierd, maybe they failed to calibrate it from factory for a full turn. But that is a long shoot