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.
I have just started working on the CLA system. To validate if I have setup everything correctly for the CLA, I did some calculations using test vectors. The calculations were done on C28x processor and the CLA processor. It is observed that there is some error between the results obtained from both processors. To have a reference for comparison the same calculations were done in the excel sheet. The formula is as given below:
Dout =( ((Var1 - Var2)*(70/6.25))-Var3)/360; where var1,var2 and var3 are test vectors of 500 values each.
The C28x code implementation is as below:
D_C28[i]= (((Iref[i]-Iinv[i])*11.2)-Van[i])/360;
The same computation is performed in the CLA task as shown below:
Out1 =(((IBatt-V_batt)*(11.2))-Vbus)/360.0;
The CLA task is called 500 times from the main loop by passing values of IBatt (same as Iref),V_batt (same as Iinv)and Vbus (same as Van) defined in CPU to CLA message RAM. The output Out1 ,defined in CLA to CPU message RAM is read and stored in an array D_CLA[500] for comparing with D_C28[500].
The difference between the C28x and excel results is as below:
The difference between the CLA and excel results is as below:
The actual output as computed by excel is as below:
Apparently there is significant error in the CLA calculations. Please guide if I might be doing something incorrectly or if there is logical explanation to this error.
Note: I am using the CLAmath library: cla1_math_library_datarom_fpu32_eabi.lib & C2000Ware4.1.0.0. The processor options in the project are as below:
Hi Asad Hameed,
Can you please provide one set of sample values to replicate the issue at my end?
Regards,
Veena
Hi Veena Kamath,
Please refer to the table below. I have highlighted cases where CLA has shown significant error. Let me know if more information is required.
Sr.# | Iref | Iinv | Van | CLA Computed | Excel | CLA Diff. | C28 Computed | C28 Diff. |
1 | 0 | 0.109474182 | 5.527175903 | -0.018759126 | -0.01875913 | 4.04033E-09 | -0.01875913 | 2.40333E-10 |
2 | 0.001800537 | 0.242996216 | 11.06726074 | -0.038246252 | -0.038246257 | 4.90372E-09 | -0.038246255 | 1.10372E-09 |
3 | -0.033561707 | 0.401107788 | 16.59013367 | -0.05960675 | -0.059606756 | 5.98324E-09 | -0.059606753 | 2.28324E-09 |
4 | 0.36013794 | 0.572662354 | 22.11946106 | -0.068054803 | -0.068054818 | 1.53467E-08 | -0.068054818 | 4.46667E-10 |
5 | 0.955368042 | 0.736412048 | 27.62727356 | -0.069930449 | -0.069930462 | 1.32071E-08 | -0.069930464 | -1.69289E-09 |
6 | 1.555969238 | 0.880348206 | 33.13723755 | -0.071028553 | -0.071028561 | 8.17533E-09 | -0.07102856 | 6.75333E-10 |
7 | 2.03629303 | 0.999649048 | 38.62138367 | -0.075030468 | -0.075030475 | 6.79578E-09 | -0.075030476 | -7.04222E-10 |
8 | 2.345573425 | 1.096282959 | 44.1033783 | -0.083642565 | -0.08364257 | 4.96889E-09 | -0.083642565 | 4.96889E-09 |
9 | 2.484107971 | 1.174629211 | 49.55525208 | -0.09691412 | -0.096914139 | 1.88E-08 | -0.096914142 | -3.6E-09 |
10 | 2.496147156 | 1.240829468 | 55.00067139 | -0.13285768 | -0.113725315 | -0.019132365 | -0.113725312 | 2.67889E-09 |
11 | 2.423217773 | 1.299552917 | 60.41381836 | -0.152732983 | -0.1328577 | -0.019875283 | -0.132857695 | 4.92444E-09 |
12 | 2.32169342 | 1.35471344 | 65.8140564 | -0.152732983 | -0.152733002 | 1.87333E-08 | -0.152732998 | 3.73333E-09 |
13 | 2.222137451 | 1.407653809 | 71.17771912 | -0.172376364 | -0.172376395 | 3.136E-08 | -0.172376394 | 1.36E-09 |
14 | 2.140731812 | 1.459281921 | 76.52632141 | -0.191372424 | -0.191372452 | 2.77522E-08 | -0.191372439 | 1.27522E-08 |
15 | 2.077789307 | 1.509109497 | 81.83404541 | -0.209624499 | -0.209624532 | 3.305E-08 | -0.209624514 | 1.805E-08 |
16 | 2.039047241 | 1.55696106 | 87.12025452 | -0.227002442 | -0.22700247 | 2.82578E-08 | -0.227002457 | 1.32578E-08 |
17 | 2.020942688 | 1.601631165 | 92.36343384 | -0.243519828 | -0.243519847 | 1.86178E-08 | -0.243519843 | 3.61778E-09 |
18 | 2.010910034 | 1.642799377 | 97.58079529 | -0.259605408 | -0.259605433 | 2.51433E-08 | -0.259605408 | 2.51433E-08 |
19 | 1.995674133 | 1.67993927 | 102.7486725 | -0.275590092 | -0.275590117 | 2.47622E-08 | -0.275590092 | 2.47622E-08 |
20 | 1.983726501 | 1.713516235 | 107.8907318 | -0.291289896 | -0.291289936 | 3.96133E-08 | -0.291289926 | 9.61333E-09 |
21 | 1.969070435 | 1.742958069 | 112.9768524 | -0.306789935 | -0.306789983 | 4.80578E-08 | -0.306789994 | -1.09422E-08 |
22 | 1.945930481 | 1.769058228 | 118.0350037 | -0.322372288 | -0.322372318 | 2.99622E-08 | -0.322372288 | 2.99622E-08 |
23 | 1.916435242 | 1.791725159 | 123.0329132 | -0.353095263 | -0.337878223 | -0.01521704 | -0.337878227 | -4.02667E-09 |
24 | 1.89037323 | 1.81161499 | 127.9963989 | -0.353095263 | -0.353095296 | 3.31444E-08 | -0.353095293 | 3.14444E-09 |
25 | 1.863014221 | 1.828300476 | 132.8974915 | -0.368079692 | -0.368079715 | 2.34333E-08 | -0.368079722 | -6.56667E-09 |
26 | 1.836868286 | 1.842330933 | 137.7598572 | -0.382836163 | -0.382836219 | 5.60178E-08 | -0.382836223 | -3.98222E-09 |
27 | 1.807197571 | 1.853416443 | 142.5576782 | -0.397431403 | -0.397431471 | 6.80178E-08 | -0.397431463 | 8.01778E-09 |
28 | 1.776725769 | 1.862136841 | 147.310318 | -0.425944746 | -0.411852561 | -0.014092185 | -0.411852568 | -6.87111E-09 |
29 | 1.748214722 | 1.868202209 | 151.9962616 | -0.425944746 | -0.425944782 | 3.58178E-08 | -0.425944775 | 6.81778E-09 |
Hi,
I am unable to recreate the issue.
I added the following code in C28x -
float IBatt = 2.496147156; float V_batt = 1.240829468; float Vbus = 55.00067139; fVal = (((IBatt-V_batt)*(11.2))-Vbus)/360.0;
and following in CLA -
float IBatt = 2.496147156; float V_batt = 1.240829468; float Vbus = 55.00067139; fResult = (((IBatt-V_batt)*(11.2))-Vbus)/360.0;
Result -
There is only one difference between your test and mine. I passed the values to CLA using message RAMS instead of directly defining in the CLA. Let me try with your approach and compare results with passing through message RAM. The data was captured using the watch window of debug mode with XDS110 debug probe. I assume that it should not be an issue. Let me do this and then get back to you.
Hi Veena,
I have figured out the issue. It was an overlook at my end. I was updating values in the CLA Message RAMs and calling the CLA task back to back without waiting for the previous CLA task completion. Now I have added an exaggerated delay of around 10uSec between the two CLA task calls and the results match. Some results are shown below:
Sr.# | C28 | CLA |
1 | -0.01875913 | -0.018759126 |
2 | -0.038246255 | -0.038246252 |
3 | -0.059606753 | -0.05960675 |
4 | -0.068054818 | -0.068054803 |
5 | -0.069930464 | -0.069930449 |
6 | -0.07102856 | -0.071028553 |
7 | -0.075030476 | -0.075030468 |
8 | -0.083642565 | -0.083642565 |
9 | -0.096914142 | -0.09691412 |
10 | -0.113725312 | -0.113725305 |
11 | -0.132857695 | -0.13285768 |
12 | -0.152732998 | -0.152732983 |
13 | -0.172376394 | -0.172376364 |
14 | -0.191372439 | -0.191372424 |
15 | -0.209624514 | -0.209624499 |
16 | -0.227002457 | -0.227002442 |
17 | -0.243519843 | -0.243519828 |
18 | -0.259605408 | -0.259605408 |
19 | -0.275590092 | -0.275590092 |
20 | -0.291289926 | -0.291289896 |
There are some minor differences between the two results but I think that these are acceptable. Is it logical to expect exactly same outputs from both processors or some differences can be expected?. Otherwise we may close this thread if the results are fine.
Hi,
I just realized that I had used fp_mode = strict. Changing to relaxed to match your setting, I too see minor differences
You can find more details about this option in the compiler guide. It would be faster, but might affect the accuracy.
Regards,
Veena