bgkatz / motorcontrol

motor controller firmware
MIT License
242 stars 102 forks source link

why send 0x00 to get position sensor angle #12

Closed Apex-yuan closed 2 years ago

Apex-yuan commented 2 years ago
`
   #define ENC_READ_WORD    0x00                // Encoder read command

   /* SPI read/write */
encoder->spi_tx_word = ENC_READ_WORD;
HAL_GPIO_WritePin(ENC_CS, GPIO_PIN_RESET );     // CS low
HAL_SPI_TransmitReceive(&ENC_SPI, (uint8_t*)encoder->spi_tx_buff, (uint8_t *)encoder->spi_rx_buff, 1, 100);
while( ENC_SPI.State == HAL_SPI_STATE_BUSY );                   // wait for transmission complete
HAL_GPIO_WritePin(ENC_CS, GPIO_PIN_SET );   // CS high
encoder->raw = encoder ->spi_rx_word;

` I have a question: if you want to get the Angle,shouldn't send 0xFFFF,and get the value &0x3FFF.Why send 0x00 here to get the Angle

bgkatz commented 2 years ago

For the MA702 encoder this is set up for you write 0's to read the encoder angle. See page 13: https://www.monolithicpower.com/en/documentview/productdocument/index/version/2/document_type/Datasheet/lang/en/sku/MA702GQ-Z/document_id/3561/ image