Skip to main content
Arduino

Return to Question

enter image description here Hi! I require your help regarding a problem I’m encountering. I am trying to measure wind speed using Hall sensor, Neodymium magnet & below mentioned code. But I only get "0" value for both RPM & KPH values. Can you help me to solve this?

volatile byte revolutions;

unsigned int rpmilli; float speed;

unsigned long timeold=0 ;

void setup() {Hi! SerialI require your help regarding a problem I’m encountering.begin(9600); attachInterrupt(digitalPinToInterrupt(2), rpm_fun, RISING);

revolutions = 0; rpmilli = 0; timeold = 0; }

void loop() { if (revolutions >= 1) { //Update RPM every 20 counts, increase this for better RPM resolution, //decrease for faster update

// calculate the revolutions per milli(second) rpmilli = revolutions/(millis()-timeold);

timeold = millis(); revolutions = 0; // WHEELCIRC = 2 * PI * radius (in meters) // speed = rpmilli * WHEELCIRC * "milliseconds per hour" / "meters per kilometer"

// simplify the equationI am trying to reduce the number of floating point operations // speed = rpmilli * WHEELCIRC * 3600000 / 1000 // speed = rpmilli * WHEELCIRC * 3600

measure wind speed = rpmilli 1.288053600;

Serial.print("RPM:"); Serial.print(rpmilli * 60000 using Hall sensor,DEC); Serial.print(" Speed:"); Serial Neodymium magnet & below mentioned code.print(speed,DEC); Serial But I only get "0" value for both RPM & KPH values.println(" kph"); } }

void rpm_fun() { revolutions++; } Can you help me to solve this?

Thank you so much in advance for your help!

volatile byte revolutions;
unsigned int rpmilli;
float speed;
unsigned long timeold=0 ;
void setup()
{
 Serial.begin(9600);
 attachInterrupt(digitalPinToInterrupt(2), rpm_fun, RISING);
 revolutions = 0;
 rpmilli = 0;
 timeold = 0;
}
void loop()
{
 if (revolutions >= 1) {
 //Update RPM every 20 counts, increase this for better RPM resolution,
 //decrease for faster update
 // calculate the revolutions per milli(second)
 rpmilli = revolutions/(millis()-timeold);
 timeold = millis();
 revolutions = 0;
 // WHEELCIRC = 2 * PI * radius (in meters)
 // speed = rpmilli * WHEELCIRC * "milliseconds per hour" / "meters per kilometer"
 // simplify the equation to reduce the number of floating point operations
 // speed = rpmilli * WHEELCIRC * 3600000 / 1000
 // speed = rpmilli * WHEELCIRC * 3600
 speed = rpmilli 1.288053600;
 Serial.print("RPM:");
 Serial.print(rpmilli * 60000 ,DEC);
 Serial.print(" Speed:");
 Serial.print(speed,DEC);
 Serial.println(" kph");
 }
}
void rpm_fun()
{
 revolutions++;
}

enter image description here Hi! I require your help regarding a problem I’m encountering. I am trying to measure wind speed using Hall sensor, Neodymium magnet & below mentioned code. But I only get "0" value for both RPM & KPH values. Can you help me to solve this?

volatile byte revolutions;

unsigned int rpmilli; float speed;

unsigned long timeold=0 ;

void setup() { Serial.begin(9600); attachInterrupt(digitalPinToInterrupt(2), rpm_fun, RISING);

revolutions = 0; rpmilli = 0; timeold = 0; }

void loop() { if (revolutions >= 1) { //Update RPM every 20 counts, increase this for better RPM resolution, //decrease for faster update

// calculate the revolutions per milli(second) rpmilli = revolutions/(millis()-timeold);

timeold = millis(); revolutions = 0; // WHEELCIRC = 2 * PI * radius (in meters) // speed = rpmilli * WHEELCIRC * "milliseconds per hour" / "meters per kilometer"

// simplify the equation to reduce the number of floating point operations // speed = rpmilli * WHEELCIRC * 3600000 / 1000 // speed = rpmilli * WHEELCIRC * 3600

speed = rpmilli 1.288053600;

Serial.print("RPM:"); Serial.print(rpmilli * 60000 ,DEC); Serial.print(" Speed:"); Serial.print(speed,DEC); Serial.println(" kph"); } }

void rpm_fun() { revolutions++; }

Thank you so much in advance for your help!

enter image description here

Hi! I require your help regarding a problem I’m encountering. I am trying to measure wind speed using Hall sensor, Neodymium magnet & below mentioned code. But I only get "0" value for both RPM & KPH values. Can you help me to solve this?

volatile byte revolutions;
unsigned int rpmilli;
float speed;
unsigned long timeold=0 ;
void setup()
{
 Serial.begin(9600);
 attachInterrupt(digitalPinToInterrupt(2), rpm_fun, RISING);
 revolutions = 0;
 rpmilli = 0;
 timeold = 0;
}
void loop()
{
 if (revolutions >= 1) {
 //Update RPM every 20 counts, increase this for better RPM resolution,
 //decrease for faster update
 // calculate the revolutions per milli(second)
 rpmilli = revolutions/(millis()-timeold);
 timeold = millis();
 revolutions = 0;
 // WHEELCIRC = 2 * PI * radius (in meters)
 // speed = rpmilli * WHEELCIRC * "milliseconds per hour" / "meters per kilometer"
 // simplify the equation to reduce the number of floating point operations
 // speed = rpmilli * WHEELCIRC * 3600000 / 1000
 // speed = rpmilli * WHEELCIRC * 3600
 speed = rpmilli 1.288053600;
 Serial.print("RPM:");
 Serial.print(rpmilli * 60000 ,DEC);
 Serial.print(" Speed:");
 Serial.print(speed,DEC);
 Serial.println(" kph");
 }
}
void rpm_fun()
{
 revolutions++;
}
Source Link

Wind speed measuring using Hall sensor

enter image description here Hi! I require your help regarding a problem I’m encountering. I am trying to measure wind speed using Hall sensor, Neodymium magnet & below mentioned code. But I only get "0" value for both RPM & KPH values. Can you help me to solve this?

volatile byte revolutions;

unsigned int rpmilli; float speed;

unsigned long timeold=0 ;

void setup() { Serial.begin(9600); attachInterrupt(digitalPinToInterrupt(2), rpm_fun, RISING);

revolutions = 0; rpmilli = 0; timeold = 0; }

void loop() { if (revolutions >= 1) { //Update RPM every 20 counts, increase this for better RPM resolution, //decrease for faster update

// calculate the revolutions per milli(second) rpmilli = revolutions/(millis()-timeold);

timeold = millis(); revolutions = 0; // WHEELCIRC = 2 * PI * radius (in meters) // speed = rpmilli * WHEELCIRC * "milliseconds per hour" / "meters per kilometer"

// simplify the equation to reduce the number of floating point operations // speed = rpmilli * WHEELCIRC * 3600000 / 1000 // speed = rpmilli * WHEELCIRC * 3600

speed = rpmilli 1.288053600;

Serial.print("RPM:"); Serial.print(rpmilli * 60000 ,DEC); Serial.print(" Speed:"); Serial.print(speed,DEC); Serial.println(" kph"); } }

void rpm_fun() { revolutions++; }

Thank you so much in advance for your help!

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /