cancel
Showing results for 
Search instead for 
Did you mean: 

Comparator with PWM

waaizkhan
Associate III

In my setup, I’m using Comparator 6 (COMP6) on the STM32G474 microcontroller. The non-inverting input of the comparator is connected to a burden resistor from a current transformer, which measures current flow. The inverting input is tied to a fixed 1.5V reference created by a voltage divider. The goal is for the comparator to disable all PWM signals (generated by HRTIM TimerA) when the burden resistor voltage reaches 1.5V, indicating an overcurrent condition (e.g., 10A).

Issue: Despite the burden resistor voltage hitting 1.5V at 10A, the comparator does not trigger, and the PWM remains active.

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks Andrew , 
I initially misinterpreted the readings, but after carefully rechecking, I confirmed that the current does not exceed 10A.
and my comparator work perfectly.

View solution in original post

7 REPLIES 7

You expect the PWM to be disabled when this voltage reaches 1.5V ?

So, if the voltage is only reaching 1.4V, then you would not expect the PWM to stop.

Your system seems to be operating as expected ?

Apologies for the typing mistake—it should be 1.5V, not 1.4V. Even when the current exceeds 1.5V, the PWM does not disable.


@waaizkhan wrote:

Even when the current exceeds 1.5V, the PWM does not disable.


Have you confirmed if that's because the Comparator doesn't trigger, or your code doesn't act on the trigger?

Have you used the debugger to see what's going on?

and/or added printfs or similar?

Yes, I checked, and it's triggering, as you can see in the pictures.

So look at why your code isn't acting on that ...

Thanks Andrew , 
I initially misinterpreted the readings, but after carefully rechecking, I confirmed that the current does not exceed 10A.
and my comparator work perfectly.

So if it's now all working fine, please mark the solution - see:

https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256