dhouston,
When I change code, old result 0 turn to 255. All the keys press are same.

Header Logic 0 Logic 1 Logic 1 logic 0
2400 600 600 600 1200 600 1200 600 600
x a b c d e f g h i j
+------------------------+ +------+ +--------------+ +--------------+ +------+
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
---+ +------+ +------+ +------+ +------+ +------
x____________________________|_____________|______ _____________|___________________|_____________|
pulsin header 1st loop 2nd loop 3rd loop 4th loop
return width of length
-- code start -------------------------------
Code:
pulsin irIn , 0 , Header 'Line 1
for i =0 to 3
pulsin irin, 0 , tmp 'line 3
if tmp > 90 then
body.0[i] = 1 'line 5
else
body.0[i] = 0 'line 7
endif
next
-- end of code -------------------------------
I think pulsin work as follow:
1. pulsin is timeout when no rising edge was found. return width is zero.
2. pulsin is time out when rising edge was found and then until falling edge. return the width length.
so pulsin in code run like that:
Line 1 : pulsin start measure (x) to end edge (b). Width is (a) to (b) so Header = 2400 (space (x) to (a) is not count.
Loop 0 (1st loop)
Line 3 : pulsin start measure (b) to end edge (d). Width is (c) to (d) so tmp = 600 (space (b) to (c) is not count.
Line 5 and 7: see the width lenght (not space) and decided logic 0
Loop 1 (2nd loop)
Line 3 : pulsin start measure (d) to end edge (f). Width is (e) to (f) so tmp = 1200 (space (d) to (e) is not count.
Line 5 and 7: see the width lenght (not space) and decide logic 1
Loop 2 (3rd loop)
Line 3 : pulsin start measure (f) to end edge (h). Width is (g) to (h) so tmp = 1200 (space (f) to (g) is not count.
Line 5 and 7: see the width lenght (not space) and decide logic 1
Loop 3 (4th loop)
Line 3 : pulsin start measure (h) to end edge (j). Width is (i) to (j) so tmp = 600 (space (h) to (i) is not count.
Line 5 and 7: see the width lenght (not space) and decide logic 0
PULSIN can only measure the width length.
When this code is used for NEC Protocol, all pulse are equal depending upon if statement (Logic 0 or 1)
Because In NEC, logic 1 or 0 is determined by space length. How can I measure space with pulsin.
lester
Thanks.
I already read Les Johnson's article and "Section 6: Experimenting with Remote Control" of that book. I already tested it. All are ok. But it's Sony IR Protocol (Pulse Width Modulation) that quite different from NEC IR Protocol (Pulse Distance Modulation).
I admire you and dhouston when I found your join date.
I start and learn picbasic at last week of July of this year. I search and collect PIC books (picbasic, C and Assembly) and article. I found about 60 books and articles. But I cannot find enough explanation for a command. eg. I want to know pulsin in detail. How pulsin work? examples relating pulsin. Pulsin in "PicBasic Pro Manual" is general. Picbasic is best language for me although I've little experience with C Language.
Moe
Bookmarks