Possibility/Workaround to Increase Analog Comparator Hysteresis

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possibility/Workaround to Increase Analog Comparator Hysteresis

1,059 Views
arun07
Contributor III

Hello Everyone,

I am using the MKE15Z256 microcontroller and using the Analog Comparator module to do some logic checks and calculations on an external signal, which is a half sinusoidal signal, and I can successfully use it, but under a noisy environment, the situation of this calculation is very bad.

Is it possible or some way or workaround to increase the Hysteresis of the Analog Comparator, so that I can configure it for at least 0.5V instead of a few millivolts?

At the moment I am using Hysteresis 3 which means 33mV for Low-Speed Mode.

Hyst-1.PNG

Hyst-2.PNG

My problem can be depicted as shown in the below image, since the hysteresis value is very less, I am getting a lot of glitches in a noisy environment as shown in the left side image.

I have used the "acmp_interrupt" example as a base for my project.

Problem.PNG

Let me know if there is a way to solve or further improve this situation. Thanks in advance.

0 Kudos
2 Replies

1,048 Views
troelsoesteraa
Contributor III

Hi,

Sometimes it is the easiest just to make an external comparator with an opamp and use a GPIO.

However, since the MKE15Z256 seems to have two comparators built in, you can configure one (CMP0) that acts on rising edge with a high reference voltage. The other (CMP1) you can configure to act on falling edge with a reference voltage 0.5V lower than the other comparator.

In the ISR for CMP0, you disable CMP0 and enable CMP1. In CMP1 ISR you disable CMP1 and enable CMP0. I'd give both CMP0 and CMP1 the same interrupt priorities.

Hope it helps.

 

Kind regards,

Troels

1,043 Views
arun07
Contributor III

Hi @troelsoesteraa 

Thank You for your response.

Actually in our old designs we have used the external comparator using opamp and things were just fine, but to save few more cents, we thought to use the internal comparator of MKE15Z, as technically they both looks same.

Regarding the second suggestion of using two comparator, maybe in future I will try this, but as of now this not possible. (Reason is that we have two variants and another variant of this product uses the MKE15Z64, which only has one comparator, plus hardware change is also not possible at this moment)

So I understand that it is not possible to increase the hysteresis. In the past I tried to follow the following approach.

  • At initialization configure the Comparator module for interrupt on rising edge when input voltage is greater than 1.0 V (from DAC)
  • When I received the rising interrupt, reconfigure the module to generate falling edge interrupt, when voltage is greater than 0.5V (from DAC)
  • When I received the falling edge interrupt, reconfigure the module to generate rising edge interrupt when DAC input voltage is greater than 1.0 (from DAC)
  • And Repeat these steps

More information is available in the below post.

https://community.nxp.com/t5/Kinetis-Microcontrollers/Setting-Different-DAC-Voltage-Level-for-Rising...

This method works really well in noisy environment, but in normal environment there is some problem at some point of time, maybe due to re-configuring, but I couldn't figure out what exactly it is.

If you have any other suggestions, please let me know.

I will also try to create a separate project, and try to share here. Thanks in advance.

0 Kudos