2018-04-24 3:36 AM
Hello to all,
I'm here to ask a question about the energy meter I've developed.
The problem concerns the 3P3W system (neutral line not available).
In this case i can measure two line to line voltages and the phase between them to reconstruct the ideal 3 vectors system(with a ideal phase of 120° between phases).
The main problem is that the alghorithm i developed is too slow on an stm32 M4 @80Mz: in a worst case it takes about 60ms to find the 3 vectors who generate the aquired two line to line voltage measurements and their phase displacement (with an
acceptable error)
.I searched a lot without founding a method to reconstruct 3P4W from a 3P3W system(unbalanced); the uniqe useful documents i've found is this one: Calculating Line-to-Line Voltages from Line-to-Neutral Measurements with the NI 9225 - National Instruments
and is the same method i developed to construct my slow algorithm(it does a convergence to find the solution to the problem)The question is: there's somewhere a relation or a library already developed than convert a DELTA three phase system to WYE ones just passing 2 vectors and the phase displacement?Thanks!2018-04-24 4:03 AM
The main problem is that the alghorithm i developed is too slow on an stm32 M4 @80Mz: in a worst case it takes about 60ms to find the 3 vectors who generate the aquired two line to line voltage measurements and their phase displacement (with an
acceptable error)
.What does this algorithm consist of ?
A Cortex M4 @ 80MHz can do an awful lot of stuff.
Do you use double variables ?
Do you use trigonometric functions (sin, cos), perhaps in double precision ?
2018-04-24 5:36 AM
This alghoritm simply scan an angle from 0 to INPUT_FI and calculate the three vetctor as described inthe nationalinstruments papes; then search for that computation that has a minimum error (error related to the two argument passed, the two know data voltage magnitude of line-to-line voltage)
I use float varialble
There are multiple trigonometric functions for each cycle(and there are hundreds of cycles): 3 tan, several sqrt, sums divisions and multiply operations.
Thanks
2018-04-24 7:47 AM
I would suggest to investigate where exactly most runtime is spent.
Either with profiling support of your toolchain, or with GPIO pins and a scope.
I use float varialble
And have all floating point literals a size specifier ('f') ?
... several sqrt, sums divisions and multiply operations.
This is native supported by the FPU (double-check you actually use the FPU ...).
There are multiple trigonometric functions for each cycle ... : 3 tan ...
These are not.
A customized lookup table approach would speed up calculations.
For comparision: an optimized float CFFT, using ARMs DSP library, achieves 5ms for a blocksize of 2048.
2018-04-25 6:48 AM
Hi,
i will try within few days to compare the speed after a lookup table implementation of the tangent function.
Thanks!
2018-04-25 9:17 AM
Don't know your code, but try not to fix a problem that doesn't exist.
I mean, make sure to first identify where most of the time is really spent.