Closed mjones7947 closed 7 years ago
Hi Matt,
So currently, this library doesn't use the angle sensors built in zero position - largely because it allows us to be more flexible.
So the getRotation
function returns a relative angle to 0 (signed int, +/-180 degrees) which is useful if you're making a PID system (as I was when I made this).
If that's not what you're after, you need to set the zero position in the device and get the raw angle from the device. I suggest:
getRawRotation()
method instead - this will return exactly what the sensor sends overLet me know how you get on!
Ben
MY HERO!! DutchMillbt too! Thanks. Looks like I'll have to mess with the getRotation as well I see now your swinging between -180 and 180. I'm just shooting to get 0 - 359. I'll keep ya up to date. Thanks Again Matt
You can use getRawRotation
to get the 0-360 (in 0x000-0x3FF form) without modification
Ya thats what I started with but then to set zero you have to burn in zero or build to factory zero. I just want to soft set zero to align to the machine as the machine may change position slightly over iterations of the build. You've got a real good starting point here its why I chose the sensor.
Thanks Matt
Nothing personal just buisness... So further study I finally got a clear picture of the whole thing. Setting the ZeroPosition bit on the sensor is kinda worthless even with DutchMillbt's option. It doesn't appear the sensor will respond to that in its angle setup, It really has to be burned in to be anything other than something to do. Buts thats all OK since you already have a method (I don't know what to call it in C++) wrote. Seems it could be used to call get raw rotation ( AS5048A angle) Set a variable then in GetRotation just subtract that initial value. So the one thing I have question about is if I change this thing significantly should I submit a branch. I have never used github, programming is just not my forte but I have to do it this time. Any suggestion on how this stuff works and the protocol for it would be appreciated.
Thanks Matt
@mjones7947 I completely forgot to reply to this, sorry! I know it was over a year ago, but I hope you got things worked out!
I am trying to use the setZeroPosition function. I want to reset the position at startup to 0 before start up. The code I am trying to use is:
word set = angleSensor.getRotation(); angleSensor.setZeroPosition(set);
Not sure if thats right, it doesn't work. Looking at the Data sheet it says:
Can't see where that is happening.. Any help and your my hero. Thanks Matt