Skip to content

Commit 98edcc5

Browse files
committed
due variable size issue
1 parent e174615 commit 98edcc5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/encoders/calibrated/CalibratedSensor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ float CalibratedSensor::getSensorAngle()
5656
// This filter has zero gain at electrical frequency and all integer multiples
5757
// So cogging effects should be completely filtered out
5858
void CalibratedSensor::filter_error(float* error, float &error_mean, int n_ticks, int window){
59-
float window_buffer[window] = {0.0};
59+
float window_buffer[window];
60+
memset(window_buffer, 0, window*sizeof(float));
6061
float window_sum = 0;
6162
int buffer_index = 0;
6263
// fill the inital window buffer
@@ -116,7 +117,8 @@ void CalibratedSensor::calibrate(FOCMotor &motor, float* lut, float zero_electri
116117
const int n_ticks = n_pos * _NPP; // number of positions to be sampled per mechanical rotation. Multiple of NPP for filtering reasons (see later)
117118
const int n2_ticks = 5; // increments between saved samples (for smoothing motion)
118119
float deltaElectricalAngle = _2PI * _NPP / (n_ticks * n2_ticks); // Electrical Angle increments for calibration steps
119-
float error[n_ticks] = {0.0}; // pointer to error array (average of forward & backward)
120+
float error[n_ticks]; // pointer to error array (average of forward & backward)
121+
memset(error, 0, n_ticks*sizeof(float));
120122
// The fileter window size is set to n_pos - one electrical cycle
121123
// important for cogging filtering !!!
122124
const int window = n_pos; // window size for moving average filter of raw error

0 commit comments

Comments
 (0)