hi
i am using 16f877a @ 20 mhz.
i need a keypad input but i don't want to use a lot of pins. i thought i can use a tv remote and made a receiver by using ua741 & ir photodiode.
then i implemented Thomas Henry's SonyRemote example.
the program worked but it shows different results for same buttons. i tried 6+ remotes which i found in the home and i think none of them have sony protocol.
i found a freeware for testing remote protocols by using pc's sound card and it says "Nec" for all these remotes. ( http://www.ostan.cz/IR_protocol_analyzer/ )
how can i use a (NEC) remote?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Anobium thank you.
i changed photodiode&741 with 3 pin ir receiver thing at first.
then i wrote a sub that can show the raw data.
this sub is triggered by external input (PortB.0 for 16f877a)
i hope this will help for people looking for a NEC(?) decoder.
sub irread
dim row1 as string
dim row2 as string
tick_on=0
tick_off=0
totalbits=0
bitontime=0
bitofftime=0
caperror=false
row1=""
row2=""
cls
do while irdetect =1 and tick_on<80
tick_on+=1
wait 100 us
loop
if tick_on<60 and tick_on>75 then caperror=true
do while irdetect =0 and tick_off<45
tick_off+=1
wait 100 us
loop
if tick_off<30 and tick_off>45 then
caperror=true
exit sub
end if
if caperror=true then exit sub
for countbits=1 to 32
bitontime=0
bitofftime=0
do while irdetect=1 and bitontime <255
bitontime+=1
wait 10 us
loop
do while irdetect=0 and bitofftime<255
bitofftime+=1
wait 10 us
loop
pulsetotal=bitontime+bitofftime
if bitontime>0 and bitontime<127 and bitofftime>0 and bitofftime<127 then
if pulsetotal>=100 then
if countbits<=16 then
row1=row1+"1"
else
row2=row2+"1"
end if
else
bitvalue=0
if countbits<=16 then
row1=row1+"0"
else
row2=row2+"0"
end if
end if
else
if countbits<=16 then
row1=row1+"e"
else
row2=row2+"e"
end if
end if
next countbits
print row1
locate 1,0
print row2
wait 3 s
end sub
However i need to convert these bits to a byte or word variable. What is the best option for this?
Last edit: fisyon 2015-02-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can assign your incoming bits to the correct bit in a byte or word
dim incomingdata as word
incomingdata.15= readyourvaluefromsensor
incomingdata.14= readyourvaluefromsensor
....
incomingdata.0= readyourvaluefromsensor
Anobium
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i tried your example but not works.
i can assign bit values to the elements of defined array of a byte variable.
that works but i have 32 bits total and that consumes 32 of bytes...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
first 16 bits of the stream carries adress data (device type)
and last 16 bits for button (command) data.
actually even last 16 bits are enough at the moment.
when i press a button i can see the stream on the lcd. that stream differs by which button pressed.
but then i got same vaule (ie 8) when i try to change a variable bit by bit as in your example.
example:
1011001001001101 'bit stream of a button
0011100011000111 'bit stream of another button
i got "8" for all bitstreams at assigning them into a word variable
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi
i am using 16f877a @ 20 mhz.
i need a keypad input but i don't want to use a lot of pins. i thought i can use a tv remote and made a receiver by using ua741 & ir photodiode.
then i implemented Thomas Henry's SonyRemote example.
the program worked but it shows different results for same buttons. i tried 6+ remotes which i found in the home and i think none of them have sony protocol.
i found a freeware for testing remote protocols by using pc's sound card and it says "Nec" for all these remotes. ( http://www.ostan.cz/IR_protocol_analyzer/ )
how can i use a (NEC) remote?
Have a look at this: http://sourceforge.net/p/gcbasic/discussion/629990/thread/9f266cd0/#c98f
Post a message to see if they can help.
Anobium
@Anobium thank you.
i changed photodiode&741 with 3 pin ir receiver thing at first.
then i wrote a sub that can show the raw data.
this sub is triggered by external input (PortB.0 for 16f877a)
i hope this will help for people looking for a NEC(?) decoder.
sub irread
dim row1 as string
dim row2 as string
tick_on=0
tick_off=0
totalbits=0
bitontime=0
bitofftime=0
caperror=false
row1=""
row2=""
cls
do while irdetect =1 and tick_on<80
tick_on+=1
wait 100 us
loop
if tick_on<60 and tick_on>75 then caperror=true
do while irdetect =0 and tick_off<45
tick_off+=1
wait 100 us
loop
if tick_off<30 and tick_off>45 then
caperror=true
exit sub
end if
if caperror=true then exit sub
for countbits=1 to 32
bitontime=0
bitofftime=0
do while irdetect=1 and bitontime <255
bitontime+=1
wait 10 us
loop
do while irdetect=0 and bitofftime<255
bitofftime+=1
wait 10 us
loop
pulsetotal=bitontime+bitofftime
if bitontime>0 and bitontime<127 and bitofftime>0 and bitofftime<127 then
if pulsetotal>=100 then
else
if countbits<=16 then
row1=row1+"e"
else
row2=row2+"e"
end if
end if
next countbits
print row1
locate 1,0
print row2
wait 3 s
end sub
However i need to convert these bits to a byte or word variable. What is the best option for this?
Last edit: fisyon 2015-02-06
You can assign your incoming bits to the correct bit in a byte or word
Anobium
i tried your example but not works.
i can assign bit values to the elements of defined array of a byte variable.
that works but i have 32 bits total and that consumes 32 of bytes...
Can I clarify.
You have an incoming data stream of 32 bits and you need to save this stream? Yes?
yes, i have 32 bit data stream but i have to split it 16bit & 16bit variables
Why do you have to split?
first 16 bits of the stream carries adress data (device type)
and last 16 bits for button (command) data.
actually even last 16 bits are enough at the moment.
when i press a button i can see the stream on the lcd. that stream differs by which button pressed.
but then i got same vaule (ie 8) when i try to change a variable bit by bit as in your example.
example:
Try something like. This is intended to read the 32 bit into one variable. I have not tested but something like this should work for you.
dim datastream as long
repeat 32
datastream.0 = readdatatreamin
rotate datastream left
end repeat
YES!
thanks a lot :D
Good morning, I use the google translator, someone can write an example of how to use the library "REMOTE" in nec protocol.
Thank you
please make a new thread and / or point us to the correct point of Lib
(http://gcbasic.sourceforge.net/help/_infrared_remote.html for example.)
Last edit: bed 2018-09-06