will not scale entire waveform, it will merely sets an instant single value to the internal VDAC8, which is getting overritten by the next DMA transfer.
Please check this thread for simiar issue and possible solution in #4.
All of it can be fine excercize, but in the end you don't need analog output for AC generation. Instead you need a PWM output. That would be a waste of hardware resouces and source of errors to produce PWM from two analog waves and a comparator.
To produce sinusoidally-modulated PWM output, just substitute VDAC8 with PWM in the above example (#4).
I understand the PWM part. We already got the AC generation done, all I am trying to implement now is PI controller where the feedback is subtracted from a set value and then multiplied with a sine wave which then changes the amplitude, hence changing the amplitude of the fundamental frequency. An overall schematic can be seen on SIMULINK of system as a whole as well as the inner PSoC works.
As you can see, the output is turned into an RMS value and then the subtracted from the set RMS and passed through a PI controller. The Output of the controller is then multiplied with the sine wave which I am generating using the WaveDAC. My goal is to set the sampled RMS value (Some DC value scaled down to below 5 V) equal to some variable RMS_In or something. This will then be passed through a PI controller and the output of the controller will be multiplied. The purpose of this was to try to understand if whether it was possible to multiply two sampled values together.
I understand that the instantaneous value of the sine wave gets multiplied with the DC which means it should change every time right?
My problem is that whenever I get the output, it looks like a distorted sine wave and not a scaled sine wave like I imagined it would.
The Simulink modeling is surely helpful for understanding the invertor's operation and brings some luster to the capstone delivery. PSoC hardware, on the other hand, allows for direct control of the bridge FETs without involvement of analog sine generation and multiplication. Attached below is a project demo showing PWM modulation by 60Hz sine, utilizing DMA transfer of the wave from RAM buffer to PWM, which can directly control the H-bridge. No voltage multiplication inlolved.
Attached is a project archive and output screenshots taken at various sine amplitudes.
Fig. 1. PWM unfiltered output, sine amplitude 255, 60Hz, 32 points/period. Yellow trace - PWM, Fuchsia - DMA_nrq
Fig. 2. PWM output filtered thru RC circuit, sine amplitude 255, 60Hz, 32 points/period
Fig. 3. PWM output filtered by RC circuit, sine amplitude 0, 60Hz, 32 points/period
So now, say I choose to use this method, is there a way I could still use the PID control using this scheme after all?
This approach implements entire PWM control shown on your Simulink bottom page using PSoC specific hardware. You still have to come up with RMS measurement and PID feedback code.
In this demo PWM output is updated 32 times per period, providing hardware signal "tc", which can be used to strobe ADC_SAR 32 times per period and calculate RMS, and another output "nrq" and interrupt, signaling the end of period, when amplitude of the Sine wave can be updated using PID algorithm.
You still have to work out connection to H-bridge using PWM outputs ph1 and ph2, and to tune timing parameters. Typical power H-bridge frequency response cutoff is below 100kHz (and as low as 20kHz), while clock_1 in the demo is set to operate at ~500 kHz to provide 32 updates at 8-bit resolution each:
clock_1 = 32 x 256 x 60Hz = 491.52 kHz
This is too high for real application, as H-bridge won't respond correctly to short pulses, so you have to come up with some solution to lower It down. For example, using 8 samples per period, or using 6-bit PWM, etc., depending on whether you are going to build an actual device.