Espanol
AddThis Social Bookmark Button

04 The protocol

PROTOCOL

The data always travel in consecutive packages from 12 byte. It isn't controlled the state of the bus but the correctness of the transmission which, in case of conflicts on the bus (transmission simultaneous of many nods) is detected.
Also the package integrity is made by the cheksum control. The cheksum is composed of 2 byte ( 11 byte lsb, 12 byte msb ) is made by the sum byte from 1 at 10.

The package bytes are made::

[ID destination]-[ID sending]-[D1]-[D2]-[D3]-[D4]-[D5]-[D6]-[D7]-[D8]-[cheksumLSB]-[cheksumMSB]

If I send ID = 50 all the nods of the net know the valid data. It serves ti give a valid command for all the net in particular cases, or with another byte you can activate deactivate for the groups X10.

The data send like MASTER:
The byte D1 (III° package's byte) function to carry out, is used from the PIC to understand what do you have to do, you must have value compress to 0 and 127.
The byte D2 (IV° package's byte) it is used to pass the address of the data.
Byte from D3 .... D6 data

Data answer send to you like SLAVE: (after a question of the master)
The byte D1 (III° package's byte) the same value or superior 128, indicate a response at one question
The byte D2 (IV° package's byte) function done and sent back.
Byte from D3 .... D6 data.

Here how the package's data is managed and interpreted:
REG = register or ram of the PIC in use, used for the modification of the doors of inp/out but can act of all the registers STATUS, INTCON, RAM, etc ( read the data sheet of PIC ). You can modify or read, knowing all you'll do because it isn't a control. You can send in crash everything if you change the registers or ram allow to the execution of the program.
It is used for the activation of the doors of INP/OUT, timer, read the values A/D, ram, etc.

FILE = si intende the writing or reading the data of the EEPROM of the PIC considerated like a memory. The quantity and the addresses vary naturally to second of the PIC used. ATTENTION: don't modify the first 8 byte because they are used from the system. For example the byte 0 continences the ID of the node.
So you can change the node's ID from remote.

I° BYTE = ID number 1 at 255 (except 50) identify the destination node
II° BYTE = ID " " " identify the node which send the data
III° BYTE = function change bit 7=1 (> 128 decimal identify an answer of the node)
0 = test verify functionament node. Turn back streak "Test"
1= read 6 byte consecutive REG. (address initial byte 4) return 6 byte (5..10)
2= write REG. just a byte (address byte4) (data byte5)
3= write REG. just a byte and return confirmation (address byte4) (data byte5)
4= read 6 byte consecutive FILE (address initial byte 4) return 6 byte (5..10)
5= write 6 byte consecutive FILE (address initial byte4) (data byte 5...10)
6= write 6 byte consecutive FILE and return confirmation ((address initial byte4) (data byte 5...10)
7= read bit REG. (address byte4) (n.bit 00000100 byte5) return byte5 = zero o uno
8= setta bit REG. (address byte4) (n.bit 00000100 byte5)
9= resetta bit REG. (address byte4) (n.bit 00000100 byte5)
10= inverti bit REG. (address byte4) (n.bit 00000100 byte5)

IV° BYTE = Address of the operation to carry out
V° BYTE = Value to memorize and or beginning data read.
....until ..........
X° BYTE = last data.
XI° BYTE = Checksum 16 bit. Data 1....10 ( byte low)
XII° BYTE = Checksum 16 bit. Data 1....10 ( byte high)

The data is always sent in 12 byte packages also when not all the byte have a significant utile.

Examples of the communication through nodes and or nodes and PC:

TRASMETTE BYTE: 1, 10, 0, 1, 2, 3, 4, 5, 6, 7, 39, 0
ID, id dest., operation (0=test), byte until 10 in this case not important, sum byte (low), sum byte (high)

RICEVE BYTE: 10, 1, 128, 5, 6, 7, sum 0, sum1
TRASMETTE BYTE: 1, 10, 1, 10, 2, 3, 4, 5, 6, 7, 49, 0
ID, id dest., operation (1=legge reg.), address initial, 6 byte without significant, sum0, sum1

RECEVE BYTE: 10, 1, 128, 10, 6 byte with the data require, csum0, csum1

For the first tests councils to construct a node and the serial interface RS232 to connect to the PC to make the tests to verify the operation. Also without no program of the PIC read and write the intern registers, the doors of I/O la EEPROM etc.