Interfacing with an LM1815 - help

Would anybody be so kind as to help me interface my Arduino with this?

http://www.national.com/mpf/LM/LM1815.html http://www.national.com/ds/LM/LM1815.pdf

Datasheet has an example circuit - but not sure where to go from there.

I had wanted to use a MAX9926 but they are surface mount and I'm a bit scared of that - prototyping is not so easy! :)

Many thanks in advance.

James

Datasheet has an example circuit - but not sure where to go from there.

It depends on what you want to do with it.

It is only one element in a motor speed feedback circuit and is about conditioning the signal you get from the rotary sensor which is measuring the speed of the motor. Thus it forms part of a closed loop control system.

It does not do the actual control function on the motor and lots more bits need adding to it to make it do anything.

Sorry I should have been more specific.

I want to count the pulses produced by a VR sensor using this IC - seems like the obvious choice as that's what it's designed for.

Code to work out and display rpm

James

Just take the diagram on page 6 and put pin11 low. Then connect pin 10 to the Arduino. I would recomend connecting this to Pin 2 or 3. Then you use the attach interrupts to let an edge on this line trigger the running of an interrupt service routine. This would simply take the value in the millis() counter and subtract it from what was there before, store the result in a "period" variable and store the current value of millis() for next time.

Then you main loop just picks up the value of "period" and does what it need to with it.

Hope that helps.

Thanks.

I have no problem with the code - in fact I have most of it written already :)

I take it I can disregard REFERENCE PULSE OUT and TIMING PULSE INPUT.

When you say "put pin 11 low" - you mean what? (sorry!)

Any thoughts on the cap and resistor on pin 14?

James

When you say “put pin 11 low” - you mean what? (sorry!)

Connect it to ground.

Any thoughts on the cap and resistor on pin 14?

It defines the pulse width, you are not so much interested in this because you are counting edges. However you have to make sure that the pulse width is shorter that the time between pulses. So if you are expecting the pulses to arrive at 30 mS intervals (2000 RPM) then make sure RC gives you a value of less than say 10 mS.

Mike,

Thanks for that.

Based on 4 pickups on the wheel (easy to do the bolts) I’d expect it to top out at about 6,500 at 110mph… if I just use one then that’ll be about 1,600 rpm.

I’ll be counting in microseconds or using the hpticks function I’ve seen on here.

James

Ok - got this wired up on my breadboard.

I've set up an attachInterrupt to println("change") to the serial console but it's constantly sending that. Something is wrong :)

The output is around 2.8 to 3 volts - it goes lower (>1 or so) when I put a piece of metal in front of the VR sensor. So it seems to be working to some degree.

I'm guessing because it's not going to 5 or 0 but somewhere in between?

James

Ok I have got this working.

I needed to swap the VR sensor wires.

An interesting thing is occuring - I think it's my understanding of how the Arduino works...

This:

void setup()
{
  Serial.begin(9600);
  attachInterrupt(0, counter, RISING);
}
void counter()
{
  count += 1;
  Serial.println(count);
}

is different to this:

void setup()
{
  Serial.begin(9600);
  attachInterrupt(0, counter, CHANGE);
}
void counter()
{
  if (digitalRead(2) == HIGH && prevVR == LOW) {
  count += 1;
  Serial.println(count);
  }
  prevVR == digitalRead(2);
}

I thought it would do the same?

The first example counts up a few numbers at a time - seemingly a little randomly.

Second one seems to work fine - and counts up one at a time.

Any ideas?

James

Replying to my own post again :)

I think I might have broken something :(

Same code, it now just counts up and up and up without the VR sensor touching anything. I tried another IC but it does the same thing.

Could I have broken the Arduino?

So just reading the LM1815 datasheet - the output when high is 7.5 to 8.6 volts.

I need to drop it to 5 volt to be safe? The output on the LM1815 has a 1k resistor to ground - so upping this to 1.5k should solve my issues?

Hi James back from the weekend:-

I would always put brackets in an if statement just to make things clear, so :- if (digitalRead(2) == HIGH && prevVR == LOW) { I would put:- if ((digitalRead(2) == HIGH) && (prevVR == LOW)) {

If you exceed the input voltage you will fry the input. I would use clamping diodes like shown here:- http://www.thebox.myzen.co.uk/Tutorial/Protection.html If it is regularaly going over 5V then I would up the series resistor to arround the 100R mark as well.

Thanks Mike.

I'll try adding the diode and upping the resistor for complete protection.

The resistor going to ground is 1k - are you suggesting another resistor in series with the connection to the Arduino?

The strange thing is the supply to the IC is only 5 volts (taken from Arduino) - so why and how would it go above this?

James

are you suggesting another resistor in series with the connection to the Arduino?

Yes it is to drop voltage when the diodes conduct on an over voltage.

The strange thing is the supply to the IC is only 5 volts (taken from Arduino) - so why and how would it go above this?

The data sheet says typical operating voltage of 10V. If you are only feeding it with 5V then I can’t see how you would get more out of this circuit either. Make sure the grounds are common.