Using a TSOP7000

Hello everybody,

I’m trying to make a lasergame in which four people stand in front of a wall with sensors and as soon as a LED next to the sensor lights up, people have to shoot at that sensor. The one that hits the first gets the most points, the one that hits second gets less points, etc.
In this I use the Aruino Uno R3.
I use the TSOP7000 to registrate the shots.
I use the TSAL6200 to shoot.

To test the registration of shots I did the following:

I have wired the TSOP7000 up as in the datasheet with a pull up resistor from the data pin to +5V, the Vcc with a 100 Ohm resistance to +5V, a 4.7uF capacitor between Vcc and GND, the GND to the GND of the arduino and the datapin to pin 2 of the Arduino. The code on this Arduino is as follows:

char updown = 0;
char state = 0;
unsigned long timer=0;
void setup()
{
Serial.begin(9600);
attachInterrupt(0, incomingshot1, CHANGE);
}
//----------------------------------------------------------------------------------------------------------------------------------------
void loop() // run over and over
{
switch(state){
case 0:
break;
case 1:
Serial.println(timer);
state = 0;
break;
}
}
//----------------------------------------------------------------------------------------------------------------------------------------
void incomingshot1() { //when the inputsignal on pin 2 changes this interrupt is called
if(updown==0){ //the first change is always a falling edge
timer = micros(); //the time is determined for a measurement
updown=1; //the outputsignal of the TSOP7000 is LOW
}
else{ //the else takes care of the rising edge
timer= micros() - timer; //the pulselength is now in timer
state = 1; //state becomes 1 to print the pulselength
updown=0; //the outputsignal of the TSOP7000 is HIGH again
}
}
//----------------------------------------------------------------------------------------------------------------------------------------

Each time the Arduino sees a pulse on pin 2, it prints the pulselength in microseconds.

Another Arduino has to generate the pulses with a carrier of 455 kHz. To do this I used the nop statements.
The code is as follows:

void setup(){
pinMode(1,OUTPUT);
}
void loop(){
PORTD |= (1<<1);
asm(“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”);
PORTD ^= (1<<1);
asm(“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”“nop\n\t”);
//This pulse is made 100 times and then there is a delay.
delay(3000);
}

For the sake of shortness of this post I only copied one pulse, but this pulse is made 100 times and then there is a delay.
The arduino controls the led with a mosfet. The led is in series with a 50 Ohm resistor and is connected to an 11.1 V battery.

Here comes the problem. When I hold the LED very short in front of the TSOP7000, this is printed:
216
224
224
224
228
224
220
220
224

So I assume that, because I made 100 pulses, the frequency of those pulses is close to 455 kHz. However, if I make the distance bigger and bigger, till like 3 meters, this is the output:

216
220
228
224
220
224
216
212
12
188
92
220
92
16
56
44
84
24
16
8

So my question is, what is going wrong? Why does the sensor not give an output of around 220 microseconds anymore at bigger distances? Is this because the wavelength of the TSAL6200 is 940 nm instead of 870 nm, the wavelength at which the TSOP7000 is the most sensitive? Is the carrier not 455 kHZ? Is there something wrong with my code?

I hope someone can help or has suggestions.

Sincerely,

Marcel