This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
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
Joel,
The DCL examples uses the array to log the input / output of the controller for evaluation reason. If you look at the F28069_DF22 example, the u1k and u2k are the control effort output variable, which are both floating point variable.
To convert the control effort to ePWM compactor value for a uni-polar DCDC control effort output, you will need to scale it to 0-1 range and multiple it by the TBPRD setting of the ePWM. This way the control output are scaled to 0% to 100% of control effort.
Han
Hi Han,
Thanks for your reply - what would be the best way to scale to 0-1?
My confusion is that, as you say, the control effort is a float. If we simply bound this float to be between 0 and 1, can we multiply this by the TBPRD register which is not a float, without any issue?
Thanks,
Joel
Joel,
As you mentioned earlier, you will normally saturate the control effort output. One common solution is to saturate the controller output to 0-1 directly. If you want to saturate control effort at different value (say n), then you can multiple the output of controller by 1/n afterwards, to scale it down to 0-1.
Han