# Conditioning current pulse signals

There is an instrument outputting pwm-like current pulse trains proportional to its rotation speed. I convert the output current pulses to voltage pulses by a shunt resistor to be read by a DAQ hardware. Pulses are sampled with 12kHz. The software detects the rising edges and calculates the frequency for each pulse. Above on the left figure is what I see from the output of the instrument. P is the period, T is the pulse duration. Whatever the rotational speed the pulse duration T remains the same around 80us-120us(between 80 and 120 microseconds). Period P can be between 330us up to 2000us.

I have two questions:

1- As shown in the right side of the above figure, I want to convert these pwm-like pulses to sharper ones. What kind of op-amp configuration would you suggest for this application.

2- Since the frequency is counted between the rising edges what should be the sampling rate? My guess is 2*(1000000/80) = 25kHz. Would you agree?

3- If I cannot reach up to that sampling rate is there work around for lower sampling rates?

• A fast comparator (where "fast" means "fast enough for your application". You get to choose the voltage level where you "slice" the pulses. Too low and you see noise : too high and they are narrowed. See WhiskeyJack's answer on hysteresis for a partial answer to the noise problem. Dec 9 '15 at 13:39
• i also need to increase the duty cycle Dec 9 '15 at 13:43

To add to Rodions answer, here is a circuit that uses a comparator instead of an opamp. It's built around the very cheap and popular LM311:

R1 and R2 form a voltage divider which set the threshold voltage.

R5 gives a bit of hysteresis by providing positive feedback. That makes sure that even if there is a bit of noise riding on your input signal you'll get clean rising and falling edges.

V+ is your supply voltage. Can be anything between 5V and 15V. Vio is the voltage expected at your DAQ hardware or micro-controller. Can by anything between 3V and Vio.

This circuit is good enough for frequencies up to 500khz or so.

• That's great! I completely forgot to mention adding hysteresis, which in my opinion is crucial! Dec 9 '15 at 10:37
• opamp and opamp2 in LTSpice doesnt have 6 pins. How can I create that? I have the spice directive file Dec 9 '15 at 10:46
• @jjuserjr Yea, that's probably a custom symbol. I've zipped the whole simulation project together: torus.untergrund.net/comparator_example.zip You may have to copy the .asy file into the ltspice lib/sym folder. Dec 9 '15 at 11:03
• thanks. just couple of questions. what is the 6th pin connected to the ground in DIP? and what is the purpose of Vio? Dec 9 '15 at 11:18
• another question is can i use this for any pulse inputs to be sharpened? Dec 9 '15 at 11:21

Not directly related to your question but might help someone who ends up here looking for similar answers.

For signal conditioning, Schmitt triggers can be used (74C14 is a common one). Besides making the switching sharper, they also remove noise from the signal. Here is an excerpt from TI's app note(scea046.pdf):

Unlike comparators, presence of hysteresis will help you remove noise from the incoming signal. Here is a comparison between a comparator and schmitt trigger(stolen from here):

What kind of op-amp configuration would you suggest for this application.

Op-amp is a good idea, but you may want even more dedicated thing - the comparator, e.g. LM393. It also has two inputs and toggles the output when one of the inputs is above the other. So you will route your line to one input and, say, divider of two resistors to another (so that you may choose at what voltage to toggle the output). If you use comparator with open collector you will want pull-up resistor on the output also.

However from your picture I do not think you really need to sanitize input, it looks Ok for calculating periods anyway...

Since the frequency is counted between the rising edges what should be the sampling rate?

That's correct. However I'm not sure why you speak of sampling frequency here - are you reading pulses with ADC?

If I cannot reach up to that sampling rate is there work around for lower sampling rates?

You can, for example, extend the duration of pulses (keeping the period unchanged!). Use something like one-shot based on 555 timer after the comparator for example.

Another, perhaps simpler idea, is to put the flip-flop which is toggled by the rising edges. You will get output with high level for one period and with low level for another. I.e. frequency is reduced twice (which you can recalculate on software side) but the pulses become 50% of period.

• Awwww, you've been faster while I was drawing a circuit :-) Dec 9 '15 at 9:42
• Oh, please sorry. Anyway I believe the drawing will be more helpful compared to my clumsy explanations... Dec 9 '15 at 9:45
• No need to be sorry, your answer is fine :-) Dec 9 '15 at 9:49
• "You can, for example, extend the duration of pulses (keeping the period unchanged!). Use something like one-shot based on 555 timer after the comparator" Can you help me to implement this in LTdpuce Im not familier with timers Dec 9 '15 at 12:46
• then do not mess with timers, I think. The idea with flip-flop looks better to me. I think you simply take something like 74LS74 (or 74HC74) flip-flop (one half of it) and then connect D input with Q-inverted output, while C-input is where you attach the output of the comparator. Dec 9 '15 at 14:05

The minimum sampling rate will depend somewhat on the anti-aliasing filter in your DAQ system, but your 25kHz number sounds reasonable - most of the energy with a 3kHz 25% duty cycle is in the first three harmonics, so double 9kHz for Nyquist, and a bit more would be good, so 25kHz is reasonable.

I'm not sure sharpening the pulses up and then feeding them into an ADC is going to make the results look very much different- you'll get a mushy signal out because of the anti-aliasing filter unless your DAQ is something like a successive approximation type that lacks such a filter.

Often this sort of thing is done digitally with a timer- sharpen the pulses up and count the periods in a given time, or count the time for one or more periods, depending on the update rate you need. One method gives you a number that is proportional to the frequency, the other to the reciprocal of frequency.

• the thing is I cannot sample more than 10kHz. i need to find another solution after i sharpen the signals. Dec 9 '15 at 12:15
• I like the idea @rodion suggested of dividing the frequency down before measuring it, which will also give you a more favorable 50% duty cycle. 2:1 or 4:1 (a single 74HC74, for example) would do it. Dec 9 '15 at 12:30
• for some reason i shouldnt change the period of the pulse that software reads. Dec 9 '15 at 12:33
• i tried with 555 but whatever RCcombination is i get the following result: postimg.org/image/pk4tnqu3v what is wrong? Dec 10 '15 at 13:51