Recently I got my hands on a couple of HSDL-1100 based IR transceivers and a KS070B LCD display module. This was a nice opportunity to experiment with three things: (1) controlling an LCD module, (2) serial communication between two PIC microcontrollers, and (3) making this work over an IR link.
Serial protocol supports addressing of up to 32 devices over shared media (IR or direct connection) and have basic error detection (2 inverse parity bits). Packets consist of 16 bits, as given below:
Serial protocol supports addressing of up to 32 devices over shared media (IR or direct connection) and have basic error detection (2 inverse parity bits). Packets consist of 16 bits, as given below:
Byte 0 | Byte 1 | ||||||||||||||
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
P0 | P1 | Device ID | C/D | Command/data bits |
- P0 - inverse parity of all even numbered bits [2-14]
- P1 - inverse parity of all odd numbered bits [3-15]
- Device ID - ID of the target device; LCD responds to ID 00001
- C/D - Code or Data; if "1", following byte contains command (for example, LCD "CLEAR SCREEN" command); if "0", following byte contains data (in case of the LCD this would be code of a character to be displayed).
Data is encoded as a sequence of short pulses. The beginning of a data packet is shown below:
The time between the first two pulses (T) is compared to the times between the following pulses. "0" is transmitted as time between pulses less than T; "1" - time between pulses greater than T.
The receiver code and the LCD constants include file can be used without any change. The transmitter generates a moving two line "Hello World!" message. Note that transmitter was written for use with IR modules that invert pulse polarity - for direct connection pulse polarity must be inverted in the transmitter code.
The receiver code and the LCD constants include file can be used without any change. The transmitter generates a moving two line "Hello World!" message. Note that transmitter was written for use with IR modules that invert pulse polarity - for direct connection pulse polarity must be inverted in the transmitter code.
No comments:
Post a Comment