0
\$\begingroup\$

I have a process that produces a digital pulse train from a rotary encoder. I need to be able to stop the process once a stepper motor has moved a given distance. The trick is, I need to manually set the length of the process, probably using a potentiometer. So what I'm looking for is something that takes the digital pulse train as an input and produces an analog voltage as an output, the voltage increasing with the number of pulses received. I can then compare this output voltage with the voltage at the potentiometer and stop the process when they match.

This stopping is secondary to the main purpose of the stepper motor, and is not a precise requirement; the exact number of pulses received is not important. I want to stop the stepper motor if it overruns its intended distance, so a potentiometer control is adequate.

I've been searching the web for articles that give a solution to this, but haven't found any. I've looked at digital-to-analog converters but can't find one that does what I need. Basically, it's a digital counter that produces an analog voltage output which increases with the input count.

\$\endgroup\$
  • \$\begingroup\$ A pulse can be made to move a voltmeter needle up or down, but keeping the needle still when there is no pulse, is subject to long-term drift. It is impractical UNLESS you add a provision for reset-to-zero, either switched or continuous-decay-to-zero. \$\endgroup\$ – Whit3rd Jan 19 '18 at 5:00
0
\$\begingroup\$

An analogue integrator appears to do what you want: -

enter image description here

A single positive pulse will cause the op-amp output to ramp down at a specific rate and, when the pulse is finished, the output level will be at a new level and remain at that level until another pulse arrives.

If the polarity of the input pulse changes then the output will ramp in the opposite direction so care has to be exercised to make sure your input is "reliable". You also have to choose op-amp and capacitor carefully to avoid the output drooping over time in the absense of a pulse.

If you are "collecting" say a hundred pulses in ten seconds and relying on the output as an approximate measure of the number of pulses you should be OK. If it is much longer you won't be OK and I would recommend a digital technique.

If the pulses have a lot of variability in their width then this will also be problematic because the circuit will "weight" pulses of longer duration more highly than thinner pulses.

If you can overcome these problems it should work.

Bear also in mind that you need a reset circuit to discharge the capacitor each time you start a new "run".

\$\endgroup\$
  • \$\begingroup\$ Thanks for that Andy Aka. I think I can use this to solve my problem. The pulses I'll be counting could be up to about 2.3 kHz and the time will typically be 1 to 2 seconds, maximum probably 5 seconds. Pulses from my encoder are conditioned by a LS7084 clock converter and should be reliably the same width. There is also no chance of reverse polarity pulses. \$\endgroup\$ – Steve W Jan 22 '18 at 19:40
1
\$\begingroup\$

Typically this would be done by making the potentiometer an input to the processor (via an ADC) and having that make a decision. Especially as it can apply somewhat more sophisticated filtering and decisioning than you can easily accomplish in the analog realm.

Alternately, more in keeping with your stated idea you can use a Digital to Analog converter (DAC) to turn a value in software into an analog voltage. One crude, but sometimes suitable form of DAC is to use a hardware timer on a processor to generate pulses of varying width (PWM), and then smooth this with a filter made from at least a resistor and capacitor, or perhaps a more sophisticated one. A key question here will be how smooth the output needs to be, vs. how agile you require it to be in responding to changes of value. If it only needs to change slowly, it can be made very smooth. But making an output that is smooth at rest but rapidly changes when required places more challenging demands on the filter, and may be a reason to use a "real" DAC rather than smoothed PWM.

Your question is rather short on details, so a more specific answer will not be possible. And even if there were more application details, seeking recommendations of specific parts isn't really a permitted goal of questions here.

\$\endgroup\$
0
\$\begingroup\$

I am afraid you just need to use the straightforward approach to solve your problem, just as you formulated it: "digital counter with analog output".

Take some minimal-size MCU, whichever you feel comfortable with (and has a full development support), and count the pulses coming form the encoder. There are plenty of ready-to-go development/reference designs, some are really inexpensive, which will serve the purpose without much soldering.

It could be just an interrupt input. One pulse - one call, counter++. In the same call you then simply output the current value of that counter into a DAC. It could be an internal DAC in the MCU, or external DAC controlled by I2C interface. You will need to get the DAC with sufficient resolution (number of bits) to cover your range of pulses.

An analog integrator will likely fail due to unpredictable leakage, so the output will drift.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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