plz any body out there help me to implement this protocol in c or VB 6.0 plzzzz,i need some code to implement this using com1 port of pc,for sending queries from computer and rechieving data from plc only.plz help me by providing some code for this.
the required data of protocol are as follows only i need is the code.
COMMUNICATION PARAMETERS:
1. Baud Rate = 9600.
2. Number of data bits= 8.
3. Parity= ODD.
4. Number of stop bits= 1.
FRAME FORMAT:
|10h 02h HEADER | length | comman byte | data field | cs check |
PARAMETERS USED:
LN : Number of commands from & including command bytes but excluding CS byte.
CS : Binary addition of the characters from header of data.
Data Field Includes :
TT - type of bit/word (register)
00 for O/P
01 for I/P
nn - hexadecimal num 'n' indicating num of bits/words.
AL AH - Offset address in Hex.
DL DH- Data in Hex returned by PLC.
LIST OF COMMANDS :
01 - Read 'n' consecutive words
15 - Force
11 - Write 'n' consecutive words
1A - CPU command
CC - =01 for put PLC in RUN mode
=02 for put PLC in STOP mode
=03 for INITIALIZE PLC.
COMMUNICATION PATTERN :
COMMAND DETAILS :
1. CPU commands:
10 02 02 1A CC CS
10 02 01 5A CS
2. Read commands
10 02 05 01 nn TT AL Ah CS
10 02 2n+1 41 DL1 DL2 DL3...DLn DHn CS
3.Write commands
10 02 15 TT AL AH CS
10 02 01 55 CS
the required data of protocol are as follows only i need is the code.
COMMUNICATION PARAMETERS:
1. Baud Rate = 9600.
2. Number of data bits= 8.
3. Parity= ODD.
4. Number of stop bits= 1.
FRAME FORMAT:
|10h 02h HEADER | length | comman byte | data field | cs check |
PARAMETERS USED:
LN : Number of commands from & including command bytes but excluding CS byte.
CS : Binary addition of the characters from header of data.
Data Field Includes :
TT - type of bit/word (register)
00 for O/P
01 for I/P
nn - hexadecimal num 'n' indicating num of bits/words.
AL AH - Offset address in Hex.
DL DH- Data in Hex returned by PLC.
LIST OF COMMANDS :
01 - Read 'n' consecutive words
15 - Force
11 - Write 'n' consecutive words
1A - CPU command
CC - =01 for put PLC in RUN mode
=02 for put PLC in STOP mode
=03 for INITIALIZE PLC.
COMMUNICATION PATTERN :
COMMAND DETAILS :
1. CPU commands:
10 02 02 1A CC CS
10 02 01 5A CS
2. Read commands
10 02 05 01 nn TT AL Ah CS
10 02 2n+1 41 DL1 DL2 DL3...DLn DHn CS
3.Write commands
10 02 15 TT AL AH CS
10 02 01 55 CS