Infra red comm's

beny1949

Senior Member
just been looking through the manuels, and I must say i am quite disapointed that i cannot change the device id for the infrain(2) command. i want to have a series of small robots which will be able to respond to the channel being changed on the tv ect, but i also want them to be able to talk to each other.

is it possible to do a serout or pulseout to comunicate, using the same hardware as you would for irout?

i would use RF but, it doesnt seem to be quick and easy like IR, and these 'bugs' will run off a 1.5 volt battry with one of these maxim buck boosters.

Thanks,
Ben

 

Edited by - beny1949 on 03/06/2007 14:26:41
 

hippy

Technical Support
Staff member
You could always use two or more INFRAOUT commands to send the data. You'd need to use some of the bits in the data itself to indicate which byte of a stream it were in case the receivers get out of step or miss data.

With two INFRAOUT's, you could send 12-bits of data, three would allow 16-bits, which is probably more useful.

Untested, passing a word of data from w2 ...<code><pre><font size=2 face='Courier'>TransmitW2:
b0 = w2 &amp; $FC00 / $400 : INFRAOUT 0,b0 ; %abcd ef-- ---- ---- =&gt; %00abcdef
b0 = w2 &amp; $03E0 / $020 | $40 : INFRAOUT 0,b0 ; %---- --gh ijk- ---- =&gt; %010ghijk
b0 = w2 &amp; $001F | $60 : INFRAOUT 0,b0 ; %---- ---- ---l mnop =&gt; %011lmnop
Return

ReceiveLoop:
Do
INFRAIN2
b0 = infra
If bit6 = 0 Then
w2 = b0 * $400 ; %00abcdef =&gt; %abcd ef-- ---- ----
Else
If bit5 = 0 Then
w2 = b0 &amp; $1F * $020 | w2 ; %010ghijk =&gt; %---- --gh ijk- ----
Else
w2 = b0 &amp; $1F | w2 ; %011lmnop =&gt; %---- ---- ---l mnop
Gosub ObeyDataInW2
End If
End If
Loop </font></pre></code> If you want some error checking on receive ...<code><pre><font size=2 face='Courier'>ReceiveLoopWithErorChecking:
b1 = 0
Do
INFRAIN2
b0 = infra
If bit6 = 0 Then
w2 = b0 * $400 ; %00abcdef =&gt; %abcd ef-- ---- ----
b1 = 1
Else
If bit5 = 0 Then
If b1 = 1 Then
w2 = b0 &amp; $1F * $020 | w2 ; %010ghijk =&gt; %---- --gh ijk- ----
b1 = 2
Else
b1 = 0
End If
Else
If b1 = 2 Then
w2 = b0 &amp; $1F | w2 ; %011lmnop =&gt; %---- ---- ---l mnop
Gosub ObeyDataInW2
End If
b1 = 0
End If
End If
Loop </font></pre></code> That simply checks the bytes arrive in the correct order. Ideally the data should be sent as a packet with a qualifier and checksum as it would be with RF, but that does require more complex code.

Edited by - hippy on 03/06/2007 14:49:45
 

beny1949

Senior Member
this looks great hippy, but would it allow me to transmit without changing the channel on the tv?

This does solve the other issue i was having that i would not be able to send enough data to really do anything i want to.



 
 

hippy

Technical Support
Staff member
<i>would it allow me to transmit without changing the channel on the tv </i>

You mean would everything sent from the bots cause the TV channel to change ? Probably.

The easiest solution would probably be to change the device code in INFRAOUT so it doesn't, then use bit-banged IR receive instead of INFRAIN ...

http://www.hippy.freeserve.co.uk/picaxeir.htm

It is a shame that there's no INFRAIN which can specify a device code, or return that received with the 'infra' data. It would make IR comms so much easier and useful - Especially if INFRAOUT/IN could mangle and unmangle device codes to allow 8-bit data to be sent; msb in data could set device code msb; that would retain existing INFRAOUT compatibility and give 8-bit IR data transfer capability.
 

beny1949

Senior Member
most certainly! thanks very much for all of this hippy! your website is fantastic as well, i reguarly use it for LCD stuff, but have not yet dicovered your IR bits as this is the first time i have started looking into ir.

ben

 
 
Top