Good afternoon,
I am trying to implement some fault detection using the submenu “Protection” on PLECS Coder. After defining the analog input and the threshold, I moved to real tests. I used a Powerstage block to shut down all my PWMs when a fault is detected. I use a GBF on the analog input and raise the voltage close to the threshold. I measured the PWM output with an oscilloscope and I saw that the PWM is shut down before the ADC input reaches the fixed threshold.
I also display the voltage measured by the ADC and the result is the same: the Powerstage block is triggered before the input voltage reaches the protection threshold.
To give some context, I fixed my threshold to 1.5V. When my GBF reaches 1.45V, the Powerstage shuts down all the PWMs and the ADC measures a voltage of 1.45V and not the 1.5V fixed.
Is there a solution to solve this problem?
Hi Idumaslaussi!
What STM32 device are you working with? Are you using a Nucleo board or a custom PCB? Would you be able to attach a PLECS model to help me see if I can reproduce the difference on my system?
Given that the error of 0.05 [V] represents around 1.5 % of the full scale (3.3 [V]), my first inclination would be to attribute this difference to noise or offsets on the DAC voltage, the GBF voltage, the wires from the GBF to the STM32, the reference voltage, or a comparator offset error.
Hi Jeroen_Buitendijk,
Thank you for your response.
I am using a STM32G474VET6 on a custom PCB.
Please find the PLECS model in the attached file.
I made a new test this morning. I increased the fault threshold to 2V. When the GBF delivers 1.93V (approximately), the Powerstage block is triggered.
I displayed the ADC measurement on PLECS and verified that the measured voltage is the same as the delivered one. I suppose that the problem comes from the DAC comparator. Is there a hysteresis behavior? I don’t see any custom settings for the DAC on PLECS Coder.
Test_DAC.plecs (36.2 KB)
Thank you for providing the model file!
If the measurement using the ADC block is accurate, that would indicate that the issue is most likely not the supplied voltage or the 3.3 V rail on your custom board.
At this point in time there is no setting that you can toggle in the TSP (e.g. hysteresis) that would ameliorate the observed inaccuracy. I will add an issue to our internal development roadmap to investigate if we can improve the accuracy of the voltage at which the analog protection trips. Thank you for reporting this!