how to measure falling edge signal time?

hi,

i’m using arduino uno and this flight computer (https://altusmetrum.org/TeleMetrum/). my goal is send low signal from flight computer to the arduino uno input pin.

this fligh computer always sending high signal, but when it detect apogee then sends 50 ms low signal. so i want to catch this 50 ms signal with interrupt.

but when i use arduino interrupt pins (pin2, pin3), arduino triggered even if flight computer doesn’t send any signal.

on the other hand, when i touched jumper cable to the any of the arduino pin, arduino triggered like flight computer sends signal and my interrupt function starts to work.

how can i solve this problem? is there any way to measure signal time which flight computer sends to arduino?

here is my code:

#include<Servo.h>

Servo myServo1;
Servo myServo2;

int intPin2 = 2; // Select INTERRUPT pin
int intPin3 = 3;

volatile byte state1 = LOW;
volatile byte state2 = LOW;


volatile uint8_t flag1 = 0;
volatile uint8_t flag2 = 0;

 

void setup() {


  pinMode(intPin2, INPUT_PULLUP);
  pinMode(intPin3, INPUT_PULLUP);
  
  //interrupt configure
  attachInterrupt(digitalPinToInterrupt(intPin2), interruptOne, FALLING);
  attachInterrupt(digitalPinToInterrupt(intPin3), interruptTwo, FALLING);
  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);

  
  Serial.begin(9600);
  
  myServo1.attach(9);
  myServo2.attach(10);
}

void loop()
{  

if (flag2 == 1) {
  
  digitalWrite(13, !state2);
  myServo2.write(270);

}

if (flag1 == 1) {

  digitalWrite(12, !state1);
  myServo1.write(270);
}


}


void interruptOne() {

  flag1 = 1;
  
}


void interruptTwo() {

  flag2 = 1;
    
}

50ms is an geological age - why do you think you need an interrupt?

You have glitches on your signal cables. Even a fraction of a microsecond glitch will trigger an interrupt.

In general logic signals don't travel far without this sort of problem - perhaps you have long cables? Or
poor layout / lack of ground return? Some sort of signal conditioning would then be needed to eliminate noise spikes

@TheMemberFormerlyKnownAsAWOL i need an interrupt, because i don't know when flight computer will send the signal. so i have to always listen the input pin if it get a signal.

@MarkT thank you for your advices, i'll try to control cables length and their connection.

What is keeping your code busy for so long that it misses a 1/20th of a second pulse?

If there are glitches there are glitches, whether or not you use interrupts, this needs fixing first

i’ll try to control cables length and their connection.

Well how about explaining the details here?

@TheMemberFormerlyKnownAsAWOL, actually i’m not sure that i could understand?

@MarkT, firstly i’m doing a rocket. there is a recovery system. flight computer doesn’t control servo motor. but i have to use this flight computer and servo motors. when signal received to arduino from fligt computer, arduino starting to control servo and parachute deploys.

in the flight computer shematic there is 6 screw terminal. two’s for switch, two’s for deploy main and drug parachute and the other’s for ground.

i use arduino pin’s 2 and 3. i use external pull up for connection between arduino interrupt pins and flight computer fet_a and fet_b which send high and low signal. i already have used breadboard and jumper cable.

i want to make a pertinaks to avoid glithcs.

You are mixing 3.3 volts on the flight computer with 5 volts on the Arduino. So, your interrupt pins are already ALMOST low when you make the connection. Doesn't take much noise to drop the 3.3 to make the Arduino think it needs to interrupt.

Should use something to translate the 3.3 volt to 5 volt signal.

Paul