2022-06-21 01:21 AM
In the workbench (5.Y.3 MCSDK-FUL) there are two locations to set/calculate the OP-gain. One is located under "Analog Input and Protection" and one under "Current Sensing". In my configuration I use external resistors so set the gain of the OPAMP. I found out that if you set the gain using the "calculate" button under "Analog Input and Protection" by entering all the right resistor values, and then go to the "Current Sensing" menu, the gain showing there is the same that you entered in the Analog input section. Now I save the project under a new name as Configuration 1 and generate the code. When I check the source code I can find the gain is set to as 7.333 (power_stage_parameters.h). Now back in the workbench I change the resistor values under "Current sensing" menu using the "calculate" button, I set the gain to 1 and click on "confirm". Now the gain value is changed only there under "current sensing", but if I go to "Analog Input and Protection", the previous set gain value is still shown 7.333). Now I save the project under a new name (Configuration 2) and generate the code, and I look in the source code for the gain value, it is still set to the old value 7.333, but now in the drive_parameters.h all the PI-regulator and CORDIC parameters are changed and also the rev-up current values in s16A unit are different. Now the question is should you enter the gain values twice in both menus (are the two meant to be the same?) or will the software apply the gain twice for the current measurement? Because those two gain values seem to be independent of each other, and the value shown under current sensing seems to be used for current calculation, even if the field itself is "greyed out" (and therefore assumed to be inactive)
2022-06-28 07:25 AM
Hello,
Yes, there are two places where current sensing OpAmp gains can be calculate in the Workbench of MCSDK 5.x, but only one of them is used in any project (or so should it be...):
If "Amplification on Board" is checked in the Current Sensing dialog, then "Embedded PGA" is cleared in the Analog Input and Protection. And vice-versa. There is a bug here, since you should not be able to access the Calculate button on the Current Sensing dialog if "Amplification on Board" is not checked. This bug will not be fixed on MCSDK 5.x as this series of MCSDK will soon be discontinued in favor of MCSDK 6.x. MCSDK 6.0.0 already fixes this issue.
The PI parameters, CORDIC (and PLL) parameters and the current targets for the rev-up are being changed when the current measurement amplification gain is changed (if computed automatically) . This is because the amplification gain impacts the definition of how much amperes 1 s16A is. The trouble you face is that with the bug you experience, the gains you set in the Current Sensing dialog, even if not used, are propagated to the PIs, the CORDIC, the PLL and the rev-up resulting in their parameters being recomputed. To solve the issue (when it has occurred), you need to go back to the Analog Input and Protection dialog change the resistors, click confirm, change the resistors back and click confirm. This trick should do it.
Now, to avoid the issue, it is best to modify the gains where they are used: in the Analog Input and Protection dialog if you use the MCU embedded OpAmp, or in the Current Sensing dialog if you do not use MCU embedded OpAmps (then making sure that "Amplification on Board" is checked.
The UI is indeed quite confusing on that aspect. We are working towards enhancing this with the MCSDK 6.0 onwards.
I hope it will help.
Best Regards,
Fred
2022-06-28 11:40 PM
thank you for explaining the bug, but a part of my question is still unanswered. When I open the example file for EVSPIN32G4, under Analog Input and Protection, the gain is set to 7.33. When I check under Current Sensing the gain is also set to 7.33. Now is this the correct way to set up the gain? Should the gains on both settings windows be set to the same value? Are those meant to be the same? Or should I set the gain in the current sensing window to "1"? My problem is that somehow, on my custom PCB the OPAMPs are amplifying the shunt voltage by a factor of approx. 50 instead of only 7.33. It appears to me as if the gain is somehow applied twice (7.33 x 7.33 = 53) and I have no idea why. I already opened a seperate thread for this issue.
2022-06-30 12:42 AM
OK. I got it.
Only one of these gain will be used. And the one that will actually be used depends on the "Amplification on Board" checkbox (from the Current Sensing dialog) and on the "Embedded PGA" checkbox (from the Analog Input and Protection dialog). One (and only one) of these checkbox must be checked.
If Amplification on Board is checked, the gain is set on the Current Sensing Dialog.
If Embedded PGA is checked, the gain is set on the Analog Input and Protection Dialog.
You may notice that changing the gain on the Analog Input and Protection Dialog changes that of the Current Sensing Dialog. The reverse is not true. However, the gain that is used is indeed the one resulting from the criteria above.
This indeed does not explain why the gain you experience is approx. 50. For this, I have no clue.
Best Regards,
Fred