Pages: 1 [2] 3   Go Down
Author Topic: What is the best type of sensor for motorcycle ODOMETER..??  (Read 4621 times)
0 Members and 1 Guest are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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't find a datasheet for the AH34, although I found one for the AH342, which may be related.

The US1881 looks suitable to me, however it needs to see a north pole to switch one way and then a south pole to switch the other way. So you would need to use 2 magnets on the wheel, opposite ways round, so that in one rotation the sensor sees both a north pole and a south pole.
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't find a datasheet for the AH34, although I found one for the AH342, which may be related.

The US1881 looks suitable to me, however it needs to see a north pole to switch one way and then a south pole to switch the other way. So you would need to use 2 magnets on the wheel, opposite ways round, so that in one rotation the sensor sees both a north pole and a south pole.

I am also thinking that the US1881 is much better...The datasheet of US1881 says that it is high magnetic sensitivity, so I thing that i can keep the magnet little far too from the sensor..
I bought one AH34 which needs a magnet to be at least half a cm close to it..


I can get these sensors too..
http://www.rhydolabz.com/index.php?main_page=product_info&cPath=137_149&products_id=391

Datasheet
http://www.rhydolabz.com/documents/datasheets/MH183%20Hall%20sensor.pdf


http://www.rhydolabz.com/index.php?main_page=product_info&cPath=137_149&products_id=390

Datasheet
http://www.rhydolabz.com/documents/datasheets/A3290XUA.pdf


http://www.sunrom.com/sensors/current/hall-effect-sensor

Datasheet

http://www.sunrom.com/files/WSH315.pdf



« Last Edit: September 24, 2011, 11:01:23 pm by Joy » Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Another thing is what is going to be much better for whatever sensor I am using...

Pick one pulse every wheel rotation (using one magnet on the wheel)   

OR

Pick two pulse every rotation, that is one pulse every half rotation of the wheel..(using 2 magnets)         

Which is going to be much better..?
« Last Edit: September 24, 2011, 10:49:46 pm by Joy » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

If you use the US1881 then you will need two magnets anyway (one N and one S towards sensor) but still only get one pulse per revolution.

Two magnets on opposite sides of the wheel will help to avoid unbalancing it. One pulse per rev is all you need, you're only measuring km so you don't need the extra resolution that two pulses would give.
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use the US1881 then you will need two magnets anyway (one N and one S towards sensor) but still only get one pulse per revolution.

Two magnets on opposite sides of the wheel will help to avoid unbalancing it. One pulse per rev is all you need, you're only measuring km so you don't need the extra resolution that two pulses would give.

I want to calculate the 1/10 also for the decimal that is the reason i was asking..
I had open a thread about this few days back..
http://arduino.cc/forum/index.php/topic,72801.0.html

I have access to few of these HALL SENSORS

I can get these sensors too..
http://www.rhydolabz.com/index.php?main_page=product_info&cPath=137_149&products_id=391

Datasheet
http://www.rhydolabz.com/documents/datasheets/MH183%20Hall%20sensor.pdf


http://www.rhydolabz.com/index.php?main_page=product_info&cPath=137_149&products_id=390

Datasheet
http://www.rhydolabz.com/documents/datasheets/A3290XUA.pdf


http://www.sunrom.com/sensors/current/hall-effect-sensor

Datasheet
http://www.sunrom.com/files/WSH315.pdf


Please check if there is anything as good as US1881, I dont want the latch effect.. smiley-sad 
By the way , is there any advantage of that latch effect.
« Last Edit: September 25, 2011, 02:41:06 am by Joy » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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 think the latch effect is an advantage in your application. Imagine that your bike is stationary but the magnet just happens to be over the sensor. Without a latch effect, very small movements of the wheel back and forth will generate pulses, making it appear that the bike has travelled. With the latch effect of the US1881, you would have the move the wheel back and forth half a revolution to get any pulses.

The circumference of your wheel is much less than 0.1km so you don't need more than 1 pulse per revolution.
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the latch effect is an advantage in your application. Imagine that your bike is stationary but the magnet just happens to be over the sensor. Without a latch effect, very small movements of the wheel back and forth will generate pulses, making it appear that the bike has travelled. With the latch effect of the US1881, you would have the move the wheel back and forth half a revolution to get any pulses.

