Other Parts Discussed in Thread: C2000WARE, SFRA
Hi,
Bit of a confusing one, but I was wondering why a digital control library function such as that to run a 2P2Z controller might output a negative value, especially if the error input is positive.
I have tried changing the coefficients many times and still I will often get a significant negative voltage returned after calling the function, rendering the controller pretty much useless. Here is a screenshot:

Even with zero volts input to the ADC pin that measures the voltage for the error calculation, the function can very often return negative float values. Is this just a coefficient issue?
If I place a very small gain, KDC (I am using the C2000Ware compensation designer), the voltage output can be positive, but very small. Then, as I increase the KDC gain, there comes a point where the output from the function returns negative. It is very frustrating as you would think increasing the gain would just increase the controller output, not make it negative.
I have wrote this code essentially from a DCL library example and did the exact same functions.
Can anyone suggest a reason why this might be happening, and a possible fix?
EDIT: I noticed in the DCL Users Guide, the following:
Step 3. Allocate the controller functions in the linker command file DCL functions which run on the FPU32 or C28x core can be allocated to a specific memory block in the linker command file. It is common to place the controller functions in zero wait-state internal RAM since this allows them to run at the maximum speed of the device. Note that all CLA functions must run from internal zero wait-state RAM. All DCL library functions are placed in the user defined code section .dclfuncs. An example showing how this section might be mapped into the internal L4 RAM memory block is shown below. dclfuncs : > RAML4, PAGE = 0 See also the linker command file F28069_DCL.cmd in the project examples (chapter 5). In a stand-alone application, code must be stored in non-volatile memory (such as internal flash) and copied into RAM at run-time. For information on how to do this, refer to the Using the Digital Control Library 20 application note “Running an Application from Internal Flash Memory on the TMS320F28xxx DSP”, TI literature number SPRA958. Information on linker section allocation can be found in the “TMS320C28x Assembly Language Tools User’s Guide”.
I am not sure if I have done this - if I haven't done the above step, would the controller code even run at all?
If the code was able to run without the above, could it cause significant issues with the results of the controller output?
It seems to be running OK - but I am not sure how fast it is executing and how accurate the controller output results I am being showed are: it would be a great help if someone was able to email me the F28069_DCL.cmd file to my email: j.holland3@newcastle.ac.uk - as I am still having the issue that the C2000Ware folders do not have any project properties and none of them include command files, either. I think this could solve my problem.
Best regards,
Joel





