Pages: [1]   Go Down
Author Topic: LM2907 vs. LM2917  (Read 1423 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm hoping to read the RPM of a gearbox using a hall effect sensor and a frequency to voltage converter IC. I'm using interrupts to calculate RPM right now, but I think having a dedicated chip count pulses will make life easier when trying to log data to an SD card.

Can anyone help me out choosing the right lm2907 package? The datasheet lists the lm2907 and lm2917, as well as another variation on each of those, which seems to relate to input voltage.

The main difference I see in this project is that the hall effect sensor is like a switch, as opposed what ever (inductive?) signal is measured from an engine's distributor as many other projects do.

I hope to run the circuit off of the Arduino's 5V regulator, and read the input on an analog input.

Cheers!
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I wouldn't give up on measuring frequency directly just yet. Using interrupts is pretty taxing on the processor if the RPM is high, but you can also use one of the built-in timer/counter peripherals if you're willing to grab control of it away from the underlying Arduino libraries.

For example, an ATmega328 can configure Timer 0 or Timer 1 to count from an external pin rather than from the 16 MHz oscillator. Leaving Timer 0 alone (it implements millis() and friends) you can use the digital T1 pin (PD5, or digital pin 5) as the clock to Timer 1 by writing 7 to the TCCR1B register. Then, do not do any PWM on the Timer 1 outputs (digital pins 9 and 10).

To compute RPM you can then use millis() (or similar) to define a particular time interval, then see how much Timer 1 has changed during that time interval. That can easily be converted to RPM.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
To compute RPM you can then use millis() (or similar) to define a particular time interval, then see how much Timer 1 has changed during that time interval. That can easily be converted to RPM.
That does sound quite elegant, can it be done in the Arduino IDE, or would I have to program that in assembly?

Here is my rpm calc code:
Code:
// Sensor Reading-------------------------------------------------------------------------------------


  if (gearCount >= 15) {
  
    gearRpm = gearCount*25000000L/(micros() - gearTimeold);
    
    gearTimeold = micros();
    gearCount = 0;
  }
  
    if (tachCount >= 15) {
  
    tachRpm = tachCount*60000000L/(micros() - tachTimeold);

    tachTimeold = micros();
    tachCount = 0;
  }
  
 //--------------------------------------------------------------------------------------
  
Here are my ISR's
Code:
void gear_fun()
{
  gearCount++;
  //Each rotation, this interrupt function is run twice
}

void tach_fun()
{
  tachCount++;
  //Each rotation, this interrupt function is run twice
}

And this is my RPM output (although rpm's are *10- i messed up calculations):


As you can see it is quite noisey, and the acceleration data could be smoother.
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That does sound quite elegant, can it be done in the Arduino IDE, or would I have to program that in assembly?

Something in between. No assembly is required, but you will have to address the AVR registers directly rather than relying on the Arduino "middleware" library functions like digitalWrite().

I didn't realize you had two things you were trying to count (gear counts and tach counts). Each timer can only count one external source. You could use Timer 1 for tach, for example, and continue to use your ISR software for the gears. You *could* use Timer 0 for gears as well but it is only an 8-bit timer (so cannot support very fast timer inputs over a long time) plus you would not be able to use the millis() and micros() functions any more.

With multiple inputs, a hardware solution may in fact be best.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals
Logged

Ontario
Offline Offline
God Member
*****
Karma: 20
Posts: 835
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Something in between.

The code to do this is literally:

Code:
TCCR1B = 7;

which you can stuff into an ordinary Arduino sketch. Nothing at all to be afraid of here.
Logged

Pages: [1]   Go Up
Jump to: