cancel
Showing results for 
Search instead for 
Did you mean: 

Using comparators and a high speed emulated/virtual SR latch - STM32F334xx

Tim VanderMey
Associate II

I want to use two internal comparators to monitor current in a circuit.  When the current gets above a level I want to turn off my switch, when the current falls below a level I want to turn on the switch.  This needs to be done at a speed that is too fast and precise for software to handle (the off time can be as little as ~1uS and must have high resolution and minimal (nS) delay).  I could use an external SR latch that is reset by the high current level comparator and set by the low current level comparator (I have done this in simulations and it works well), but I was wondering if there was a way to emulate a fast SR latch using the internal hardware, like perhaps using timer compare hardware or something similar.  The processor I am currently looking at is the  STM32F334xx.  Any suggestions would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Bob S
Principal

DIsclaimer - I am not familiar with the F3xx comparators.  My answer presumes they are similar to the L4xx and G4xx comparators

If you connect the minus input to external circuitry you can implement your own hysteresis so that when the plus input goes above the "turn off" threshold it changes the ref voltage on the minus input to make it correspond to the "turn on" threshold.

View solution in original post

3 REPLIES 3
Bob S
Principal

DIsclaimer - I am not familiar with the F3xx comparators.  My answer presumes they are similar to the L4xx and G4xx comparators

If you connect the minus input to external circuitry you can implement your own hysteresis so that when the plus input goes above the "turn off" threshold it changes the ref voltage on the minus input to make it correspond to the "turn on" threshold.

Hi Bob,

Thanks for the suggestion.  What I failed to include in my description was that I was planning to set the threshold for each comparator with an on board DAC (one DAC for each comparator).  That will give me independent control over peak current and minimum current, which need to be varied.  I still might make it work with your solution, but it means the levels are not independent, and I would prefer they be independent.  Sorry for the scant description, and thanks for the suggestion.

Tim

Tim VanderMey
Associate II

Bob,

I decided I could live with a constant current delta and went with your simplified single comparator with hysteresis concept.

Thanks,

Tim