The circumference of your wheel is much less than 0.1km so you don't need more than 1 pulse per revolution.

Good point ..
Even I was thinking earlier about the thing you told..But it never came to mind that the US1881 can solve the problem...
Logged

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the latch effect is an advantage in your application. Imagine that your bike is stationary but the magnet just happens to be over the sensor. Without a latch effect, very small movements of the wheel back and forth will generate pulses, making it appear that the bike has travelled. With the latch effect of the US1881, you would have the move the wheel back and forth half a revolution to get any pulses.

The circumference of your wheel is much less than 0.1km so you don't need more than 1 pulse per revolution.

Good point ..
Even I was thinking earlier about the thing you told..But it never came to mind that the US1881 can solve the problem...

Will you please help me out in writing the code for the odometer..
The thread about it is here..
http://arduino.cc/forum/index.php/topic,72801.15.html
« Last Edit: September 26, 2011, 06:27:48 am by Joy » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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 know you are using one interrupt-enabled pin already for the RPM counter, but is the other interrupt pin still free? On the Uno it is pins 2 and 3 that can generate interrupts as standard.
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know you are using one interrupt-enabled pin already for the RPM counter, but is the other interrupt pin still free? On the Uno it is pins 2 and 3 that can generate interrupts as standard.

yes..
My pin 3 on the arduino is free...
I am trying to use it for the ODO..
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

OK, here is a first attempt, compiled but otherwise untested.

Code:
#include <EEPROM.h>

const int odometerPin = 3;
const int odometerInterrupt = 1;
const int odometerEepromLocation = 0;  // address of the first of 4 bytes in which the total wheel revs is stored
const int powerPin = A0;               // analog pin used to sense impending loss of power

const float wheelCircumference = 0.002035;  // wheel circumference in km
const int minPowerOkReading = 700;          // minimum reading on the power sense analog input that indicates good power
const int minPowerRestoredReading = 750;    // minimum reading on the power sense analog input that indicates we have powered back up

volatile unsigned long wheelRevs;       // total wheel revolutions counted, will overflow after 85 million km
unsigned long lastDisplayedMs = 0UL;    // time when we last refreshed the display

void setup()
{
  // Initialise wheel revs from value stored in EEPROM
  wheelRevs = 0UL;
  for (int i = odometerEepromLocation + 3; i >= odometerEepromLocation; --i)
  {
    wheelRevs <<= 8;
    wheelRevs |= (unsigned long)EEPROM.read(i);
  }
  
  if (wheelRevs == 0xFFFFFFFFUL)
  {
    // must be the first time we have run
    wheelRevs = 0UL;
  }
  
  // Set up the odometer sensor pin and interrupt
  pinMode(odometerPin, INPUT);
  attachInterrupt(odometerInterrupt, odometerIsr, RISING);  
}

void odometerIsr()
{
  ++wheelRevs;
}

void loop()
{
  // Capture the wheel revs with interrupts disabled in case it changes while we read it
  noInterrupts();
  unsigned long savedWheelRevs = wheelRevs;
  interrupts();
  
  if (analogRead(powerPin) < minPowerOkReading)
  {
    // Looks like power is going down, so write wheel revs to EEPROM (takes 13.2ms to write 4 bytes)
    for (int i = odometerEepromLocation; i < odometerEepromLocation + 4; ++i)
    {
      EEPROM.write(i, (unsigned char)savedWheelRevs);
      savedWheelRevs >>= 8;
    }
    
    // wait until either we die or the power comes back up
    while (analogRead(powerPin) < minPowerRestoredReading)
    {
      delay(200);
    }    
  }
  else
  {  
    unsigned long now = millis();
    if (now - lastDisplayedMs >= 200)    // update display evert 200ms
    {
      lastDisplayedMs = now;
      float km = wheelCircumference * savedWheelRevs;
      Serial.print(km, 1);
      Serial.println("km");
    }
    delay(5);    // repeat after 5ms so that we check for power down often enough
  }
}
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you dc42..

I tried your code and connect the hall and a magnet to a fan but there was no increments on the reading..
It kept showing 0..

I want to test it with a push button instead of the hall..and according to my wheel circumference 491 pulse = 1Km..
so what values in the code should I change so that with the push button 5 or 10 clicks make one Km...
Should I change this..??
const float wheelCircumference = 0.002035;
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

Yes, change the wheel circumference to something much higher for debugging. Alternatively, display wheelRevs directly instead of converting it to km. Remember that if you are using the US1881, the sensor needs to see both a north pole and a south pole per simulated wheel revolution.
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.

INDIA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 382
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, change the wheel circumference to something much higher for debugging. Alternatively, display wheelRevs directly instead of converting it to km. Remember that if you are using the US1881, the sensor needs to see both a north pole and a south pole per simulated wheel revolution.

I tried these changes in the code..

Code:
#include <EEPROM.h>

const int odometerPin = 3;
const int odometerInterrupt = 1;
const int odometerEepromLocation = 0;  // address of the first of 4 bytes in which the total wheel revs is stored
const int powerPin = A0;               // analog pin used to sense impending loss of power

const float wheelCircumference = 1;  // wheel circumference in km
const int minPowerOkReading = 700;          // minimum reading on the power sense analog input that indicates good power
const int minPowerRestoredReading = 750;    // minimum reading on the power sense analog input that indicates we have powered back up

volatile unsigned long wheelRevs;       // total wheel revolutions counted, will overflow after 85 million km
unsigned long lastDisplayedMs = 0UL;    // time when we last refreshed the display

void setup()
{
  Serial.begin(9600);
  Serial.print("odometer");
  // Initialise wheel revs from value stored in EEPROM
  wheelRevs = 0UL;
  for (int i = odometerEepromLocation + 3; i >= odometerEepromLocation; --i)
  {
    wheelRevs <<= 8;
    wheelRevs |= (unsigned long)EEPROM.read(i);
  }
  
  if (wheelRevs == 0xFFFFFFFFUL)
  {
    // must be the first time we have run
    wheelRevs = 0UL;
  }
  
  // Set up the odometer sensor pin and interrupt
  pinMode(odometerPin, INPUT);
  attachInterrupt(odometerInterrupt, odometerIsr, RISING);  
}

void odometerIsr()
{
  ++wheelRevs;
}

void loop()
{
  // Capture the wheel revs with interrupts disabled in case it changes while we read it
  noInterrupts();
  unsigned long savedWheelRevs = wheelRevs;
  interrupts();
  
  if (analogRead(powerPin) < minPowerOkReading)
  {
    // Looks like power is going down, so write wheel revs to EEPROM (takes 13.2ms to write 4 bytes)
    for (int i = odometerEepromLocation; i < odometerEepromLocation + 4; ++i)
    {
      EEPROM.write(i, (unsigned char)savedWheelRevs);
      savedWheelRevs >>= 8;
    }
    
    // wait until either we die or the power comes back up
    while (analogRead(powerPin) < minPowerRestoredReading)
    {
      delay(200);
    }    
  }
  else
  {  
    unsigned long now = millis();
    if (now - lastDisplayedMs >= 200)    // update display evert 200ms
    {
      lastDisplayedMs = now;
      float km = wheelCircumference * savedWheelRevs;
      Serial.print(km, 1);
      Serial.println("km");
      Serial.println(wheelRevs);
    }
    delay(5);    // repeat after 5ms so that we check for power down often enough
  }
}


Changing the wheel circumference to 1
Serial.println(wheelRevs);


connected push button
Push button pin pin 3 of arduino and  other pin to 5V+ . A 10k resistor connected to pin 3 of arduino and GND..

Still no result.. smiley-sad


Is it because my A0 of arduino is open..??
« Last Edit: September 26, 2011, 07:24:14 am by Joy » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

Yes, you don't have the power sense pin wired up yet, so it thinks you are powering down all the time. As a temporary measure, try connecting pin A0 to +5v.
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.

Pages: 1 [2] 3   Go Up
Jump to: