Infrared Xmitter/Receiver
AKruzel
Posts: 25
hello,
I'm trying to get the infrared xmitter and receiver to work with the propeller and the issue is that when i move an object in front of the led, the receiver outputs a low signal but only for about 5 seconds or so and then goes back high and stays high even with the object in front of the LED. I tested the IR sensor circuit with my basic stamp and it worked just fine so i believe the wiring is correct. anyone have any ideas of what could be the issue with my propeller code? I did try setting the SqrWave.Freq to continuously output 38kHz and toggle the dira for pin 0 from output to input to control the output of the sine wave but when reading the terminal i would only receive a low from the receiver exactly at the same time i put an object in front of the LED and then it would immediately go back high. Code is attached. Any assistance would be greatly appreciated!
Adam
I'm trying to get the infrared xmitter and receiver to work with the propeller and the issue is that when i move an object in front of the led, the receiver outputs a low signal but only for about 5 seconds or so and then goes back high and stays high even with the object in front of the LED. I tested the IR sensor circuit with my basic stamp and it worked just fine so i believe the wiring is correct. anyone have any ideas of what could be the issue with my propeller code? I did try setting the SqrWave.Freq to continuously output 38kHz and toggle the dira for pin 0 from output to input to control the output of the sine wave but when reading the terminal i would only receive a low from the receiver exactly at the same time i put an object in front of the LED and then it would immediately go back high. Code is attached. Any assistance would be greatly appreciated!
Adam
Comments
a waittime of 1 millisecond is pretty short. For testing you should use waittimes in the area of 1-3 seconds.
you hae only one waitcnt-command this means I guess sending aprox 500 characters per second does fill the receivebuffer of pst quickly.
You wrote something about control a sine-wave through toggling dira: I don't understand that as dira is not toggled in your code. Where does the sinewave come from? What do you mean by that?
Please provide more details of how you did your testing and what you mean by controling the sinewave.
best regards
Stefan
with regards to testing, it was just placing my hand in front of the led and receiver. the receiver would output high when i didn't have my hand there, when i put my hand in front of the led and receiver, i would receive a low for about 5 seconds and then the signal would go back high and stay high with my hand in front of the LED and receiver.
Thanks for the quick reply StefanL38
"H" means your hand.
describing code with sentences is only medium understandable. If you have access to your propeller-things and internet-access please post your actual code.
For analysing what is going on I would slow down the repeat-loop through a waitcnt(ClkFreq + cnt) command (delays one second).
If this does not work I would even do a more basic testing like this
or I would use EZLog from hannoware to show the value of variables
http://hannoware.com/ezlog/
Does the datasheet of the receiver say something about automatic adaption to ambient light?
I'm not too familiar with IR-receivers but if I remember right the carrier is used to get independent of ambient light and the data has to be "put on" the carrier-signal to be transmitted.
What does the datasheet of the IR-receiver say about how to "put on" the logical value onto the carrier-signal?
best regards
Stefan
I don't have access to my propeller stuff now but i want to answer your questions so we can nail this problem down asap. I plan to attach the code with dira as soon as i get home. But with regards to your questions:
I put my hand in front of the LED AND receiver, i don't believe putting my hand between them would do anything. As for the simple test you provided, i did something similar. I put my DDM on the output of the receiver to see if the output sits around the TTL threshold when i put my hand in front of the LED to reflect the infrared but when i do so, it goes all the way to 0V and after 5 seconds or so, bounces back up to 3.6V. As mentioned before, i use the exact same circuit with my basic stamp 2 and it works fine, as long as i have my hand in front of LED and receiver, the receiver outputs a low. there is a 10k between the receiver output and propeller input (P1) and a 1k between the LED anode and propeller output (P0). I'm thinking there has to be some issue with my code, somethign small i'm overlooking.
Thanks again,
Adam
(5V - 1.3V) / 1000 Ohm = 3,7 mA. Which is already a quite low current.
Now at 3.3V of the propeller (3.3V - 1.3V) / 1000 Ohm = 2 mA. So this current might be too weak to drive the LED.
usual LEDs seeable light) are made for a current of 20mA and I guess IR-LEDs are in the same range. To know it well we have to take a look in the datasheet of the IR-LED you are using.
If you don't have a datasheet you should measure the voltagedrop across the IR-LED
the exact formula is current-limiting resistor = (Supply-voltage - LED-voltagedrop) / LED-current
another example
Supply-voltage 5V
LED-voltagedrop 1.8V
LED-current 15mA
R = (5V - 1.8V) / 0.015A = 213 Ohm.
Assuming the LED-current is 20mA
For supplying the IR-LED through a Prop-IO-pin you would need a (3.3V - 1.3V) / 0.02A = 100 Ohm
After looking into two datasheets of IR-LEDs they say LED-current 100mA
For this current you need a transistor. A Prop-IO-pin can do only 30mA.
For 30mA the resistor would be (3.3V - 1.3V)/ 0.03A = 67 Ohm.
10k-resistor between receiver and Propeller-IO-pin might be a resistor with a to high value. What is the voltage that the receiver has on its output? Is it 3.6V?
3.6V can be connected through a (3.6V - 3.3V) / 0.0005A = 600 Ohm-resistor. The Propeller-IO-pins have an internal clamp-diode that can stand a current of 500µA.
These clamp-diodes "drive away" voltages above 3.3V. So with 3.6V (3.6V - 3.3V) / 500µA = 600 Ohm.
What I do still not understand is why it should be impossible to have the IR-LED on the left side and the receiver on the right side and interrupt the IR-light with your hand between the IR-LED and the receiver??
Is the IR-LED and the receiver mounted into one and the same housing? If you could upload a picture of your setup this would clear things up easily.
EDIT: it's always good to take a look into the datasheets.
Some time ago I ordered a TSOP 31238 IR-receiver. carrier-signal 38kHz just to have it at home in case I want to do IR-experiments.
Now I took a look into its datasheet. If I understand the pictures and diagrams right. a logical bit high is represented as 38kHz-carrier is on for some time.
A logical bit low is represented as 38kHz-carrier is OFF for some time.
I haven't done such a test yet. Was coming to my mind right now.
It might be a problem of the noise-suppression:
The datasheet says If understand right
for proper testing you need a signal-sequence of 10-16 bits where logical low and logical high are defined as different long "carrier-on-signal" which are repeated
after a pause according to the specification of the datasheet.
Now for testing this an oscilloscope would be good.
best regards
Stefan
This along with the 38KHz (dependant on the system) modulation rates as well.
You provided very interesting insight into at least some functions that the IR Receiver could have. I believe what i'm seeing is actually noise cancellation, the fact that it the receiver will output a low as soon as i put my hand in front of the LED and receiver for about 5 seconds or so and then go back high even with my hand still there. According to what you wrote and looking into it more, afte a receiver receives a certain signal for a certain amount of time it may ignore it thinking it's noise. I researched more of this topic and found others that encountered the same issue so i'm going to plan to play around with outputting the signal to the LED, reading in the output from the receiver and shutting off the output to the LED for a certain amount of time before sending the signal to the LED again. Unless i completely missed it, the spec sheet for the parallax IR receiver doesn't mention this as a function of it's receiver.
Apologies, got busy last night and couldn't post the code with dira[] turning on and off the signal to the LED, will provide that asap...regardless i'd still like to know why that isn't working.
Thanks again for the insight!
Adam
http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/177/Default.aspx?txtSearch=ir+receiver
This device seems not to have noise cancellation. But some other things to care about.
The signal must be 38kHz with a dutycycle of 50%. Meaning 50% of the time the LED is on 50% of the time LED is off.
The testcircuit shows an IR-LED connected to a BS-pin through a 220Ohm-resistor. (5V-1.3V) / 220 Ohm = 17 mA
to get 17 mA at 3.3V you need (3.3V - 1.3V) / 0.017 = 100 Ohm.
The Output-pin is connected directly to the inputpin. The device as an internal Pullup-resistor with 20kOhm.
The device needs a 5V powersupply (min 4.7V) and then the output should be connected to a voltage-divider
IR-Output
x
39kOhm---GND
IR-receiver supplied with 5V at "x" will be a voltage of 3.3V
5V (20kOhm + 39kOhm) * 39kOhm = 3.3V. So "x" can be connected to the propeller-IO-pin.
You schould test the voltage at x with a DMM before connecting it to the prop-IO-pin.
You should measure the current through the IR-LED when driven with a prop-IO-pin
You should measure the on/off times and frequency of the prop-IO-pin supplying the IR-LED
after these checks you know a lot more where the problem (was) or still might be
See attached schematic
What's not clear to me from the datasheet is if the carrierfrequency is really 38kHz
So a test with the other carrier-frequency for PNA4601M (36.7 kHz) should be done too.
Now as you can see that this device works different than the ones I have looked up before.
is it really this device you are using?. If not please provide the exact partnumber and manufacturer.
best regards
Stefan
guess I narrowed down the problem
I analysed the output of pin 0 (IR-LED) with an oscilloscope.
1.) with your code you are sending a frequency of averaged 21kHz.
a part of the time 38KHz and another part 0 Hz.
2.) using SqrWave.Freq(0,0,0) leaves pin 0 sometimes on high sometimes on low
which means IR-LED sometimes full on sometimes off.
I guess the attached code which does send 1 38kHz-signal for 2 seconds then makes a pause of two seconds then repeat should work.
It sets pin 0 as input to stop the 38kHz carrier-signal
try this code and report what you get
@who it might concern: an oscilloscope helped a lot in this case.
somebody coded a "poor man's oscillscope" for TV or VGA-output.
to make this code even more "cheaper" Ariba has a PC-software prop-terminal that emulates tv-output
so all that is nescessary to display the signal is a propeller and the PC you already have.
could the author chime in and tell if will code a variant that is using PropTerminal?
@Hanno: Viewport could do this too.
If the author don't want to. ViewPort still needs a learning curve of some hours and has traps for real beginners. How about a screenshot for screenshot and mouseclick for mouseclick tutorial that eliminates really every misstepping or misconfiguring viewport as an oscilloscope?
Showing minimum 5 examples where the users code has to be inserted by a simple copy&paste into a prepared
ViewPort-sample-code. Showing really every detail where to start copying and where to stop.
If this isn't possible by start copying here and end copying there. The five examples have to show which parts have to be copied and which not. Screenshot for screenshot. Otherwise newbees will find it difficult to use it.
best regards
Stefan
I will definitely give this code a shot asap, thank you! i was going to spend a good deal of this holiday weekend working on other sensors but after this issue, i may transition over to learning how to use ViewPort so i can debug these problems myself on the oscilloscope function. You mention there are some traps for beginners, i'm by no means brand new at microcontrollers or using an oscilloscope, did this in school, but i'm curoius as to what traps you're speaking of. Could you give some general examples or is there another thread or webpage that goes into more detail? This would be helpful figuring i'm going to try and tackle ViewPort this weekend and i'll already have an idea of what to look out for.
Thanks again for all your help Stefan,
Adam
I dont remember my problems in detail. But I had some problems to get Viewport working with my own code and then some problems to configure ViewPort to show me what I wanted.
and I remember somebody made a additional tutorial with useful hints what details are important. But I can't remember who and how the file was named.
Already did a search with Everything.EXE http://www.voidtools.com/ on my garddisks but did not find i.
Hanno has released a new version of the manual "ViewPort v4 December 2010" I guess there are improvements over the previous version but I haven't read much in it yet.
best regards
Stefan