simplefoc / Arduino-FOC-drivers

Drivers and support code for SimpleFOC
https://docs.simplefoc.com/drivers_library
MIT License
146 stars 63 forks source link

Added CPR configuration option to SC60228 Encoder #15

Open josephduchesne opened 2 years ago

josephduchesne commented 2 years ago

The SC60228 encoders that I have are reporting 2048 ticks rather than the expected 4096. This is probably an SPI register setting, but I can't find documentation on the chip's register map.

As a solution (interim maybe?) I'm proposing making the encoder ticks a parameter, placing it 2nd in the list since I suspect it's more likely to be overridden than the SPI settings.

runger1101001 commented 2 years ago

May I ask which MCU you are using? Could you try changing the SPI mode to see if it makes a difference? I recently noted a similar thing for the MT6701 sensor, where some MCU types read an extra bit at the start, and others do not...

runger1101001 commented 2 years ago

If we can figure out what's causing the problem and fix it, or at least figure out the MCU types that have it one way vs the ones that have it the other, we can fix it in the code and not make it up to the user... users will find it difficult otherwise.

josephduchesne commented 2 years ago

That's a good point. I'm using a STM32G031F8. I'll see if there's an SPI configuration option that helps.