Hey, here’s a quick update.
So, it looks like my encoder is using a specific command to request a read that differs from the way AMS is doing it (sending a 0 or 1 on bit #14).
The command (send/receive) in the encoder.cpp is defined in the driver itself (stm32f4xx_hal_spi.c)
the function Encoder::abs_spi_start_transaction() in encoder.cpp has:
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive_DMA(hw_config_.spi, (uint8_t*)abs_spi_dma_tx_, (uint8_t*)abs_spi_dma_rx_, 1);
Right now I am trying to understand what is sent to the encoder to trigger a read. Here’s what I think:
hw_config_.spi contains config information on the SPI parameters, which I think may need to be changed for my encoder, not sure yet
(uint8_t*)abs_spi_dma_tx_ this one is really what I need to change. Right now it is defined in encoder.hpp as uint16_t abs_spi_dma_tx_[1] = {0xFFFF}; which was confusing me a little bit at first. But as it turns out per the AMS datasheet the command frame is a 16bit word where bit 15 is parity, 14 R/W (1 for read), and 13:0 as the address, in which case you are reading at the address 11 1111 1111 1111 (or 0x3FFF), so all together 0xFFFF makes total sense.
Next step, I will use a DUE to send my commands and see what the encoder is returning on the oscilloscope.
Aside from this “command” question, my encoder is also doing verification differently by sending a CRC. So it seems that there is no polarity to deal with. A bit odd.
Lastly, the position data is sent through 4x 8 bytes for MT followed by 4x 8 bytes for ST position. I have no need for MT information and will assume the ODrive doesn’t use MT anyway. So I’ll have to ignore those MT bytes and only focus on the ST bytes. I am hoping the F4 chip can read this amount of data without significant slowdown.
Also, random side question: does anyone know intellisense does not work for the board drivers files? It compiles fine, just unsure why it’s underlining all files with many errors. All of the firmware files are fine, it seems only the .c and .h inside the board/drivers folders are effected.
Cheers