|
|
View previous topic :: View next topic |
Author |
Message |
Andrew83
Joined: 16 Sep 2008 Posts: 51
|
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue Oct 28, 2008 12:06 pm |
|
|
Andrew,
I think your problem lies here:
Code: | for (ircount=0;ircount<31;ircount++) |
then you add:
Code: | if (ircount==32)
{
irdone=true;
} |
The variable ircount will never get to 32. In my code, I had put it as one less than the total number of bits I expected to receive. Try setting it to 30.
Also, in the pulse train in the picture, there seem to be 33 bits; the last one being a 'closing' bit (I think).
I don't think you have taken that into consideration. You can assume the closing bit to be a bit0, i.e. the TSOP will be low for 560us, and then high again for 560us. The last few lines of code are for the closing bit itself, but the for loop accounts only for 32 bits; it does not account for the 'low' of the closing bit.
Rohit |
|
|
Andrew83
Joined: 16 Sep 2008 Posts: 51
|
|
Posted: Sat Nov 08, 2008 2:14 am |
|
|
Hello Rohit !
I was out of town for a few days and i wasn't able to continue my work on this project. However....now I'M BACK, ALIVE AND KICKING !!
So.... i've managed to analize more carefully the data obtained from the pickit 2 logic analizer and come to the following conclusions:
- a "ONE" seems to be represented by a combination of 600 uS LOW and 1,6 mS HIGH
-a "ZERO" seems to be represented by a combination of a 800 uS LOW and 400 uS HIGH
Doing the math, i've come across a 1,2 mS for a "ZERO" and a 2,2 mS for a "ONE" .
First, i've tried to detect only the timing for the zero ( in the sense that if i've detected a 800uS low, then it's a zero, or if i've detected a 600 uS low, then it's a one).
However, this approach (wich in my opinion would be the logical way to go) didn't get me anywhere.
So....i've tried to detect also the high part of a one or a zero.
NO LUCK !!!
I don't know what else to try !
Please look at my code http://docs.google.com/Doc?id=ddmwh28z_0dkdq28dr and give me a hint why it isn't working !
Thank you very much !! |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sun Nov 09, 2008 5:47 am |
|
|
Andrew:
It seems to me that your tolerances are extremely tight. I think this is one of the reasons for your code not working: Quote: | #define zero_min_for_zero 800
#define zero_max_for_zero 950
#define zero_min_for_one 600
#define zero_max_for_one 750
#define one_min_for_zero 300
#define one_max_for_zero 500
#define one_min_for_one 1500
#define one_max_for_one 2500
#define start0_min 8000 //no of counts to safely detect a "0" start
#define start0_max 12000 //optimal @1,1 MIPS is 9900
#define start1_min 3000 //no of counts to safely detect a "1" start
#define start1_max 6000 //optimal @1,1 MIPS is 4950 |
Also, do note that according to the NEC protocol the low (the 'low' happens because the TSOP data is inverted; actually there is a 'high' before each bit) for both bit1 and bit0 is the same length - 560us ( http://www.sbprojects.com/knowledge/ir/nec.htm ). In your definitions for zero_min_for_zero and zero_max_for_zero the equivalent time is (800/1.1)=727us and (950/1.1)=863us respectively. Similarly, you may need to correct, and also broaden the range or counts for proper detection.
I would recommend starting off with the widest possible range that you can accommodate, and then, once it works, narrowing the range to get more reliability.
Rohit |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|