Timestamping with RPICT: Difference between revisions
No edit summary |
|||
Line 12: | Line 12: | ||
[[File:Wavaform.png | 400px]] | [[File:Wavaform.png | 400px]] | ||
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 | 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 together rather than just realPower alone. 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. | 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. | ||
Line 22: | Line 22: | ||
* Remove unused CV pair from the configuration. If you are using only 3 CT on a RPICT7V1 then it might be better removing the unused CV pair to optimise the full scan interval. | * Remove unused CV pair from the configuration. If you are using only 3 CT on a RPICT7V1 then it might be better removing the unused CV pair to optimise the full scan interval. | ||
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. | '''Polling interval'''. 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. | ||
==Using a sketch with timestamping== | ==Using a sketch with timestamping== | ||
If a more strict timing requirement is needed then we recommend to write an Arduino sketch using timestamping. We will show an example how to perform this below. | If a more strict timing requirement is needed then we recommend to write an Arduino sketch using timestamping. We will show an example how to perform this below. |
Revision as of 17:25, 12 November 2020
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 together rather than just realPower alone. 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 is useful for complex configurations. Just set debug=1 in the 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 with ncycle=5. Think of this as being similar to an average. Averaging on a long timeframe yield more stable results than on a short timeframe. The value of the right ncycle should be evaluated by the user.
- Remove unused CV pair from the configuration. If you are using only 3 CT on a RPICT7V1 then it might be better removing the unused CV pair to optimise the full scan interval.
Polling interval. 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.
Using a sketch with timestamping
If a more strict timing requirement is needed then we recommend to write an Arduino sketch using timestamping. We will show an example how to perform this below.