Timestamping with RPICT

From lechacal
Jump to navigation Jump to search


This guide is for those with precise timing requirements.

Timing with the default firmware

RPICT computes power using Current/Voltage pair which we call CV pairs. The configuration defines these CV pairs for example (ct1 master, v1 master) or (ct1 slave, v1 master). Therefore the microcontroller has a list of CV pairs to compute and these are run one at a time.

Computing rms value or active Power is not instantaneous. We need to acquire a certain amount of analogue readings of the waveform before being able to compute the rms value with a good accuracy. Most signals being 50 or 60Hz we can determine the time it takes for one CV pair to complete. The parameter Ncycles in the config is the number of cycles used to compute rms or power. It is set to 20 by default. So the computing length for 50Hz is 20/50 = 0.4s. This is for a single CV pair.

Note there is a difference between a CV pair and a channel. A CV pair can generate several channels. realPower Irms Vrms PowerFactor are all channels produced by one single CV pair. Therefore it does not take more time to output realPower Vrms Irms and PowerFactor rather than just realPower only. In both cases this will take 0.4s.

If we have 7 CV pairs in the config (as with the RPICT7V1) then the total time to complete a full reading of all sensors is 7*0.4 = 2.8s. We call this the full scan interval. This can be considered the biggest timing error possible between the time when the data was sent on the serial port and the time when it was actually measured and computed by the RPICT board.

The debug mode can provide the scan interval. This useful for complex configurations. Just set debug=1 in teh config. Then use the cat command to see the output. The scan interval will be shown.

How can we reduce the full scan interval? The easiest way is to reduce the number of cycles. Changing it from 20 to 5 will reduce it by 4 fold. Becoming 0.7s in the above example. Now bare in mind data might become more jumpy. Think of this as being similar to an average. Averaging on a long timeframe yield more stable results than on a short timeframe.

Independently from the full scan interval the data output rate is set by the polling interval set in the config. This is set to 5 seconds by default. The polling interval is like a timer and command to output data stored in memory at regular intervals.