Motor1 not spinning?

Hi guys, I just complied the latest firmware with configuration for v3.1 board, using native USB and step/dir GPIO config. I hooked up motor1
After flashing I can hear the beep and the motor does a slow test rotation
now I’m trying to run (after modifying to run motor1 instead of motor0), the system can access odrive through USB and I’m getting the proper VBUS readout (~17.6V), it’s going through the sine wave test but the motor is not spinning, any ideas why or how to debug this?


#!/usr/bin/env python3
Example usage of the ODrive python library to monitor and control ODrive devices

from __future__ import print_function

import odrive.core
import time
import math

# Find a connected ODrive (this will block until you connect one)
my_drive = odrive.core.find_any(consider_usb=True, consider_serial=False, printer=print)

# The above call returns a python object with a dynamically generated type. The
# type hierarchy will correspond to the endpoint list in `MotorControl/protocol.cpp`.
# You can also inspect the object using the dir-function:
# TODO: maybe provide an introspection method that dumps the whole type hierarchy at once

# To read a value, simply read the property
print("Bus voltage is " + str(my_drive.vbus_voltage) + "V")

# Or to change a value, just assign to the property
my_drive.motor1.pos_setpoint = 3.14
print("Position setpoint is " + str(my_drive.motor1.pos_setpoint))

# And this is how function calls are done:
my_drive.motor1.set_pos_setpoint(0.0, 0.0, 0.0)

# A little sine wave to test
t0 = time.monotonic()
while True:
    setpoint = 10000.0 * math.sin((time.monotonic() - t0)*2)
    print("goto " + str(int(setpoint)))
    my_drive.motor1.set_pos_setpoint(setpoint, 0.0, 0.0)

# Some more things you can try:

# Write to a read-only property:
my_drive.vbus_voltage = 11.0  # fails with `AttributeError: can't set attribute`

# Assign an incompatible value:
my_drive.motor1.pos_setpoint = "I like trains"  # fails with `ValueError: could not convert string to float`

Use to read the error.

I can already see that you don’t have your encoder CPR set correctly, but try finding that from the error codes.

btw, also the motor is not responding to step/dir GPIOs (3,4)

# Copy this file to tup.config and adapt it to your needs
# make sure this fits your board

thanks a lot @madcowswe
I was able to change the encoder CPR to the proper value (I think 600x4 = 2400 for LPD3806-600BM-G5-24C)
Still giving error 22 ERROR_ENCODER_CPR_OUT_OF_RANGE
I also tried changing to 1600 since some websites show it’s 400 ppr
I wonder if there’s a way to see if the encoder is actually alive and giving pulses to the odrive?

I did verify that the encoder is on, outputting 3.3V pulses when rotating
do you remember what values you used with this encoder before?

also made sure the pole pairs = 7, double counted for the turnigy aerodrive 4250-410 motor

After startup check encoder state value. Turn wheel 360 by hand and check if the increase in pulses is what you expect. Also is your timing belt tight enough. So no play between encoder and motor.

it’s weird, I checked my_odrive.motor1.encoder.encoder_state and it’s always zero no matter how much I rotate the encoder. But I can see the encoder pulses on the board using my scope

i will keep looking

I got it to work now, I missed the v3.1 errata on silkscreen notes for encoder
thanks for your attention