Go Down

Topic: how to use rpm sensor where frequency and amplitude of output varies [SOLVED] (Read 3709 times) previous topic - next topic

Grumpy_Mike

The comparator solution as drawn (both of them) require a split power rail. Otherwise the +ve input is never going to be able to go below the -ve one to switch the comparator.

For a single rail solution:-
It is better if the -ve input is wired to a mid point between +5V and ground provided by a potential divider of two equal resistors, of say 10K.



dc42


The comparator solution as drawn (both of them) require a split power rail. Otherwise the +ve input is never going to be able to go below the -ve one to switch the comparator.


The LM193 has a common mode input range that includes ground, because the input is a PNP emitter follower. The comparator in my circuit will quite happily switch when the inverting input goes negative by a few millivolts, which will happen when the input goes below -0.25v.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Thanks for the explanation dc42.

About your circuit, I didn't understood the diodes protection very well.
You connected two diodes "inverted" to each other between the comparator inputs?
Isn't it just like wiring the inputs together? How does that work?

dc42


Thanks for the explanation dc42.

About your circuit, I didn't understood the diodes protection very well.
You connected two diodes "inverted" to each other between the comparator inputs?
Isn't it just like wiring the inputs together? How does that work?


A regular silicon diode doesn't start to conduct until it has about 0.6v forward voltage. So the diodes limit the voltage on the noninverting input to about +/- 0.6v. The comparator needs only a few millivolts between its inverting and noninverting inputs to make it switch state.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Hi again,
First, thank you all for your help.

It didn't work well with either schematics here had here, there was too much noise, specially at low RPMs.
So I followed the links posted by ams0178 to add hysteresis, and this the schematic I got working pretty fine (at first).


As I explained in my 1st post, my goal is to control the speed of a motor by controlling the supply of the injection pump.
When I hookup the rest of the circuit I got (schematic bellow) to control the pump, instead of via an external adjustable power supply.
There was some kind of interference and my rpm reading got crazy (much higher than the real), so I guessed more noise :-/
Then I started looking at the signals in the oscilloscope, but when I connected the oscilloscope to the sensor pins the noise got "filtered" somehow.
I don't understand this, but it was always reproducible. When the oscilloscope is connected on the sensor leads (along with my circuit), the RPM reading is fine. If I disconnect it, it goes crazy.

Here is the "power" part of my circuit:


Can someone explain why this is happening? (and hopefully a solution that is not leave the oscilloscope connected :D)

Grumpy_Mike

Well I can't see any decoupling capacitors in the circuit. A scope lead has a small capacitance and that is acting as a bit of decoupling.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

dc42


It didn't work well with either schematics here had here, there was too much noise, specially at low RPMs.
So I followed the links posted by ams0178 to add hysteresis, and this the schematic I got working pretty fine (at first).


The circuit I gave you had a little hysteresis, about 0.25v. You could have increased the amount by decreasing the 1M resistor. The one you are using now has about 1.5v of hysteresis.


As I explained in my 1st post, my goal is to control the speed of a motor by controlling the supply of the injection pump.
When I hookup the rest of the circuit I got (schematic bellow) to control the pump, instead of via an external adjustable power supply.
There was some kind of interference and my rpm reading got crazy (much higher than the real), so I guessed more noise :-/
Then I started looking at the signals in the oscilloscope, but when I connected the oscilloscope to the sensor pins the noise got "filtered" somehow.
I don't understand this, but it was always reproducible. When the oscilloscope is connected on the sensor leads (along with my circuit), the RPM reading is fine. If I disconnect it, it goes crazy.


Try connecting a capacitor across your sensor. I suggest somewhere in the range 1nF to 10nF. If you are going to stick with having the sensor referenced to a voltage divider between +5v and ground, then I suggest a 100nF capacitor from the middle of that voltage divider to ground as well.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#24
Oct 09, 2011, 12:38 am Last Edit: Oct 09, 2011, 02:42 am by Henrique Abreu Reason: 1
Thank you both for the explanations.

@dc42
I tried your circuit first, but since it didn't worked. I tried to follow the hysteresis link schematic. I do prefer it because it's simpler (and I am bad at soldering).
You recommend it like this?


About this feedback resistance, lower means more hysteresis? Should I use an even lower one?

I will be able to test this only on Monday, because I have to buy this capacitor. It's ceramic, right?
By the way, I have not found the LM193 in the local shops, so I bought the LM393. They seemed the same.
Thanks a lot for the help and patience :)

@Grumpy_Mike
Very nice explanation on the site. I never understood de-coupling well. Thanks.

(edit: forgot to add the ground on the schematic)

dc42

Yes, lower feedback resistance from output to non-inverting input means more hysteresis. However, if the hysteresis is higher than the peak input voltage, the circuit won't work at all. So choose the hysteresis to be less than the minimum peak input voltage (which will probably be at the lowest RPM). Also, since the load on the output is the internal 20k pullup in the Arduino, don't make the feedback resistor too low, otherwise the logic high voltage to the Arduino will be too low. I suggest a feedback resistor of 100k minimum. If you want more hysteresis than that gives, increase the 47K input resistor. The amount of hysteresis (and therefore the minimum peak input voltage you need) is 5 * Rin/(Rf + 20K), where Rin is the input resistor and Rf is the feedback resistor.

I think you will find that the 10nF capacitor cuts the noise substantially and reduces the amount of hysteresis you need. Ceramic is fine. In fact any value from a few hundred pf to 100nF will probably work.

[EDIT: I just noticed your circuit above uses a 10K pullup rather than relying on the 20k pullup in the Arduino. In which case the hysteresis is 5 * Rin/(Rf + 10K) assuming you don't also turn on the internal pullup, and Rf shouldn't be lower than abot 50k.]
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Hi guys, thanks a lot for your help. It worked great!
The capacitor really did the trick.

Go Up