I'm having a bit of an issue, and wanted to see whether or not what I'm noticing with my set up is somehow due to a faulty script.
I have a fairly simple set up—just an IR LED emitter and an IR receiver, which responds to 38KHz modulated IR pulses. I've pasted my code below. The goal of my set up was to (1) see if my receiver is working and (2) see what degree of physically blocking the communication between the emitter and the receiver (placing my hand between them, for example, and varying the distance) is enough to cause a total signal loss (so a static HIGH output from the receiver).
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(6, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(6, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
void SendPowerCode() {
pulseIR(1500);
delayMicroseconds(200);
pulseIR(1440);
delayMicroseconds(200);
pulseIR(600);
delayMicroseconds(1060);
pulseIR(1400);
delayMicroseconds(240);
pulseIR(1400);
delayMicroseconds(260);
pulseIR(560);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(520);
delayMicroseconds(1140);
pulseIR(520);
delayMicroseconds(1120);
pulseIR(1360);
delay(70); // wait 70 milliseconds before sending it again
pulseIR(1500);
delayMicroseconds(200);
pulseIR(1440);
delayMicroseconds(200);
pulseIR(600);
delayMicroseconds(1060);
pulseIR(1400);
delayMicroseconds(240);
pulseIR(1400);
delayMicroseconds(260);
pulseIR(560);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(540);
delayMicroseconds(1100);
pulseIR(520);
delayMicroseconds(1140);
pulseIR(520);
delayMicroseconds(1120);
pulseIR(1360);
}
void setup () {
pinMode (6, OUTPUT);
}
void loop () {
SendPowerCode();
}
After setting up the circuitry and hooking up my oscilloscope, I can see that my receiver is working. However, no matter how I try physically block the communication between them—even going as far as completely wrapping one of them in heat-shrink tape—the signal does not drop. How is this possible? Is there something wrong with the script?
Are you sure the material you are using for blocking is opaque to IR? Are you sure the IR is not going around your blocking by bouncing off, for example, walls?
If the send signal was removed and the receiver IR was hooked up to power and there was no signal produced in the receiver then the odds of an oscillation build-up are very very low. I'd look to discover why the sender is always seeming to send.
johnwasser:
Are you sure the material you are using for blocking is opaque to IR? Are you sure the IR is not going around your blocking by bouncing off, for example, walls?
I've tried (1) my fingers (2) electrical tape to completely wrap around the IR emitter. I'll try aluminum next.
I had problems a bit similar to this, something was wired up wrong.
Instead of cutting the power to the emitter, can you leave everything as it is and just unplug the emitter. Does that change anything?
steve1001:
I had problems a bit similar to this, something was wired up wrong.
Instead of cutting the power to the emitter, can you leave everything as it is and just unplug the emitter. Does that change anything?
What do you mean by not cutting the power to the miter but at the same time unplugging it?
I've no idea of your circuit or set up, so just throwing some things out here, shot in the dark.
Power everything up as you have been doing. Then just withdraw the emitter, without changing anything else. Does anything change at the receiver end?