IR and pulsin
2008-10-05 14:47
After some time of idleness i got to work again on my IR setup. I still have some problem understanding what happens.
This is my setup:
Transmitter: picaxe28x1, IR led (tsal6100)with cathode connected to pwm (%50 duty, 38000Hz), anode to an output pin.
Code:
pwm bla bla (set up of pwm)
pause 500
pulsout 7, 250
Receiver: picaxe28a, IR receiver and demodulator (tsop1238) properly connected.
Code:
debug
main:
pulsin INPUT_PIN, 0, w0
goto main
-----
I get strange result every time i switch the transmitter on.
Sometimes the results i get are more than one and i don't understand why (i switch on the transmitter, and on the debug appear 2 or 3 different values like 249, which is approximately correct, then 169(?) and sometimes also something close to 30).
Some other times i just get incorrect values like 169 instead 0f 240. I don't really know what is going on. If i understood well, having a 0 in the "state" field of the pulsin command tells it to begin counting only when a high to low transition occurs (that is, when the receiver sees IR modulated at 38kHz), so if i switch on my transmitter this transition only occurs once. But then why do i get more than one rresult? And why do i sometimes get incorrect ones?
strange...(for me)

looking at
looking at http://pdf.chinaicmart.com/TSO/TSOP1238.pdf i noticed:
1. burst length should be 10 cycle bursts or longer
2. after each burst which is between 10 and 70 cycles a gap time of 14 cycles is necessary
3. for each burst which is longer than 1.8 ms a corresponding gap time is necessary at
some time in the data stream. This gap should be at leas 4 time longer than the burst
seems like a lot of rules to follow - how exactly are you doing the modulation?
i've never programmed a picax - so what does "pulsout 7, 250" do? I'm guessin this is how
your doing the modulation? Is it pin 7 - 250 times at some fixed rate? Could you be
breaking one of the aforementioned rules?
actually i never thought
actually i never thought about following those rules! (i know...i'm dumb)
the pulsout commands actually sends a high pulse (=V+) to pin 7(standard output pin) of 2.5ms. The pwm command defines the modulation, and it is at 38000Hz and 50% duty cycle. The puslin in the receiver code should measure this pulse of 2.5ms lenght. I don't think i have problems with modulation, because i already made a simple program which flashes a led whenever the IR receiver detects any kind of IR light at 38kHz, which is when the output pin of the receiver goes low (it is high by default).
I don't really know if i understood the meaning of burst and cycle though. Or well, i thought i knew them but i can't really understand what it means written in that way. Could you help? (I thought a burst was delivering a whole sequence of IR light. But i don't have many ideas about what a cycle is)
even more doubts
this is what i just tried
CODE:
pulsin 0,0,w0
high 0
---
Now, this is what happens when i launch the code: output 0 goes high without me doing anything. How come?
This is the what the pulsin command does:
pulsin
Syntax:
PULSIN pin,state,wordvariable
- Pin is a variable/constant (0-7) which specifies the i/o pin to use.
- State is a variable/constant (0 or 1) which specifies which edge must occur
before beginning the measurement in 10us units (4MHz resonator).
- Wordvariable receives the result (1-65535). If timeout occurs (0.65536s) the
result will be 0.
Function:
Measure the length of an input pulse.
Information:
The pulsin command measures the length of a pulse. In no pulse occurs in the
timeout period, the result will be 0. If state = 1 then a low to high transistion
starts the timing, if state = 0 a high to low transistion starts the timing.
Use the count command to count the number of pulses with a specified time
period.
---
Now, i am not making input 0 (pulsin input) go from high to low in any way (i even trying putting 2 or more pulsins in the code but nothing changes). What i noticed though is that the more pulsins i put, the more time i have to wait before seeing the led light up. But still, should the program stop untile input 0 goes from high to low? ahhhh this thing is making me go mad.
So the thing here is: the timeout is on even if the timing of the incoming pulse hasn't started. But still this won't add up with the previous code...hmm ( the one in the previous posts i mean)