RobTillaart / AS5600

Arduino library for AS5600 magnetic rotation meter
MIT License
109 stars 20 forks source link

Hardwired direction pin not used #59

Closed LukeSkaff closed 8 months ago

LukeSkaff commented 8 months ago

Thanks for making this great library. I have a hardwired pullup on the direction pin on my AS5600 circuit board and I am setting the direction in the code to "AS5600_COUNTERCLOCK_WISE" to let the AS5600 code know. There is no direction output from the Arduino to the AS5600 circuit board though. There does not appear to be a way not to assign a direction output pin in the code, it looks like you have to use a direction pin. Is there anyway around this?

RobTillaart commented 8 months ago

Thanks for the issue Might take a few days before I have time to dive into your question.

RobTillaart commented 8 months ago

There does not appear to be a way not to assign a direction output pin in the code, it looks like you have to use a direction pin. Is there anyway around this?

You should pass the direction pin in begin()

From the readme.md


DIR pin

From datasheet, page 30 - Direction (clockwise vs. counter-clockwise)

The AS5600 allows controlling the direction of the magnet rotation with the DIR pin. If DIR is connected to GND (DIR = 0) a clockwise rotation viewed from the top will generate an increment of the calculated angle. If the DIR pin is connected to VDD (DIR = 1) an increment of the calculated angle will happen with counter-clockwise rotation.

This AS5600 library offers a 3rd option for the DIR (direction) pin of the sensor:

  1. Connect to GND ==> fixed clockwise(*). This is the default.
  2. Connect to VCC ==> fixed counter-clockwise.
  3. Connect to an IO pin of the processor == Hardware Direction Control by library.

In the 3rd configuration the library controls the direction of counting by initializing this pin in begin(directionPin), followed by setDirection(direction). For the parameter direction the library defines two constants named:

(*) if begin() is called without directionPin or with this parameter set to 255, Software Direction Control is enabled.

See Software Direction Control below for more information.


LukeSkaff commented 8 months ago

Thank you, sorry I missed that.

RobTillaart commented 8 months ago

No problem