Hi!
Hope you are all doing well. Got quite a few confusions I would very much appreciate being cleared up for my code!
I have now got to a point in my code where I have coded my CLA to return a control effort from a 2p2z controller with pre-computation to my CPU.
It is my understanding that calling a DCL function returns a float (assumption, because clamp limits are always set as float values!)
What is the best way to take this value and then modulate the PWM registers with, by placing the value into the CMPA register? I believe these registers take uint_16t, is there an efficient way to convert floats to unsigned 16-bit integers?
It seems in all of the examples, a set of arrays are filled with the full, partial and difference results between the two in floating point form.
Why is the data length large in all of the DCL examples, such as 1601? Is it not a fact that with a 2P2Z result you only need the memory of about 3-4 of the previous results? Why are the arrays defined so large to compute the next result?
Once the full and partial results are computed, the program will then compute the "difference" between them. Is this "difference" the same as the control result, thus we should use the "difference" array, to compute our next duty cycle, frequency or phase?
Finally, if we do need such a large array, which part of it do we use to compute the actual frequency, duty cycle or phase of the PWM signals? If there are 1601 data points in the array, do we always use the most recent result to modulate the PWM registers?
Thanks in advance,
Joel