How to wire AS5047P to ODrive

Hi,
Can you help me about how to wire as5047p encoder to odrive 3.6 56V?

Hi cpoyraz, you will connect +5V or +3.3V (depending on which AS5047 board you’re using) to the ODrive, connect GND, and then connect MISO to MISO, MOSI to MOSI, and SCK to SCK. Then connection one of the GPIO pins (I like GPIO 8) to the AS5047 CS pin. Pretty straight forward :slight_smile:

there are a few pins on odrive like A, B, Z but I could not find any counterparts on AS5047P

The A/B/Z pins are only used for incremental encoders and are not applicable for the AS5047P absolute SPI encoder

I connected according to your comment and odrive instructions in docs below
Connect the encoder to the ODrive’s SPI interface:

  • The encoder’s SCK, MISO (aka “DATA” on CUI encoders), GND and 3.3V should connect to the ODrive pins with the same label.
  • The encoder’s MOSI should be tied to 3.3V (AMS encoders only. CUI encoders don’t have this pin.)
  • The encoder’s Chip Select (aka nCS/CSn) can be connected to any of the ODrive’s GPIOs (caution: GPIOs 1 and 2 are usually used by UART).
<axis>.encoder.config.abs_spi_cs_gpio_pin = 8 
<axis>.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
<axis>.encoder.config.cpr = 4096             
<odrv>.save_configuration()
<odrv>.reboot()

it gives the error ENCODER_ERROR_ABS_SPI_COM_FAIL (error 0x0080)

Hmm. Looks like your configuration is right, and your wiring sound correct.

Please check encoder.spi_error_rate. If it’s 1.0 or nearly, then you may have a wiring or power problem. If it’s 0.0, or very close, then you are getting good data. If it’s in between, you have intermittent data. You may need to get an oscilloscope or logic analyzer to check that the Error Flag is not set on the encoder, and that the waveform looks ok.

Hi again,
encoder.spi_error_rate is 2.8 and dump_errors(odrv0) gives “MOTOR_ERROR_PHASE_RESISTANCE_OUT_OF_RANGE” for axis1.
In AS5047P doc, it is said that
“The connector JP1 allows to select between 5V or 3.3V operation.
R1 and R2 are 0 ohm resistors in 0603 package. Depending on the supply voltage either R1 or
R2 has to be populated. For 5V operation R1 has to be populated and R2 has to be removed
(default case). Vice versa for 3.3V operation.”
I think not setting 3.3V in JP1 may cause of that, how can I do that correctly?

Ok, your motor isn’t plugged in, it has a problem, or it has very high (or low) resistance.

No idea!

Hi there,

I take the liberty to reopen this topic because I have the exact same problem with the AS5048A. This gives an idea of the configuration and the errors (encoder object):

error = 0x0080 (int)
is_ready = False (bool)
index_found = False (bool)
shadow_count = -98403 (int)
count_in_cpr = 16279 (int)
interpolation = 0.0 (float)
phase = -0.589404821395874 (float)
pos_estimate = -6.006387710571289 (float)
pos_estimate_counts = -98402.421875 (float)
pos_cpr = 0.993830680847168 (float)
pos_cpr_counts = 16280.71875 (float)
pos_circular = 0.9936075210571289 (float)
hall_state = 7 (int)
vel_estimate = 0.0 (float)
vel_estimate_counts = 125.00003051757812 (float)
calib_scan_response = 0.0 (float)
pos_abs = 16285 (int)
spi_error_rate = 0.5155370831489563 (float)
config:
mode = 256 (int)
use_index = False (bool)
find_idx_on_lockin_only = False (bool)
abs_spi_cs_gpio_pin = 8 (int)
zero_count_on_find_idx = True (bool)
cpr = 16384 (int)
offset = 0 (int)
pre_calibrated = False (bool)
offset_float = 0.0 (float)
enable_phase_interpolation = True (bool)
bandwidth = 1000.0 (float)
calib_range = 0.019999999552965164 (float)
calib_scan_distance = 6.2831854820251465 (float)
calib_scan_omega = 12.566370964050293 (float)
idx_search_unidirectional = False (bool)
ignore_illegal_hall_state = False (bool)
sincos_gpio_pin_sin = 3 (int)
sincos_gpio_pin_cos = 4 (int)
set_linear_count(count: int)

I’m powering the chip with 3.3V, is this correct? Did anyone find an answer to this topic?
Thanks!