I am working on a Arduino tachometer that reads the RPM of a BLDC motor. The motor circuit does not use the hall sensors so I would like to use them for RPM sensors. I have already hooked up an Uno board using one pin as an input with the internal pull up enabled and it works fine.The reason I want to use all 3 hall sensors is to increase the pulse count per revolution to steady the reading on my LCD display at lower speeds. I have been searching for information on how to read 3 inputs, and totalize the pulses for this purpose but have not been able to find the information.
2 Answers
Assuming that only one sensor will trigger each time then (as jsotola suggested) tie them together and connect the common output to an interrupt pin. Arduino UNO has interrupt functionality on pins 2, 3.
As an example for counting the pulses using pin2 on falling edge (modified from https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/):
const byte interruptPin = 2;
volatile int numPulses = 0; // change type of variable according your needs
void setup() {
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), sumPulses, FALLING);
Serial.begin(9600);
}
void loop() {
Serial.println(numPulses);
delay(500);
}
void sumPulses { // keep the ISR as short as possible
numPulses++;
}
-
The hall outputs on the BLDC motors are sinking so two of the outputs are high at any time so parallel won't work. I may have to get a dual shaft motor and add a pickup with a higher PPR count on the rear shaft to achieve the results I am looking for. Thank you for your suggestions though. Commented Feb 15, 2021 at 13:50
An alternative method of frequency determination is to measure period and take the reciprocal. It can be extremely accurate and responsive at very low frequencies, so you don't need to combine multiple sensors just to increase the rate.
Note that you are not limited to measuring a single period; you can count the microseconds in N periods to increase resolution at high frequencies.