Open bdring opened 4 years ago
I have been able to move the motor via the CAN bus
Hope you don't mind me butting in, but I've finally someone else with a motor that looks like the one I'm trying to get going :)
I can't seem to make mine move at all - whenever I plug in the 24V only a red led turns on and the CAN bus message I send never receives an ack from the motor. Is the red led normal on the new revisions? Based on videos of the older ones, it should be a green led and the red one indicates a fault. I can backdrive it with my fingers even when the 24V is applied. I'm assuming you've only attached the 24V and the H/L of the CAN bus?
Trying to determine if the problem is my CAN programming/setup or if it's the motor itself.
Thanks!
It is red at power on. If you send the motor enable signal, it turns green. You can then send it a move command.
Without fully understanding all the parameters, the motor can be very jerky and not get to position. We were able to SWAG some numbers to get it better, (slow and low torque).
I am dumping everything I know in a drive folder. Feel free to browse around. I am not ready to publish my SWAG values until I get a better understanding.
I am not sure if the encoder is calibrated. I did not get a 3 pin UART connector. I ordered a few from Digikey.
It is red at power on. If you send the motor enable signal, it turns green. You can then send it a move command.
Awesome, thanks for the quick reply. I'll see if I can figure it out :)
I won't be doing much on it until later this week. If you figure anything out, post it here and I'll add it to the doc/folder
Documentation for my motor drives is here:
https://docs.google.com/document/d/1dzNVzblz6mqB3eZVEMyi2MtSngALHdgpTaDJIW_BpS4/edit?usp=sharing
It has an explanation for what the different commands mean and how to set them in real physical units, but here's a qualitative description of what these terms do.
Kp is desired position stiffness. If you set all commands to zero except for Kp, the motor will behave like a spring with stiffness Kp about the 0 angle.
Kd is velocity gain. Kd acts like a damper. If you set all the commands to zero except Kd and try to spin the motor by hand, you will feel some drag, proportional to Kd.
The feed-forward torque is a bias torque. If you set all the commands to zero except for the feed forward torque, the motor will just apply the torque you set.
All the commands get summed up in the motor drive, so the final torque is: Kpposition_error + Kdvelocity_error + feedforward_torque
All this being said, the Aliexpress company just copied my schematic, but I have no idea if they made any changes to the firmware,.
Thanks, that is exactly the guidance I was looking for.
Bart
@bengkatz
I was able to get everything working. Your explanations really helped. The only thing I don't understand is the velocity value. I don't seem to see any change if behavior when I change the value.
Can you give me a quick description? Maybe show me two examples and what to expect to see differently between them.
Thanks again
Bart
Which velocity value? The desired velocity command, or the velocity gain Kd?
The desired velocity
You have to set both a desired velocity and a non-zero velocity gain The velocity gain will set how "hard" it tries to track the desired velocity
Thanks, I am starting to get a feel for it.
To go at a specific velocity, the kd value needs to be higher than the kp value.
If you are just trying to control velocity, you should set Kp to zero or it will fight against your velocity command.
Starting to make some progress. Thanks for all the help.
See the video on this tweet.
@bgkatz I am still playing with this motor as I get time. I have loaded your firmware and the motor appears to work the same as before, so I doubt they changed your firmware much.
I did tweak the gear ratio because my motor has a 6:1 reduction. The range of motion seems to match the +/-12.5 radians of the firmware.
When I send it a command, the motor will move with the values I give it, but it never appears to reach its target position. with low values for kp, kd and ff it can be as far as a radian away. If I send the same position values, but higher kp, kd, and ff values it moves closer. If I max out Kp it gets pretty close, but is very stiff.
I would like to be able to tune it so it always reaches the target, but has adjustable stiffness.
I hope make some sort of CNC machine, like a delta or SCARA. I am thinking about adding a CAN command that disables the UART on the fly and converts those pins to step and direction inputs.
I bought same motor from Steadywin(on aliexpress). I want to upgrade the firmware with mbed compiler. Which target board shall I select?
@nyxrobotics I documented what I did to program it
I hope it helps.
@bdring Thank you so much! I will try it tomorrow.
I was able to write the firmware, thank you!
The motor moves pretty well in normal operation, but I sometimes get "1f" message on serial terminal, and the motor won't move untill reboot. Don't you have this problem?
The "1f" is normal operation. It is on line 63.
printf("%df\n\r", rxMsg.id);
It is printing the message id of the received CAN message on all messages. I am not sure why it is printing the f. It initially fooled me into thinking it was a hex value. It never has any effect on my operation.
Thak you for your reply! The "1f" message was just CAN target ID... We are investigating the problem of resetting the MCU while the motor is rotating, and the motor will not work unless the encoder is recalibrated.....
I replaced the power supply with one with a higher allowable current. It came to move stably. However, I can't set any CAN command for ID "4". While I send the packet for ID 4, CAN::_irq_handler is not called. It seems that mbed-dev issue. Does anyone have same problem ?
I found that ID numbers of "0bxxxxx1xx" pattern, such as 4,5,6,7,12,13,14,15 don't work.
I comented out line 537 and it works pretty well. Thank you!
//can.filter(CAN_ID<<21, 0xFFE00004, CANStandard, 0);
Sounds like you are on an old version of the firmware, which likely has other bugs as well. The link to the latest fork is in the documentation Google doc or here https://os.mbed.com/users/benkatz/code/HKC_MiniCheetah/
Commenting out that line will cause every motor drive to go into the CAN interrupt any time any message is sent on the CAN bus, which is not at all what you want.
Documentation for my motor drives is here:
https://docs.google.com/document/d/1dzNVzblz6mqB3eZVEMyi2MtSngALHdgpTaDJIW_BpS4/edit?usp=sharing
It has an explanation for what the different commands mean and how to set them in real physical units, but here's a qualitative description of what these terms do.
Kp is desired position stiffness. If you set all commands to zero except for Kp, the motor will behave like a spring with stiffness Kp about the 0 angle.
Kd is velocity gain. Kd acts like a damper. If you set all the commands to zero except Kd and try to spin the motor by hand, you will feel some drag, proportional to Kd.
The feed-forward torque is a bias torque. If you set all the commands to zero except for the feed forward torque, the motor will just apply the torque you set.
All the commands get summed up in the motor drive, so the final torque is: Kp_position_error + Kd_velocity_error + feedforward_torque
All this being said, the Aliexpress company just copied my schematic, but I have no idea if they made any changes to the firmware,.
Dear all,
The explanations really helped. I got pure velocity control and pure position control work too. However, I wonder why a PD controller is selected instead of the classical multi-loop(position, velocity, or torque) controller for servo motor. With only PD control, I found it difficult to control the position and velocity at the same time. Can anyone explain that to me.
Thanks
Dear all,
The explanations really helped. I got pure velocity control and pure position control work too. However, I wonder why a PD controller is selected instead of the classical multi-loop(position, velocity, or torque) controller for servo motor. With only PD control, I found it difficult to control the position and velocity at the same time. Can anyone explain that to me.
Thanks
It's not quite a classic PD controller, which would only take a position command, and would take the derivative of the position error to get the derivative term. The position + velocity commands with position + velocity proportional gains is equivalent to the classic PD controller in continuous time, IF the position and velocity commands are consistent with each other, but is works better when commands are sent slower than the control loop is updated.
Which brings up the point - you fundamentally can't do independent position and velocity control. If you want to control to a trajectory, you should send position and velocity commands that are consistent with each other, i.e. the velocity command integrates to the position command.
To summarize how it was intended to be used:
The motor drive itself will not generate intelligent trajectories (e.g. trapezoidal velocity profiles between position setpoints), that is up to you to do on whatever is controlling the motor. But if you can generate the trajectories, you should be able to send self-consistent position and velocity commands to track it.
Hopefully that clears up any confusion
That is pretty interesting. I will do more research on command generation and motion planning. Thanks for your detailed explanation.
Nowadays, is anyone able to compile the firmware? I can't import it into the mbed cloud compiler. I can't even compile it with mbed CLI and mbed Studio. I believe the cause is due to the version of the mbed library. Can someone please help me?
Hey Ben,
Thanks for this awesome open source project. I do a lot of open source work too.
https://github.com/bdring/Grbl_Esp32 https://www.youtube.com/watch?v=M1gXuKFspgY
I stumbled upon one of your designs on AliExpress. I bought one to test. The motor I received looks like this.
The documentation I received is pretty limited.
I hope to use the motor some sort of fabrication or kinetic art machine. The motor is so clean looking and the wiring can almost be invisible. I am quite excited.
I have been able to move the motor via the CAN bus, but I don’t have a real feel for what values to provide for Kp, Kd and Feed-Forward Current. Is there any guidance you can give me?
Thanks
Bart Dring