PSoC 5LP PID Control

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
CaDu_3933941
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hello,

I am somewhat new to PSoC and I am working on my senior thesis for which my part of the project is to design a DC-AC Converter. I am currently using a PSoC 5LP to generate my control signal using the top design in the figure below.

pastedImage_0.png

The top DAC generates a 60 Hz sine wave. For my next step, I want to implement some sort of feedback control for which I need to subtract the reference sine wave from the measured one and pass it through a PI controller.

I am planning on implementing the PI algorithm in C code so my question is: Is there a way I could read the output of the DAC and store in it a variable in my code so thatg i can implement the rest of the PI Algorithm?

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

molinac5,

The WaveDAC is essentially a VDAC8 component with DMA support. It is possible to read VDAC8 data back from the destination pointer VDAC8_Data_PTR. See the VDAC8_SetValue() API implementation. But....

From your description of the project I assume that the goal is to adjust the amplitude of the second sine wave to match the reference signal, assuming that both waves have same frequency, phase, shape and offset (correct me if I am wrong). This can be done differently simply by reading analog values from DAC_1 and DAC_2 by sequential SAR_ADC and processing data in code. The 60Hz wave is slow enough to do it by PSoC CPU. To further simplify the task, you can sample amplitude value only at the peak/valley of the reference and synthesized waves. For that you would need to lock on the reference wave phase and derive a quadrature signal for ADC.  This can be easily accomplished in PSoC using Phase Locked Loop (PLL), which will produce both sync and high-frequency sampling clock for WaveDAC_2

custom Phase-Locked Loop (PLL) implementation using PSoC5

Note that on your schematic all information about the amplitude difference is being lost as soon it goes through comparator. At this point the PID control is no longer applicable (at least the traditional one), as PID  require knowledge of signal deviation (V1-V2) for further processing. Since you have only 1-bit digital info available from the comparator (>,<), the PID will never settle (this is like a cheap house thermostat with on/off action, which either overshoots or undersoots the set temperature, but never stay on target).

There are other methods for 1-bit digital control, e.g. fuzzy logic or "take-back-half", which don't give same accuracy and speed as PID.

https://www.edn.com/design/sensors/4460914/Generate-proportional-feedback-from-a-bang-bang-sensor-wi...

/odissey1

View solution in original post

0 Likes
4 Replies