Pages: [1] 2   Go Down
Author Topic: how to use rpm sensor where frequency and amplitude of output varies [SOLVED]  (Read 3176 times)
0 Members and 1 Guest are viewing this topic.
Minas Gerais, Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to use arduino to control a diesel motor EDC injection pump (and therefore the motor).
I already have the "power" part, where I can control the amount of fuel injected.
Now I want to read the motor RPM using a sensor that's already in the pump.
My electric/electronic skills are very limited, but from what I understood, it's a coil biased by a magnet that, when the teeth of a gear attached to the pump shaft pass by, induce a voltage.
The output looks roughly like a triangle-wave (maybe a sine?) in the oscilloscope, where both the amplitude and frequency varies with the rpm. Something from 2V (peak) to 7V and the frequency from 50Hz to 200Hz. I don't know how to use a oscilloscope very well, so this may be totally wrong, when I use a digital multimeter set to read AC, it varies from 1.5V to 6V (from the motor lowest rpm to very high).

I first thought to use a rectifier and capacitor (to smooth) and read the it using an analog pin. But now I think that if I'm able to read the frequency, by counting the peaks somehow, It will be a much better value. i.e. without noise or resolution problems, since it'd be digital by nature (I imagine).

I am a developer and coding is not the issue (I know interrupts, etc), my problem is the electronics: how do I hook it do my arduino?
If I do it directly, this high value (6V) for the higher speeds may damage it. And the lower value (1.5V) may not trigger the HIGH state on the pin. Are these assumptions right? How can I do this?
« Last Edit: October 11, 2011, 01:11:29 pm by Henrique Abreu » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I can think of a couple of ways to measure the frequency:

1. If the Arduino won't be doing much else, you can read the voltage continuously from an analog pin. If neither side of the sensor coil is grounded, I would connect one side to a 2.5v reference (1:1 voltage divider across the 5v supply) and the other to an Arduino analog input pin through a fairly high resistance (e.g. 100k). This resistance in conjunction with the protection diodes on the Arduino pin will prevent the voltage from damaging the Arduino. [Purists may object that the atmega328p doesn't specify an input clamp current rating. However, 70uA isn't going to harm it. If it worries you, use a voltage divider to reduce the voltage to 5 volts peak to peak.] Your sketch will need to do an analogRead on the pin at least every 1ms or so, looking for the polarity with respect to the 2.5v reference to change.

2. If the Arduino is going to be busy with other tasks, then I would use a comparator IC with a little positive feedback to convert the input into a nice square wave. Feed that into a digital input pin, which can trigger an interrupt, and the interrupt servcie routine can either count pulses or track the time between pulses.
Logged

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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34122
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Purists may object that the atmega328p doesn't specify an input clamp current rating.
Yes it does it is 1mA but it is not in the data sheet.

I would feed the input into the base of a transistor through a 1K resistor. Emitter to ground, collector to arduino input and enable the internal pull up resistors. Put the other end of the coil to ground.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Purists may object that the atmega328p doesn't specify an input clamp current rating.
Yes it does it is 1mA but it is not in the data sheet.

That's useful to know. Can you point me to a source for that information?
Logged

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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34122
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It says:-
Quote
It is not recommended that the clamping diodes are conducting more than maximum 1 mA

in Application note:- AVR182: Zero Cross Detector
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks Mike!
Logged

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.

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2590
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's in data sheet, paragraph 28 Electrical characteristics:
Quote
Injection Current at VCC = 5V ...................................... ±1.0mA
Most transistor wouldn't survive 7V reverse voltage on base-emitter junction, I'd add a protection diode to pass negative half-wave to ground.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Magician,

Which datasheet is that? I'm using doc8271.pdf, downloaded from Atmel a few weeks ago, revision 8271D–AVR–05/11. On this sheet, "Electrical characteristics" is section 29, and the word "injection" isn't found in the document. I just searched the Atmel site again and it came up with the same document.
Logged

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.

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2590
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.atmel.com/dyn/products/product_docs.asp?category_id=163&family_id=607&subfamily_id=1723&part_id=4662
doc7810.pdf   It's not clear what board OP has, but I think this parameter isn't varying much between other chips in this (8 - bit CPU) category, as it "technology" dependant.
Logged

Rochester, NY USA
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Henrique,

dc42 suggested using a comparator in option 2 which is what I'd recommend. At my day job, I'm currently finishing a design where we needed to measure frequency off motors for aircraft. I used a comparator based circuit fed into a digital I/O pin, which I would recommend. If you've never used one before I'd recommend reading the wikipedia entry to get up to speed, http://en.wikipedia.org/wiki/Comparator. Depending on the noise in your signal you can add hysteresis and if you don't know how, read this ap note http://www.maxim-ic.com/app-notes/index.mvp/id/3616 . If you have any questions after reading the ap notes or your specific implementation, feel free to ask.

Alan
Logged

Minas Gerais, Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, thanks a lot for you help. I still has some doubts though. (my board is a 2009)

About the comparator solution, I read the links provided and searched trying to learn how to do it. I've came up with this schematic, is it correct?


About the transistor, is this what you meant?


Sorry for the delay on answering, the problem is that I have to study a lot before posting smiley

(edit: fixed img links)
« Last Edit: October 06, 2011, 09:25:07 am by Henrique Abreu » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34122
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've came up with this schematic, is it correct?
Only if you post it or provide a link can we tell.
Logged

Minas Gerais, Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the fast reply Grumpy_Mike.
I hope to have fixed the links now.
« Last Edit: October 06, 2011, 09:26:06 am by Henrique Abreu » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6614
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The comparator solution is only better than the transistor solution if you add some positive feedback to give it some hysteresis to improve noise immunity. Also, you may damage the comparator if you drive it directly from the sensor, so you must use at least a series resistor and preferably protection diodes as well (1N4148 or similar). See attached. I've omitted the resistor from the comparator output to Vcc on the assumption that you will use the internal pullup in the Arduino, as for the transistor solution. The LM193 or LM393 is a good choice because its common mode input range includes ground.


* Scan 42.JPG (53.21 KB, 1653x1165 - viewed 36 times.)
Logged

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.

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2590
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Better this way


* rpm.png (8.06 KB, 800x600 - viewed 36 times.)
Logged

Pages: [1] 2   Go Up
Jump to: