Uno, fastest way to monitor 4 inputs?

I have a circuit with 4 outputs that I wish to monitor using the Uno. I want the fastest way to time stamp (i.e. micros() ) the rising edge of the signals as they come in. My thought was pinchangeint() but I can even get a code to compile. Is the pinchangeint() my best approach or is there any ideas for an accurate read?

Doesn’t compile sorry! Perhaps it will shed some light on what I am trying to do. For simplicity the code is with only 2 of the 4 inputs.

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN1 2;
#define PIN2 3;
unsigned long T1;
unsigned long T2;

void func1 ()
{ T1=micros();
};

void func2 ()
{ T2=micros();
};

void setup(){
    pinMode(PIN1, INPUT);
    pinMode(PIN2, INPUT);
    digitalWrite(PIN1, LOW);
    digitalWrite(PIN2, LOW);
    PCintPort::attachInterrupt (PIN1, func1, RISING); //look for the rising of pin and call func
    PCintPort::attachInterrupt (PIN2, func2, RISING);
}  

void loop() {
  //checks that each measure has been taken
  if (T1 != 0);
    if (T2 != 0);
      {void loop() {
        Serial.print("Hit1:");
        Serial.println(T1);
        Serial.print("Hit2:");
        Serial.println(T2);
     delay(200);// waits and clears for next test
  T1=0;
  T2=0;
      }
   }
}

The forum lost my 1’st response so here’s my short pissed off (not at you) answer. See where you’re missing {,}.

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN1 2;
#define PIN2 3;
unsigned long T1;
unsigned long T2;

void func1 ()
{ 
  T1=micros();
};

void func2 ()
{ 
  T2=micros();
};

void setup(){
  pinMode(PIN1, INPUT);
  pinMode(PIN2, INPUT);
  digitalWrite(PIN1, LOW);
  digitalWrite(PIN2, LOW);
  PCintPort::attachInterrupt (PIN1, func1, RISING); //look for the rising of pin and call func
  PCintPort::attachInterrupt (PIN2, func2, RISING);
} 

void loop() {
  //checks that each measure has been taken
  if (T1 != 0);
  {
    if (T2 != 0);
    {
      void loop(){
        Serial.print("Hit1:");
        Serial.println(T1);
        Serial.print("Hit2:");
        Serial.println(T2);
        delay(200);// waits and clears for next test
        T1=0;
        T2=0;
      }
    }
  }
}

Is Pin change library copied to your PC?

Also think about…

http://arduino.cc/en/Reference/PortManipulation

#define PIN2 3;

Normally one does not use a semicolon with a #define, so I’m not sure what that does.

RMjimbob:

Doesn’t compile sorry!

Doesn’t tell very much either! What was the error message? It should have been a bit more descriptive of what was wrong.

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#define PIN1 2
#define PIN2 3
unsigned long T1;
unsigned long T2;

void func1 ()
{
  T1=micros();
};

void func2 ()
{
  T2=micros();
};

void setup(){
  pinMode(PIN1, INPUT);
  pinMode(PIN2, INPUT);
  digitalWrite(PIN1, LOW);
  digitalWrite(PIN2, LOW);
  PCintPort::attachInterrupt (PIN1, func1, RISING); //look for the rising of pin and call func
  PCintPort::attachInterrupt (PIN2, func2, RISING);
}

void loop() {
  //checks that each measure has been taken
  if (T1 != 0);
  {
    if (T2 != 0);
    {
      void loop(){
        Serial.print("Hit1:");
        Serial.println(T1);
        Serial.print("Hit2:");
        Serial.println(T2);
        delay(200);// waits and clears for next test
        T1=0;
        T2=0;
      }
    }
  }
}

Sorry with the above corrections the error is "sketch_dec02a.ino: In function ‘void loop()’:

sketch_dec02a:33: error: a function-definition is not allowed here before ‘{’ token"

Not sure if it makes sense but I’m trying to get the time stamps of events 1 and 2 before it prints to the serial monitor.

Really?

You can’t find the problem in that block of code?

Really?

Ha. at first you comment bugged me but then I went through it again and caught it… thanks for the patience!

I don’t think the if statements preceding it will work either. They are ending in semi-colons, so they end there. The code in the curly-brackets behind it are executed independently. Atleast, C would be that strict, maybe Arduino is less strict.