2

Well I am working on old textile machines, it is taking motor RPM with ISR. I want to read this RPM and publish on web. but the output voltage of this old system is 0 and 22 Volt. (0 Volt when the infrared light comes into the gap in the disk, 22 volt when the infrared light see the photocell). if I try to read this data I see 17.000 - 18.000 RPM while actual RPM was 1600. I cant read true RPM. I suspect input signal voltages which is 0 and 22 Volts. I don't think Arduino UNO works in this voltage range but I cant see any info at docs. voltage divider with 0 - 2.2 volts I have dropped but still did not work. what is the ideal voltage level for attachInterrupt() command. I am using klon arduino uno (Arduino Uno R3 SMD CH340 Chip - Klon Arduino Uno )

Also are there ane filter to prevent interference I am using long wire (100 meter)?

this is my code

int encoder_pin = 2; // pulse output from the module
unsigned int rpm; // rpm reading
volatile byte pulses; // number of pulses
unsigned long timeold;
// number of pulses per revolution
// based on your encoder disc
unsigned int pulsesperturn = 12;
void counter()
{
   //Update count
   pulses++;
}
void setup()
{
   Serial.begin(9600);
   pinMode(encoder_pin, INPUT);
   //Interrupt 0 is digital pin 2
   //Triggers on Falling Edge (change from HIGH to LOW)
   attachInterrupt(0, counter, FALLING);
   // Initialize
   pulses = 0;
   rpm = 0;
   timeold = 0;
}
void loop()
{
   if (millis() - timeold >= 1000) {
      //Don't process interrupts during calculations
      detachInterrupt(0);
      rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
      timeold = millis();
      pulses = 0;
      Serial.print("RPM = ");
      Serial.println(rpm,DEC);
      //Restart the interrupt processing
      attachInterrupt(0, counter, FALLING);
   }
}
  • 1
    The interrupt signal is assumed to be a digital input signal of 0v or 5v (for an Arduino Uno, which is a 5v arduino board). You need a voltage divider which is two resistors to bring the 22v down to 5v. For example r1=33k and r2=10k (for 5.1v, close enough). Perhaps you need a capacitor of 1nF parallel to r2 to filter spikes and noise. Please check the links in your question, don't give links to something that requires to log in. The 100 meter cable is a serious problem. What kind of cable do you use? Can you put the arduino near the engine? The code in the loop is not okay. – Jot Jan 27 '19 at 8:47
  • You are awesome, I've checked links. 100 meter cablo there is no The voltage drop, is it still a problem? What happens if it happens. "Can you put the arduino near the engine?", no because there are 20 machines.Also where is the problem in "loop" – memet569 Jan 27 '19 at 18:52
  • "100 meter cablo there is no The voltage drop, is it still a problem? " You have a 100 meter antenna. What happens if you pick up disturbances from other sources, do you think that might matter? – Rudy Jan 27 '19 at 21:09
  • Use an optocoupler, then the input voltage can be anything and the data is a bit more robust. – ctrl-d Jan 27 '19 at 21:27
  • @ctrl-d If the signal can output enough current for a opto-coupler, that would be a good solution. With a shielded cable and a current as signal (instead of a voltage). Maybe it is possible, but it requires some electronics skills to make it work. – Jot Jan 27 '19 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.