DC motor + hall effect sensor = encoder?

Dear all

Since some time ago I would experiment a ratio-metric hall effect sensor in a dc motor and find a magnetic pulses.

I buy a A1302 ratio-metric sensor and DC 12V motor (2500rpm) with a gear box (5rpm) but without encoder.

Yesterday I tried the experience with a ni6009 from NI and labview and some low pass filter, it works! I found a wave in the outside body from the motor between 2.426V and 2.438V and a frequency near the 45Hz (about 10V power supply in dc motor).

Then I tryed with arduino uno, but I am not so good in that and seems I dont found voltage sensitivity in arduino or speed to find the sine wave.

Here is the first version with poor success, because I can see voltages between 2.39 and 2.40.

float val = 0;
float old_val = 0;
int state = 0;
int Eel_Count = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
val = analogRead(A0);
val = val * 0.00488;
Serial.println(val);
if ((val > 2.40) && (old_val < 2.40)){//2.40volts=490bits
 state = 1 - state;
}
old_val = val;
if (state == 1) {
 Eel_Count = 1 + Eel_Count;
 Serial.print("Pulse");
 Serial.println(Eel_Count);


}
delay(500);
}

After that can some one change the code to improve the sensitivity and/or speed that I can count the pulses and after that transform the pulses in displacement?

Thanks in advance

best regards
cpalha

cpalha:
Here is the first version with poor success, because I can see voltages between 2.39 and 2.40.

By poor success, do you mean failure? If you don't get a big enough signal to read, how can you possibly write working code to process it?

The first thing that I would do would be to eliminate the calculations from the code. Who cares what the voltage is, just use the raw input from analogRead() and it goes without saying that you should eliminate the delay() as well because at the moment you are only taking a reading every half second.

UKHeliBob:
The first thing that I would do would be to eliminate the calculations from the code. Who cares what the voltage is, just use the raw input from analogRead() and it goes without saying that you should eliminate the delay() as well because at the moment you are only taking a reading every half second.

Hi

The voltage is to see if I have the similar values that i found with other hardware.
But in arduino it changes between 2.39v and 2.41v, in the other hardware I found between 2.421v and 2.435 (sine wave peak to peak). Can you help me to get arduino counting the times that it gets 2.41v?

Here is an output for the condition if ((val > 2.40) && (old_val < 2.40)) seems not good.
Can help me implement a condition to count the times that reaches 2.4v in raising or failing not the both. For now I put the lowest speed in the motor.

40
2.39
2.40
Pulse86
2.40
Pulse87
2.39
Pulse88
2.41
2.40
2.40
2.40
Pulse89
2.39
Pulse90
2.41
2.40
2.40
2.40

thanks
cpalha

Dear all

Since I have a variation of readings between 490 and 493 bytes, I make a modification

float val = 0;
float old_val = 0;
int state = 0;
int Eel_Count = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
val = analogRead(A0);
//val = val * 0.00488;
//Serial.println(val);
if ((val > 492) ){//2.40volts=490bits
 Eel_Count ++;
}
//old_val = val;
//if (state == 1) {
  // Eel_Count = 1 + Eel_Count;
 Serial.print("Pulse");
 Serial.println(Eel_Count);



delay(10);
}

Now I have pulse counts :slight_smile:

Problems:

At 1.6V power supply for the motor, the program counts 620ppr at 50ms loop and 2700 at 10ms loop
At 3.2V power supply for the motor, the program counts 260ppr at 50ms loop and 1250 at 10ms loop
At 6.4V power supply for the motor, the program counts 125ppr at 50ms loop and 630 at 10ms loop

I will work with voltages between 5 and 7volts power supply. And I would get ppr in that voltage, but in first experiences the ppr are not the same, seems speed problem with code?

Best
cpalha