Jump to content
Sign in to follow this  
Michael.

Arduino / Freetronics people?

Recommended Posts

Hey guys,

Just wondered if there was anyone here up to speed on using Arduino gear & the coding?

I need a fairly simple solution to a speedo signal problem.

To keep it simple, I need to input a 2 wire magnetic speed sensor as an analogue input to the Arduino unit, for it to be coded to act as an analogue to digital (ADC) converter, giving the digital output as 0-5v, giving the high reading for each pulse, then I can use that signal for the ECU.

The 2 wire speed sensor does 4 pulses per rpm of the trans output shaft.

The original 3 wire hall effect sensor is gone since I changed the gearbox with a different model on the weekend.

Any help would be great!

Share this post


Link to post
Share on other sites

Hey guys,

Just wondered if there was anyone here up to speed on using Arduino gear & the coding?

I need a fairly simple solution to a speedo signal problem.

To keep it simple, I need to input a 2 wire magnetic speed sensor as an analogue input to the Arduino unit, for it to be coded to act as an analogue to digital (ADC) converter, giving the digital output as 0-5v, giving the high reading for each pulse, then I can use that signal for the ECU.

The 2 wire speed sensor does 4 pulses per rpm of the trans output shaft.

The original 3 wire hall effect sensor is gone since I changed the gearbox with a different model on the weekend.

Any help would be great!

On first glance that would seem really easy to implement but it begs the question why you need to do this with a microcontroller? When you say magnetic speed sensor do you mean mechanical (ie. reed switch) or hall effect and if so is it latching or not? Either way a simple electronic switch would do the job. If you must use an Arduino, connect the sensor to an external Interrupt pin so that when it gets a signal it switches an output to 5V - simple code:

void setup()

{

Serial.begin(9600);

attachInterrupt(0, detect_sensor, RISING); // Initialize external Interrupt 0 (Pin 2 or 3 on most Arduino boards)

pinMode(digital pin number, OUTPUT); // Set pin ( you choose) to output

}

void loop()

