Open rpv-tomsk opened 4 days ago
I will need to... think about it. I am not the author of that division for BL0937. Would it be possible to somehow... make an experiment to verify which version is correct? Hm, I could try ticking drivers every 2 seconds, not 1.... and then see..
I don't think experiment is needed, because of clear principle of work: the frequency is proportional to the value. More the value - more pulses per fixed unit of time. Pure math.
Hm, I could try ticking drivers every 2 seconds, not 1.... and then see..
Yes, that should produce 4x greater measurement. 2x - twice the counted pulses and 2x - from ticksElapsed
.
But correct implementation should leave result unchanged and independent from ticks period.
Another issue is overall 'ticks correction' / PwrCal_Scale()
design. We have to use current/voltage measurement unchanged from previous cycle, but implementation does correction for all (Voltage and Current) values. Due to ticksElapsed
mismatch between cycles, that produces additional error in measurement. This is hard to fix due to PwrCal_Scale()
always called for all three values, while we need to leave one of final_v
or final_c
left untouched. To solve this we need to have separated PwrCal_ScaleVoltage
, PwrCal_ScaleCurrent
and PwrCal_ScalePower
.
value = pulses / time
More pulses for same time - bigger value. More time for same pulses count - smaller value. Twice more pulses for twice time - same value.
ticksElapased tick_period == elapsed time in ms ticksElapased tick_period / 1000 == elapsed time in s
final = final expected_time / elapsed_time; //expected time is 1 second. final = final expected_ticks / elapsed_ticks; //expected ticks for 1 second: (1000.0ms / portTICK_PERIOD_MS)
Closes: #1270