# AS5047P SPI failed

**URL:** <https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748>\
**Category:** ODrive v3 Support\
**Created:** [July 31, 2024, 5:04am UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748 "2024-07-31T05:04:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [July 31, 2024, 5:04am UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/1 "2024-07-31T05:04:39Z")

</div>

I’m currently using ODrive v3.6.

But I have no idea about how can I use an AS5047P which has a different layout from other’s.

This is my encoder and…

 ![20240731_133848](https://discourse.odriverobotics.com/uploads/default/original/2X/9/959b2c2940eb16678fdfe5d58071808958140e9c.jpeg)

this is the pinout instruction from the manufacture.  
 ![unnamed](https://discourse.odriverobotics.com/uploads/default/original/2X/5/564afd2c444d2ef51a80530e45b713ac7395d9b3.jpeg)

Can someone help me with wiring this thing and configurating my ODrive?

(I have no budget left. so buying a ODrive S1 can’t be a solution for me.)

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [July 31, 2024, 1:20pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/2 "2024-07-31T13:20:20Z")

</div>

Hi! Have you read the docs? [Encoders — ODrive Documentation 0.5.6 documentation](https://docs.odriverobotics.com/v/0.5.6/encoders.html#spi-encoders)

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [July 31, 2024, 2:06pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/3 "2024-07-31T14:06:11Z")

</div>

Yes, I have. But the dump says  
“AXIS\_ERROR\_ENCODER\_FAILED”  
and  
“ENCODER\_ERROR\_ABS\_SPI\_COM\_FAIL”.

I soldered the  
Encoder CS to Odrive GPIO4,  
Encoder CLK to Odrive SCK,  
Encoder MISO to Odrive MISO,  
Encoder MOSI to Odrive MOSI,  
Encoder GND to Odrive GND, and  
Encoder 5V to Odrive 5V

And I this is what have run :

```auto
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 4
odrv0.axis0.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
odrv0.axis0.encoder.config.cpr = 2**14
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

```

But there a SPI communication error. And The motor never moved during the calibration.

```auto
In [33]: odrv0.axis0.error
Out[33]: 257

```

```auto
In [27]: dump_errors(odrv0)
axis0
  axis: Error(s):
    AXIS_ERROR_INVALID_STATE
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_ABS_SPI_COM_FAIL
  controller: no error
axis1
  axis: Error(s):
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_ABS_SPI_COM_FAIL
  controller: no error

```

After completely turned off and on the power, I got this different error:

```auto
In [34]: odrv0.axis0.error
Out[34]: 256

```

```auto
In [35]: dump_errors(odrv0)
axis0
  axis: Error(s):
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_ABS_SPI_COM_FAIL
  controller: no error
axis1
  axis: Error(s):
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_ABS_SPI_COM_FAIL
  controller: no error

```

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [July 31, 2024, 3:00pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/4 "2024-07-31T15:00:30Z")

</div>

Can you send some images of your wiring?

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [July 31, 2024, 3:05pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/5 "2024-07-31T15:05:55Z")

</div>

Yes, here’s the picture.

 ![20240801_000429](https://discourse.odriverobotics.com/uploads/default/original/2X/d/d0cac71b84d0d3ffa10eb1a43b0e2bde695b3bf3.jpeg)

 ![20240801_000433 (1)](https://discourse.odriverobotics.com/uploads/default/original/2X/0/09dba9d34058201630b7fd02255ce034bda194ba.jpeg)

![unnamed](https://discourse.odriverobotics.com/uploads/default/original/2X/5/564afd2c444d2ef51a80530e45b713ac7395d9b3.jpeg)

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [July 31, 2024, 3:16pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/6 "2024-07-31T15:16:07Z")

</div>

Do you have an oscilloscope or logic analyzer? Are you using a ferrite ring on the motor phases?

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 1, 2024, 12:26am UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/7 "2024-08-01T00:26:39Z")

</div>

I’m sorry, I don’t have any of them…  
and the motor is directly connected to the ODrive.

 ![20240801_092429](https://discourse.odriverobotics.com/uploads/default/original/2X/0/06ac5d89108111942b35be7e2e80fa3acc598598.jpeg)

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 1, 2024, 3:21am UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/8 "2024-08-01T03:21:58Z")

</div>

Oh I replaced the encoder, resoldered it, erased the configuration, and re configured using this commands :

```auto
odrv0.erase_configuration()
odrv0.config.brake_resistance = 2.0
odrv0.config.dc_bus_undervoltage_trip_level = 8.0
odrv0.config.dc_bus_overvoltage_trip_level = 56.0
odrv0.config.dc_max_positive_current = 20.0
odrv0.config.dc_max_negative_current = -3.0
odrv0.config.max_regen_current = 0
odrv0.axis0.motor.config.pole_pairs = 14
odrv0.axis0.motor.config.calibration_current = 5
odrv0.axis0.motor.config.resistance_calib_max_voltage = 2
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
odrv0.axis0.motor.config.current_lim = 15
odrv0.axis0.motor.config.requested_current_range = 20
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 4
odrv0.axis0.encoder.config.mode = ENCODER_MODE_SPI_ABS_AMS
odrv0.axis0.encoder.config.cpr = 2**14
odrv0.axis0.encoder.config.bandwidth = 1000
odrv0.axis0.config.calibration_lockin.current = 5
odrv0.axis0.config.calibration_lockin.ramp_time = 0.4
odrv0.axis0.config.calibration_lockin.ramp_distance = 3.141592
odrv0.axis0.config.calibration_lockin.accel = 20
odrv0.axis0.config.calibration_lockin.vel = 40
odrv0.axis0.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL
odrv0.axis0.controller.config.vel_limit = 50
odrv0.axis0.controller.config.pos_gain = 30
odrv0.axis0.controller.config.vel_gain = 0.02
odrv0.axis0.controller.config.vel_integrator_gain = 0.2
odrv0.axis0.controller.config.input_mode = INPUT_MODE_TRAP_TRAJ
odrv0.axis0.trap_traj.config.vel_limit = 30
odrv0.axis0.trap_traj.config.accel_limit = 5
odrv0.axis0.trap_traj.config.decel_limit = 5
odrv0.save_configuration()
odrv0.reboot()
odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

```

Most of the errors disappeared while this processes.

```auto
In [1]: odrv0.axis0.encoder
Out[1]:
error = 0x0000 (int)
is_ready = False (bool)
index_found = False (bool)
shadow_count = 0 (int)
count_in_cpr = 0 (int)
interpolation = 0.5 (float)
phase = 0.002684354782104492 (float)
pos_estimate = 0.0 (float)
pos_estimate_counts = 0.0 (float)
pos_cpr = 0.0 (float)
pos_cpr_counts = 0.0 (float)
pos_circular = 0.0 (float)
hall_state = 7 (int)
vel_estimate = 0.0 (float)
vel_estimate_counts = 0.0 (float)
calib_scan_response = 0.0 (float)
pos_abs = 0 (int)
spi_error_rate = 0.0 (float)
config:
  mode = 257 (int)
  use_index = False (bool)
  find_idx_on_lockin_only = False (bool)
  abs_spi_cs_gpio_pin = 4 (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 = 50.26548385620117 (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)

```

```auto
In [48]: dump_errors(odrv0)
axis0
  axis: no error
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: no error
  controller: no error

```

But sometimes, the error ‘AXIS\_ERROR\_INVALID\_STATE’ appears in the axis section.  
I tried those commands to verify.

```auto
In [25]: odrv0.axis0.encoder.config.phase_offset
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File <ipython-input-25-82bec0f1045f>:1
----> 1 odrv0.axis0.encoder.config.phase_offset

File c:\users\bluej\appdata\local\programs\python\python38\lib\site-packages\fibre\remote_object.py:245, in RemoteObject. __getattribute__ (self, name)
    243 return attr
    244 else:
--> 245 return object. __getattribute__ (self, name)

AttributeError: 'RemoteObject' object has no attribute 'phase_offset'

In [26]: odrv0.axis0.encoder.config.direction
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File <ipython-input-26-a77ffd9810f9>:1
----> 1 odrv0.axis0.encoder.config.direction

File c:\users\bluej\appdata\local\programs\python\python38\lib\site-packages\fibre\remote_object.py:245, in RemoteObject. __getattribute__ (self, name)
    243 return attr
    244 else:
--> 245 return object. __getattribute__ (self, name)

AttributeError: 'RemoteObject' object has no attribute 'direction'

```

Well, It’s not working.  
After running this command :

```auto
odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

```

The dump says this errors :

```auto
In [30]: dump_errors(odrv0)
axis0
  axis: Error(s):
    AXIS_ERROR_MOTOR_FAILED
  motor: Error(s):
    MOTOR_ERROR_PHASE_RESISTANCE_OUT_OF_RANGE
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: no error
  controller: no error

```

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [August 1, 2024, 12:45pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/9 "2024-08-01T12:45:16Z")

</div>

That seems like a normal error for gimbal motor calibration 🙂 you will need to change calibration current and voltage. Which motor are you using this with?

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 1, 2024, 12:50pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/10 "2024-08-01T12:50:36Z")

</div>

I’m using a GIM4310. I don’t have much information but here’s the website.  
[http://shop.smc-powers.com/GIM4310-Motor.html](http://shop.smc-powers.com/GIM4310-Motor.html)

I’m currently running the ODrive at 14V, but I’d like to go to any higher one like 24V, under 30V.

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [August 1, 2024, 2:02pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/11 "2024-08-01T14:02:12Z")

</div>

Is this the 70KV GIM4310 or the 110KV GIM4310?

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 1, 2024, 2:37pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/13 "2024-08-01T14:37:54Z")

</div>

Oh, sorry again. I had no idea so I measured the resistance between two wires.

 ![KakaoTalk_20240801_233418043](https://discourse.odriverobotics.com/uploads/default/original/2X/d/d71f12a78efae895ab2908e13f033e76591bdfc2.jpeg)

I don’t know whether it’s a right method or not, but my multimeter says, It’s 2.7ohm. I think it’s the 110kV one.  
(Because the 70kV one has 4.8ohm and the 110kV one has 2.0ohm in the specification.)

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 1, 2024, 3:46pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/14 "2024-08-01T15:46:33Z")

</div>

Oh after I ran

```auto
odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

```

the dump says

```auto
axis0
  axis: Error(s):
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_NO_RESPONSE
  controller: no error

```

and the shadow count is fixed at 0 regardless to my manual rotation.

```auto
In [82]: odrv0.axis0.encoder.shadow_count
Out[82]: 0

```

The ODrive doesn’t says SPI COM ERROR but the encoder is still not responding.

To summarize, When I run encoder offset calibration, the dump says encoder no response,  
and when I run axis state full calibration, the dump says motor phase resistance out of range.

---

<div class="post-metadata">

**Author:** ![bluejin404](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/bluejin404/32/6378_2.png) [@bluejin404](https://discourse.odriverobotics.com/u/bluejin404)\
**Post date:** [August 2, 2024, 2:12am UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/15 "2024-08-02T02:12:39Z")

</div>

I tried the MOTOR\_TYPE\_GIMBAL and it started to move when I run the calibration. Thank you. 😇  
(Umm I don’t know how to use the phase\_resistance\_valid command so annotated it, and don’t know if it a right setting or not. Can you tell me?)

```auto
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_GIMBAL
odrv0.axis0.motor.config.pole_pairs = 14
odrv0.axis0.motor.config.torque_constant = 8.27 / 110
odrv0.axis0.motor.config.phase_resistance = 2.0
# odrv0.axis0.motor.config.phase_resistance_valid = True
odrv0.save_configuration()

```

But there’s still ENCODER\_ERROR\_NO\_RESPONSE remaining.

```auto
In [120]: dump_errors(odrv0)
axis0
  axis: Error(s):
    AXIS_ERROR_ENCODER_FAILED
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: Error(s):
    ENCODER_ERROR_NO_RESPONSE
  controller: no error
axis1
  axis: no error
  motor: no error
  fet_thermistor: no error
  motor_thermistor: no error
  encoder: no error
  controller: no error

```

---

<div class="post-metadata">

**Author:** ![solomondg](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@solomondg](https://discourse.odriverobotics.com/u/solomondg)\
**Post date:** [August 6, 2024, 4:06pm UTC](https://discourse.odriverobotics.com/t/as5047p-spi-failed/11748/16 "2024-08-06T16:06:40Z")

</div>

ODrive uses phase-neutral resistance not phase-phase resistance so the given phase resistance value should be 1. Otherwise, looks correct.

Do you have an oscilloscope or logic analyzer to debug the SPI communication issues? Did you set `odrv0.config.gpio4_mode = GPIO_MODE_DIGITAL` ?
