12 IR laser trip wires 10m apart from each other: false triggering

Hello there,

I'm working on a project where I need to measure the time position of a vehicle over a 100m length, for many times (tests). Simultaneously I need to take wind measurements with an anemometer.

I'm doing it using:

  • Arduino Mega 2560;

  • LCD shield ( Arduino_LCD_KeyPad_Shield__SKU__DFR0009_-DFRobot ) to read if the test is running properly;

  • MicroSD breakout for logging time and win data;

  • 12 this IR laser beams (approx. sensors are 10m apart from each other) of this kind https://arduino-info.wikispaces.com/InfraredBeamPair;

  • A Young 2D ultrasonic anemometer model 85000;

  • 12 LED that indicate when the vehicle has broken each laser beam.

  • IR Emitters are powered externally each one with a battery pack (yeah 4xAA batteries).

  • IR receivers are powered externally too. However, they are powered in parallel with a 6V battery (which effectively gives about 5.5V).They are wired together with this kind of "cable stripe" (FLAT RIBBON CABLE RAINBOW 14PINS - PER FOOT), in such a way that at 0m the 6V battery connects (pos and neg) to 2 cords of the cable and then the cable runs 100m to the end and every 10m IR receiver just draw current from such cable

  • Arduino is powered with 2x6V batteries in such a way that ground is shared between arduino and IR receiver (this is for a proper reading of the signal from IR receivers).

  • Anemometer is powered externally with a farther set of 2x6V battery.

  • Signal from IR receivers (~4V if laser beam non broken, ~0V otherwise) is sent back to Arduino via other cords comprised in the "cable stripe".

The core of the code I'm using is the following. The whole code is attached.

  // 4. Measurement Phase///
  ///////////////////////////



  for (unsigned char pin = 0; pin < LBSensorPinsTot; pin++) //check SELECT so that if someone is gong to slow to reach last sensor, data can be saved anyways
  {

    while (digitalRead(LBSensorPins[pin]) == HIGH && digitalRead(SelectButtonPin) == HIGH )
    {

      if ((WindTime[wr] - WindTime[wr - 1]) >= intTime && wr < wrmax) //WRITE IN HERE 1Hz anemometer readings
      {
        WindTime[wr] = micros();
        AN_Dir_SensorRead_1sec[wr] = analogRead(ANSensorsPins[0]);
        AN_Vel_SensorRead_1sec[wr] = analogRead(ANSensorsPins[1]);
        wr++;
      }
      WindTime[wr] = micros();

    }

    ReadTime[pin] = micros();
    AN_Dir_SensorRead[pin] = analogRead(ANSensorsPins[0]);
    AN_Vel_SensorRead[pin] = analogRead(ANSensorsPins[1]);
    digitalWrite(LBLEDPins[pin], HIGH); //turn on related LED, when beam broken. 36 to 47 are Led pins.
    

  }

 
  }

Now, I had problem of false triggering of IR sensors. In particular, sometimes and pretty randomly, as soon as one IR sensor triggers the next one triggers too. Note that this false triggering doesn't happen consistently, i.e. for every test different beams shows this unexpected behaviour. Note also that this happen almost always for sensors that are the furthest from Arduino (50m to 100m)
I changed many times the code, I checked wiring, connections etc. But I don't understand why it is not always working.
Can anybody suggest what else should I look at? Is there any problem with my code? Is there any problem in having the sensors so far apart? Can Arduino handle these kind of tasks?

Thank you very much! Simone

time_switches_vehicles.ino (17.8 KB)