Is it possible to initialize a sensor output to a non-zero position?

Having gone through previous posts, I cannot find the answer to my specific need. I am using an Orbis magnetic encoder and the position control is working perfectly. Some part of the SImpleFOC code must keep track of the number of rotations past 2pi - so when I command the motor to move say 31.4, it will rotate 5 rotations. This is the behavior I want ! However I want to save this “integrated” value and at initialization it should startup at 31.4 if I have not sent the motor a new command. I can use the EEPROM to keep the old value - but I cannot figure out how to load that offset into the sensor output - the sensor code I wrote does not keep track of rotations (it’s 14 bits) - So in summary I want to preload whatever integrated value is managed by the sensor code and then set the target to that value at startup ( I did try motor.sensor_offset, that doesn’t seem to do what I want). Thank you !!!

I do see a potential way to solve this by adding a function to set the full_rotations variable in the sensor base class function

UPDATE ! I did modify the sensor.cpp/sensor.h files to add a function to set the integer number of rotations and this works well - I’d love this to make it back into the baseline - all it does is set the value of full_rotations. In my code I read this value, multiply it by 2pi and then add the current sensor angle and then save it to the target at startup. The Orbis is an absolute encoder so as long as I keep track of the number of rotations it will be correct at startup.

1 Like