The Fourier series coefficients a0, a1, and b1 are calculated by integrating over at least one full period. In real-time applications, the output using these coefficients (a0, a1, and b1) must be delayed by one period (a one-period delay). The integrator must be reset at the start of each period, and the coefficients should only be calculated and used at the end of each period.
Your current setup suggests you have some confusion about how the mathematics should work. The simplest solution might be to write a DLL block with C code for this task. I tested a code that can implement this idea. However, note that output is delayed by one cycle, as a0, a1, and b1 are only available after one full cycle of integration.
example.Fourier.qsch (3.4 KB)
fourier.cpp (5.5 KB)