Op-amp in my circuit is accepting differential sinusoidal signal, that swings around 0 V with 1 Vpp. It is configured as a comparator - swings to upper rail when the signal is positive and swing to lower rail when negative, effectively converting sine to square. Square wave pulses are then counted by uC.

However, differential output from my incremental rotary encoder swings around 2.5V.

rotary encoder voltage output

What is a good way to solve this problem? Note that there is one unused channel in an op-amp, but I am not sure if it can help. Thank you

  • 1
    Why not use a comparator (referenced to 2.5V)? It's not clear to me what the relevance of the op-amp is... (and op-amps generally make bad comparators). – uint128_t Sep 4 '17 at 5:31
  • Hello, thanks for a tip. However, I need to have it done in around 8 hours or less. I have comparator LM293 and a TVL341 reference at hand, but have no idea how to connect them together with a differential signal. – delmadord Sep 4 '17 at 9:26
  • In such case just connect the positive side to your input of the MCU. It's not nice, but will work, and is the best you can do in 8 hours – Gregory Kornblum Apr 13 at 15:59

Use one opamp as a differential to single-ended converter and then use a comparator (or schmitt trigger) to convert to a square wave. Using an opamp as a comparator is a recipe for trouble, any noise on the signal (and there is always noise) will cause rapid switching of the opamp output as the analog signal transitions across the threshold. Comparators and schmitt triggers have built-in hysteresis which creates a margin between the turn-on threshold and the turn-off threshold. Schmitt triggers often do not have programmable thresholds, but you can manipulate the gain of the differential to single ended conversion to move the signal to the threshold value for your selected Schmitt trigger. As long as this margin is greater than the maximum amount of noise in your system you get a clean square wave on the output.

If you have an ADC on the microcontroller with a differential input (and it is fast enough to sample the signal), you might be able to configure the ADC to operate on two pins as differential input and eliminate the opamp all together. If you do this, you will have to implement hysteresis or pulse width filtering in software. Even without differential inputs on the ADC, you might be able to sample the signal using two channels and simultaneous sampling on the ADC (if available) and just subtract the values.

  1. Use differential input, this is what the signal is differential.
  2. Instead a comparator, take diff receiver, like 26lv32
  3. For analog encoder you can get a very high resolution, so you can use adc

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.