{

// do nothing or something

{

void sensor_detect() // Interrupt service routine

{

digitalWrite(pin, HIGH); // Switch to 5V

delay(50); // Change the value in mS if you need shorter or longer pulse width

digitalWrite(digital pin number, LOW); // Switch back to 0V

}

Share this post


Link to post
Share on other sites

If the magnetic speed sensor is a pulse, you want to be hooking that to to an interrupt pin so you don't miss any pulses. Depending on the sensor it may also need debouncing (would do that with hardware, capacitor would do it).

The arduino it self does not have analog out, but you could use the pwm out and some external hardware to get something that would be pretty close to a 0-5v analog output.

Share this post


Link to post
Share on other sites

On first glance that would seem really easy to implement but it begs the question why you need to do this with a microcontroller? When you say magnetic speed sensor do you mean mechanical (ie. reed switch) or hall effect and if so is it latching or not? Either way a simple electronic switch would do the job. If you must use an Arduino, connect the sensor to an external Interrupt pin so that when it gets a signal it switches an output to 5V - simple code:

void setup()

{

Serial.begin(9600);

attachInterrupt(0, detect_sensor, RISING); // Initialize external Interrupt 0 (Pin 2 or 3 on most Arduino boards)

pinMode(digital pin number, OUTPUT); // Set pin ( you choose) to output

}

void loop()

{

// do nothing or something

{

void sensor_detect() // Interrupt service routine

{

digitalWrite(pin, HIGH); // Switch to 5V

delay(50); // Change the value in mS if you need shorter or longer pulse width

digitalWrite(digital pin number, LOW); // Switch back to 0V

}

Just going to turn an output on and off as the switch opens / closes. Also, that wont compile. it has errors, and its not smart to have delays in your ISR.

Micheal, you can also get dedicated frequency to voltage converter chips if you were not aware of that.

http://www.ti.com/lit/ds/symlink/lm2907-n.pdf

Edited by polley
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the tip Troy, wasn't aware those!

One code I've found that does more along the lines of what I want is this, but it outputs to the serial display, I want to try get that as an digitial out put instead.

*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}

Share this post


Link to post
Share on other sites

From what I understand is you want to take a pulse input (this is not a analog input!), convert it to speed, then output that as a 0-5v output ?

If it is a pulse input, you want to use a digital interrupt, and count the number of pulses in a given amount of time and you can calculate speed from that. Are you going to be measuring RPM or do you want to calculate KPH? You can then map your min and max speed to 0-255 to output a PWM signal that can be filtered to your 0-5v output.

Is the magnetic sensor just a reed switch or is it a VR sensor?

There is an example of reading RPM from a fan here, which will give you a better idea.: http://playground.arduino.cc/Main/ReadingRPM

An example of filtering the PWM output to provide a 0-5v analog output: https://arduino-info.wikispaces.com/Analog-Output

I've done the same thing before to build a tacho.

Edited by polley
  • Like 1

Share this post


Link to post
Share on other sites

The 2 wire speed sensor does 4 pulses per rpm of the trans output shaft.

The original 3 wire hall effect sensor is gone since I changed the gearbox with a different model on the weekend

Do you actually need an analog output or just 4 square wave pulses per rpm like the hall effect sensor used to put out?

If this is the case you could use a max9924 (although qsop chips are tiny) or an lm1815.

Anyone know of a qsop adapter that is available locally

  • Like 1

Share this post


Link to post
Share on other sites

Will look into those today Troy. Thanks!

It's one of these kind of inductive sensors I wish to use as the input

http://cdn2.stylincdn.com/is/image/Autos/sisc281_is?$700x700$

James, I need an square wave signal 0-5v that runs back to the dash, this is for the ECU.

What is involved with using such ICs like you suggest?

Share this post


Link to post
Share on other sites

Need some more info on the sensor as that could be a VR sensor and will need extra circuitry on the input.

So you are after a square wave pwm type signal back to the dash instead of a straight 0 -5 v?

Need more information on what type of sensor you are using, what output you want. Easy enough to convert the 4 pulses per revolution to RPM if thats what you want, but what is the ECU expecting at the other end, 0-5v analog? pwm pulse output?

^^ Or like thorburn said, just convert the magnetic sensor output to hall effect type output?

If its a VR sensor, I already have some boxes here that convert VR to Hall made up im not going to use anymore.

Edited by polley

Share this post


Link to post
Share on other sites

Looks like a vr sensor and being 2 wire it probably is.
There is plenty of info about the lm1815 chips
- you could just copy how the circuit they are on in a megasquirt (ill dig you out more info if you need).
- another option is look through the examples on the datasheet

The max chips are a lot better but probably not necessary for just reading rpm and the tiny size of them makes a bit less user friendly
Again the datasheet has a good example of how to use.

Either way i think Troy has you sorted- what chip are you using?

Share this post


Link to post
Share on other sites

Yeah, a hall effect output is what the ECU needs to regulate the dash and some other units. I thought this would be an issue looking at the wiring diagrams and sure enough it is.

This board runs a ATmega328P chip.

The original hall effect sensor, 3 wire type 5v + / Signal / GND, runs a gear setup at the back of the gearbox, it gives the siginal as a 0 (low) and 5v (high reading) to the ECU and Dash.

On the otherside of the box theres the VR sensor

Share this post


Link to post
Share on other sites

Either way i think Troy has you sorted- what chip are you using?

I have 2 x these boards: http://www.jbperf.com/dual_VR/v2_1.html

Was going to use them to convert my ABS signals to hall type for traction control, instead now I'm using to to install hall effect sensors.

Have these boards avaliable if you want one / suits yours needs (which it sounds like it might) Micheal.

Share this post


Link to post
Share on other sites

They sound like they would suit.

However I think the other requirement is the output as a digital from analogue input to be set to the right pulse rate, so it would need to be calibrated as such with some on road testing.

I believe the original gear driven hall effect sensor was 32 pulse per full rotation of the tail shaft vs 4 pulses of the VR sensor, so given that its not as simple as a direct ADC.

This is why I've looked to use the Arduino.

I once got a similar driver 2 years ago for another project but gave up because of not being familiar with the coding. I shall persist this time!

Edited by Michael.

Share this post


Link to post
Share on other sites

Ah yep sweet as. Well if it is indeed a VR sensor the arduino wont read that directly anyway (as its an AC signal). You could still use the board above to convert it to hall effect / 0-5v, feed that into the arduino and then write the code to convert the signal for the extra pulses needed.

Edited by polley

Share this post


Link to post
Share on other sites

Just going to turn an output on and off as the switch opens / closes. Also, that wont compile. it has errors, and its not smart to have delays in your ISR.

Micheal, you can also get dedicated frequency to voltage converter chips if you were not aware of that.

http://www.ti.com/lit/ds/symlink/lm2907-n.pdf

No one said it would compile as is...it was merely suggested way forward according to the description given. ie. a high out for each pulse from a sensor. There is nothing wrong with delays in the ISR as long as the Interrupt period >> pulse width.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...