Be careful when using AS5047p in SPI mode.
According to ODrive DOCS AS5047p should work with 3V3 volts.
AS5047P-TS_EK_AB (eval board/kit) has a jumper 3V3 / 5V,
however !!! it’s not enough (in my case) just to select 3V3 on that jumper.
As per AS5047P-TS_EK_AB datasheet, R1 and R2 resistors (0 Ohms) should be switched:
with jumper in 3V3 position and default setting of R1 and R2 I was not able to make AS5047p running.
@M_M very good spot. I had completely missed that! Might explain why I’ve been having spurious issues.
The jumper seemed to do nothing - it seemed to work fine on 3.3V even when set to 5V. And all it does is change which pin is used from the main header.
If you only look at the schematic (as I did) then it looks as if the jumper does literally nothing at all:
I didn’t want vibration to work the jumper loose and turn off my encoder, so I desoldered the jumper and soldered 3v3 directly in place of the middle pin.
This work(ed) fine for months, but I am now having inexplicable problems, having changed nothing. But maybe the internal LDO regulator in the chip is actually producing 2.5V or so (with 3v3 connected to VDD5V) and not 3V, and this is causing it to lock out in an error state when it gets a little bit of noise from the ODrive. It might have been only just on the boundary of working before.
If you have to change the chip resistors I don’t see the point of having the jumper. It’s bizarre!
Update: Sadly this has made no difference to me so it wasn’t the source of my problem.
I moved the 0R resistor from position R1 to R2, but I have the same issue as I did before - the encoder works fine on boot, I can query the position, turn the motor by hand and the encoder reads as it should, and spi_error_rate is zero. But as soon as I enable the motor (even in torque mode with zero current setpoint) - it immediately drops to ERROR_ABS_SPI_COM_FAIL and spi_error_rate is 0.9997616410255432 (which is as close to 1 as it goes). This error will not go away with odrv.reboot() - I have to power cycle the encoder itself. It seems as if the encoder has a latched fault, and it is waiting for the drive to send the clear faults command.
Looking on the scope, there is a ringing oscillation seen on MOSI, at about 26MHz, about 2V pk-pk with a 3dB time of of about 500ns, when the motor is turned on. So It’s pretty clear that motor switching noise is causing spurious commands to be sent to the encoder, which drop it into the error state.
Zooming out on the scope, I can see there is one of these transients every 20.8us i.e. 48kHz, which sounds suspiciously like once every edge of the 24kHz switching cycle of the motor.
So my problem is just motor noise. But what perplexes me is that there has been no changes to this hardware since it was working perfectly. My motor wires have always been well twisted, and my encoder wiring has always been CAT5, with each of MOSI and MISO twisted with GND.
Also, there are no errors communicating with the DRV8301 chip, which shares the same MOSI/MISO lines.
Do you have both pins 5v and 3v3 (on as5047p board) connected to 3v3 (as per pdf manual)?
No, I have Pin 2 of JP1 connected to 3v3.
People have had trouble with this dev board when powering it from something that isn’t the ODrive. It sounds like everything is well grounded. Are you grounded to J3, or somewhere else?
Even if you supply As5047 with 3v3, 5v pin should also be connected to 3v3.
now Im having the same spi_error_rate related problem
(btw: the jumper together with R1/R2 resistors change the capacitor connection and shortcut/open VDD and VDD3V3, so actually i think they may change something )
when I power on the ODrive I usually get spr_error_rate 0.99…
(shielded signal cables 80cm long)
whenever I unplug encoder 3V cable from the ODrive and plug back again, the spi_error_rate slowly drops to 0.00000001111 something very small; than after clear_errors() I can use the ODrive.
Be careful with encoder MOSI pin.
I had it connected to ODrive MOSI and it looks like it was the problem.
Should be tied to 3V.
hmm… If it is tied to 3v instead of MOSI(ODrive) I cant run the full calib
Don’t forget to tie a TEST pin (as5047P eval board) to the GND.
I am also getting the ERROR_ABS_SPI_COM_FAIL and spi_error_rate is almost 1.
JP1 is selected to 3V3. R1 and R2 are already switched. Have no clue what the cause can be.
I think there’s a reason the AS5047P is a discontinued product…
No i tell a lie- it seems to be back in stock everywhere now. Maybe they have fixed it.
I have tried 3 different encoders which all worked perfectly a year ago, on my new ODrive board.
Each has exactly the same behaviour: spi_error_rate is between 0.5 and 1. In some positions, it will settle on 0.5, in others it will converge to 1.
My theory is that ODrive is polling them too fast, and the error flag that comes back might indicate that the ADC/Cordic had not converged in time. This would explain why certain positions read better than others.
This is without any power to the motor.
6 months ago, I had this issue but only when the motor was powered, above a certain power supply voltage.
It’s as if these chips are going bad over time, getting slower and slower, and becoming less tolerant of noise.
Has anyone contacted AMS about the issue?