Hi everybody,
I wanted to do a quick write up on how I got going with my ODrive and Windows10. Overall, I think the description in the getting started are pretty good, yet sometimes a bit more detail would be great. So essentially here is a write up, first of all to have a documentation for myself, and it might be useful for other people.
Components
As I’m not much of an expert in any of the fields involved, especially not electronics, I went for the usual combination of an 600 count encoder and the N5065 Motor. Furthermore, I ordered a 6/8mm coupler. In my case I had a Mean Well 24V 13A power supply around for powering the whole setup.
Motor holder
As I didn’t find any 3d printable sketch right away, I quickly sketched up a holder for this motor encoder combination. The baseplate is not completely symmetric, but does the job for testing purposes. If you are interested check this thingiverse thing.
Wire up
Okay, so people will make fun of me but this literally cost me 6-8 hours until I realized that I wired up my encoder incorrectly. So the motor is straightforward, I just plugged the 3 wires into the terminal, as different wiring only results in different spin direction as far as I understand. The encoder was plugged in this way, colors are the wires coming from the encoder (this is the correct way, or at least the way which is working for me): red - 5V, green - A, white - B, black - gnd. The power supply was connected, yet not powered on. The ST-Link V2 (included with the board, thanks a lot for this) , was plugged in the following: SWDIO - SWD, SWCLK - SWC, GND-GND. The resistor (also coming with the board, thanks!) was plugged into AUX terminal.
What I was doing wrong before and symptoms: Very first I plugged red into vcc. I was able to flash the board and the initialization routine was running. Yet, I was not able to send commands to the board. After a while I realized the motor was shutting off after the initialization routine, meaning I was able to spin it easily without any resistance. I watched the reference video and realized that my motor only briefly spins in one direction and doesn’t reverse, which I assumed points out that the encoder is not signaling. Once everything is wired up correctly, the motor spins around 1/8 of a rotation in one direction, and then the same reverse. After this it is possible to feel the position control if it is being rotated by hand.
Firmware setup / flash
The guide here is good in my opinion. The only brief struggle I had was putting everything into path, as I wasn’t able to figure out how to do this in cmd right away. I went the advanced systems settings -> Environment Variables -> Path to get all tools into path. From git the V3.3 branch was cloned by:
git clone <url> --branch <branch> --single-branch
<url> from git master
<branch> V3.3-pinout
Next, as mandatory, the motor specs were added into the low_level.c file in MotorControl. As the motor I’m using seems to be fairly standard, the settings were all okay right out of the box. However, as I was just testing one motor first (which I plugged into M1), I deactivated the M0 motor by .enable_control = false and .do_calibration = false in the // M0 section. Subsequently, in git bash, make and make flash worked right away.
Motor control
Here I failed for a long time, as the encoder was not correctly plugged in. Also the Python tool doesn’t work in my hands so far as the use of the print() function seems to be python3 specific, yet this can be fixed easily for python2 by adding from future import print_function at the very beginning of test_bulk.py. Yet, so far it is not recognizing the board and sends: ODrive BulkDevice Not Found I tried to get pyusb going for myself but this also didn’t work independently, so there might be an error to fix in my case.
What did work for me was the suggestion of tokol0sh. Using git bash I used ls /dev/ | grep “tty” to find the device ID of my board, which is /dev/ttyS5. Then I was able to use echo “p 1 1000 0 0” > /dev/ttyS5 to get the motor moving. Once there was a ‘permission denied’ error which just needed a re plugging of the USB connection to be fixed.
Motor tuning
I did an initial tune, which is very rudimentary (I wish there was a good youtube tutorial on this to get it straight). The velocity gain for me was pretty much already perfectly set, I tried to step it up the 30% way, and ended back at the original settings .vel_gain = 15.0f / 10000.0f, // [A/(counts/s)]
as the motor started shaking very soon after stepping the value up. The position gain I was able to set up to .pos_gain = 200.0f,
, and now gives me very tight control which I’ll need for integration into a CNC machine. The overshoots out of a spinning motion are good, so it stops very abruptly, but precisely. However, the motor starts vibrating a bit, not visible at the shaft, but the whole rig is slowly moving on the table. If I push it even more, to .pos_gain = 250.0f,
, this gets really strong.
Maybe someone will find some use in this post if running in the same issues as I did.
One very pressing question I have is, if it is possible to avoid the start up routine for a non-changing setup?
I think the relatively heavy loads of a CNC machine will disturb this process.
Anyways, so far this looks very promising!
Cheers!