
Originally Posted by
jyi1
Is the code that I wrote below what you are trying to tell me?
I am only trying to send 4 bits (8 bits encoded). I looked at the digital data pin of the scope and my signal has an amplitude of about 3.72 v.
Code:
Transmit:
Pulsout PORTB.7, 500
Pause 20000
serout PORTB.7, n2400, [$aa,encoded2]
Pause 20000
Receive:
Wait55:
Pulsin PORTB.0,1,ct55
If ct55 = 500 Then
goto Waitaa
Else
goto Wait55
Endif
'goto Wait55
Yes, more or less. I would change it to...
Code:
Transmit:
Pulsout PORTB.7, 500
Pause 2500 'shorten space
serout PORTB.7, n2400, [$aa,encoded2]
Pause 20000
Receive:
Wait55:
Pulsin PORTB.0,1,ct55
If ct55 < 450 Then Wait55
goto Waitaa
The important thing with the signal is that it be clean with no noise pulses interspersed with the data.
With only 4 bits, I think I would use a variation of the NEC protocol, sending only 1 byte with each code. The NEC protocol has error detection built in so you can discard any corrupted codes. Read the NEC protocol documentation in the link I cited earlier and if you still have questions I'll try to answer them here.
Bookmarks