Frank_and_Beans
Member
I am using this library, and it works well.
In my application, I am reading a quad encoder feedback from an electric motor. Since the encoder is naturally a differential measurement, it starts at zero on power up. However, I need it to start at some non zero quantity on startup.
Here is my setup:
const int c_Steering_Angle_Rev_Count = 42000;
//Encoder Setup
myEnc1.setInitConfig(); //
myEnc1.EncConfig.revolutionCountCondition = ENABLE;
myEnc1.EncConfig.enableModuloCountMode = ENABLE;
myEnc1.EncConfig.positionModulusValue = c_Steering_Angle_Rev_Count;
// with above settings count rev every 20 ticks
// if myEnc1.EncConfig.revolutionCountCondition = ENABLE;
// is not defined or set to DISABLE, the position is zeroed every
// 20 counts, if enabled revolution counter is incremented when
// phaseA ahead of phaseB, and decrements from 65535 when reversed.
myEnc1.EncConfig.positionInitialValue = 0;
myEnc1.EncConfig.filterCount = 0;
myEnc1.EncConfig.filterSamplePeriod = 6;
myEnc1.init();
I have an external Analog rotary potentiometer to use as an absolute position reference. So, I would like to read the Analog position - convert it to a number of revolutions and position counts, then set the appropriate registers.
So, I can set the positionInitialValue to the converted position counts,
myEnc1.EncConfig.positionInitialValue = reset_value;
But, how can I set the revolution counter to a value? I can't seem to find a function to do this. But, I'm also dumb. So there's that.
In my application, I am reading a quad encoder feedback from an electric motor. Since the encoder is naturally a differential measurement, it starts at zero on power up. However, I need it to start at some non zero quantity on startup.
Here is my setup:
const int c_Steering_Angle_Rev_Count = 42000;
//Encoder Setup
myEnc1.setInitConfig(); //
myEnc1.EncConfig.revolutionCountCondition = ENABLE;
myEnc1.EncConfig.enableModuloCountMode = ENABLE;
myEnc1.EncConfig.positionModulusValue = c_Steering_Angle_Rev_Count;
// with above settings count rev every 20 ticks
// if myEnc1.EncConfig.revolutionCountCondition = ENABLE;
// is not defined or set to DISABLE, the position is zeroed every
// 20 counts, if enabled revolution counter is incremented when
// phaseA ahead of phaseB, and decrements from 65535 when reversed.
myEnc1.EncConfig.positionInitialValue = 0;
myEnc1.EncConfig.filterCount = 0;
myEnc1.EncConfig.filterSamplePeriod = 6;
myEnc1.init();
I have an external Analog rotary potentiometer to use as an absolute position reference. So, I would like to read the Analog position - convert it to a number of revolutions and position counts, then set the appropriate registers.
So, I can set the positionInitialValue to the converted position counts,
myEnc1.EncConfig.positionInitialValue = reset_value;
But, how can I set the revolution counter to a value? I can't seem to find a function to do this. But, I'm also dumb. So there's that.