top of page
Feb. 5th, 2022
Yo-yo robot part 3: encoders, setup, and O-Drives.
Occasionally being pleasantly told... Oh no odrv0 disappeared
A few small updates of the general kind before we begin — the first is that we've started a Simmons Hall official small business. Located right next to Carl's Chair Consortium and across from Anita's Jank Salon, our robotics company will be called "Boston Falls Over." And we put the logo on our room door.
The next update is we've officially taken up a small spot in MITERS, something we've been planning to do since first year of MIT. I want to be a deeper part of the MITERS community and come work on the amazing projects they do here with the amazing people. Today I've come by with the yo-yo robot to see if we can't get some yo-ing action going.
Alrighty so here's the plan for the day and a picture of the yo-yo bot (with the man, the myth, the legend, John Henry in the background).
Glue on the encoder unit on the back of the motor.
Mount the encoder and wire it up.
Flash the O-Drive, calibrate, modify settings, and test control.
Start working out a yo-yo control strategy.
Amber and Electra are also here so we're going to have fun tonight! Depending on how long this takes we may split this up into one or two more controls posts because the testing and electrical bring-up might take the whole night (especially because we need to find a battery and etc).
Ok so step one is to get this encoder mounted to the back of the motor. The encoder is used by the motor controller to determine the position of the motor's rotor so the motor controller can precisely send electrical signals to the three phases of the brushless motor for fine torque control (which is what we need in this case as opposed to just spinning at a constant speed back or forth).
This precise torque/current control into the motor takes the form of Field Oriented Control a technique for controlling BLDC motors. Since motor torque is proportional to current (directly), we can use the O-Drive in FOC/current control mode to output a precise torque at any given time.
The encoder has two parts, the actual encoder itself and a spinny gear thing that gets attached to whatever is spinning. To attach the spinny gear thing we first super glued the spinny gear to the center of the back of the motor. And then to keep it a little more secure, we added hot glue into the center for support. We did the same kind of thing on the Pixar Lamp to attach both encoders.
The encoder we're going to mount onto this is an AMT102-V from CUI Devices. It runs on 5V and is capable of a resolution of 2048 PPR incremental with a Z-index pulse. Here's the datasheet for those who are interested.
So the next step was wiring in the encoder. We took some standard female header connectors, in this case a 1x5 CONN housing for the 5V, GND, A, B, and Z of the encoder. We also took some 22awg copper wire with a lovely orange coating and cut five pieces to size. We crimped the female headers on each end and put them into the 1x5 housing ensuring the right wires were going to the right ports. The ports on the O-Drive are labeled and so are the ports on the encoder itself.
We did a conductivity test between all of the ports on the O-Drive and the connectors, the connectors at the beginning of the wire to the end of the wire, and the connectors at the encoder itself to ensure full continuity. We then zip-tied the wire down to the frame.
The tension in the wire will prevent the encoder from rotating since the friction inside the encoder itself is so low, that little bit of constraint is enough. This means we don't need an additional mechanical mount to make the encoder stay in one place.
It was late last night and John Henry wanted to go home — and I wanted to sleep. Now it's tomorrow and we're back at a favorite campus makerspace 4-409 to finish up what we wanted to do yesterday. We also didn't have a USB-C to USB adapter yesterday but we have one now!
Before we left last night we made a power cable that could connect the yo-yo bot to a power supply that supplies around 20-24V at input. We probably don't need that much current at least for setup and calibration.
So next we wanted to flash the O-Drive with the latest firmware. Usually this is as simple as running odrivetool dfu in the terminal after installing all the appropriate software. But in this case the O-Drive was behaving funny so there's an alternate tool we can use with brew and downloading the binaries from git.
Steps to flash the ODrive (24V V3.6)
We first downloaded the ODrive V3.6-24V .elf firmware file (on MacOS) from here
Then with homebrew we ran brew install --cask gcc-arm-embedded
And then brew install dfu-util
Convert the .elf to a .bin using arm-none-eabi-objcopy -O binary ODriveFirmware_v3.6-24V.elf ODriveFirmware_v3.6-24V.bin
Then run dfu-util --list to find the serial number of the O-Drive
Found DFU: [0483:df11] ver=2200, devnum=11, cfg=1, intf=0, path="20-3", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="2079358E524B"
And we can flash the firmware with sudo dfu-util -S 2079358E524B -a 0 -s 0x08000000 -D ODriveFirmware_v3.6-24V.bin
According to the flashing tool the firmware on our device was initially corrupt. So that's probably why odrivetool dfu couldn't flash it. But now it seems like the device is all flashed and ready to go so we want to go ahead and setup all the parameters needed using odrivetool as standard.
We basically went thought the following guide step-by-step but ended up using the following values.
odrv0.axis1.motor.config.current_lim = 40
odrv0.axis1.controller.config.vel_limit = 100
odrv0.config.enable_brake_resistor = False
odrv0.config.dc_max_negative_current = -10
odrv0.axis1.motor.config.pole_pairs = 7
odrv0.axis1.motor.config.torque_constant = 1
odrv0.axis1.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
odrv0.axis1.encoder.config.cpr = 8192
The next step was to go ahead an do encoder and motor configurations using the following guide. We followed it pretty much exactly, our encoder has a z-index-pulse so we set the following parameters. Remember to hold the assembly horizontal for the fulll-state-calibration-sequence.
...encoder.config.pre_calibrated = True
...motor.config.pre_calibrated = True
...config.startup_encoder_index_search = True
We ran an axis full state calibration sequence which measured the motor parameters and encoder offset, and found the z-index pulse and etc. During this we can't have any gravity loads on the motor so we just held the whole robot horizontally. Remember after doing all this to type odrv0.save_configuration() in the terminal.
Lastly, we had to adjust the arm set screws so the arm sits slightly farther away from the body so it doesn't collide with the screws at the bottom. The arm now has a full 360deg range-of-motion.
Now we ran a quick test of the robot, we set axis requested state to CLOSED_LOOP_CONTROL and put the controller in torque control mode and requested 5A of current. The above video resulted which was super fun. The O-Drive is currently trying to send a constant torque-producing current of around 5A to the motor.
So what we achieved in this set is we mounted and wired in the encoder and went through the full setup of the O-Drive itself. For purposes of keeping this post short and so we can get to other homework and things (oops) we'll probably do control in the next post so we can focus on that. Now that the robot is a fully functional platform, we can get to trajectories and control next time. With previous code from the Pixar Lamp we should be able to do that in one day to get some initial preliminary yo-yo results and compare the motions of a human hand to that of the yo-yo robot.
#yo-yo-bot #wiring #configurations #odrive
bottom of page