Wuxi-Gold-Serial-Communications-Protocol: Difference between revisions
Embeddedrf (talk | contribs) |
|||
| (36 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
AIBUS Communication Interface Protocol Instruction | [[Temperature-Controller-Software-Domination-Project]] | ||
Version 7.0 | |||
== AIBUS Communication Interface Protocol Instruction == | |||
[http://www.yudian.us/index.php?option=com_content&task=view&id=48&Itemid=59 Yudian Documents Page] | |||
[http://www.yudian.us/images/stories/documents/aibuscommprotocolv70eng.pdf Version 7.0 Yudian AIBUS]<br><br> | |||
Summary: | Summary: | ||
AIBUS is the communication protocol for Yudian AI series instruments. It features: | AIBUS is the communication protocol for Yudian AI series instruments. It features: | ||
| Line 245: | Line 251: | ||
For both READ and WRITE instruction, the instrument will automatically return to the follow | For both READ and WRITE instruction, the instrument will automatically return to the follow | ||
data: | data: <br><br> | ||
Process value (PV) + Set value (SV) + output value MV + alarm status + READ/WRITE | '''Process value (PV) + Set value (SV) + output value MV + alarm status + READ/WRITE parameter value + ECC''' | ||
parameter value + ECC | <br><br> | ||
2 + 2 + 1 + 1 +1 +2 = 10 bytes ( memory map shows only 1 byte address for PV made of 2 bytes ) | |||
MV | <br><br> | ||
bytes. The total number of bytes is 10. | *PV, SV = 2 byte integers with low byte before high byte. | ||
*MV = one byte with range -110~+110 | |||
*Alarm status = 1 byte | |||
*ECC = 2 bytes. | |||
The total number of bytes is 10. <br><br> | |||
The meaning of the returning data is as below: | The meaning of the returning data is as below: | ||
Model Controllers Multi-channel | Model Controllers Multi-channel | ||
| Line 343: | Line 355: | ||
*2. VB program instruction:<br><br> | *2. VB program instruction:<br><br> | ||
**Address -> 81H == 129 | **'''Address -> 81H == 129''' | ||
**Write function -> 43H == 67 | **'''Write function -> 43H == 67''' | ||
**Parameter Address -> 0 ( write set value ) | **'''Parameter Address -> 0 ( write set value )''' | ||
100 degrees ==> 1000 integer : Conversion to decimal | 100 degrees ==> 1000 integer : Conversion to decimal | ||
| Line 352: | Line 364: | ||
**LSB of value -> | **'''LSB of value -> 232''' | ||
**MSB of value -> | **'''MSB of value -> 3''' | ||
<br><br> | |||
**ECC_LSB -> | |||
**ECC_MSB -> | |||
Calculation of ECC ... should result in 44,4 | |||
| Line 362: | Line 380: | ||
'''COMM1.OUTPUT= 81H....+ CHR$(67)+ CHR$(0)...........+ CHR$(232)....+ CHR$(3)......+ CHR$(44)+ CHR$(4)''' | '''COMM1.OUTPUT= 81H....+ CHR$(67)+ CHR$(0)...........+ CHR$(232)....+ CHR$(3)......+ CHR$(44)+ CHR$(4)''' | ||
COMM1.OUTPUT= | COMM1.OUTPUT=CHR$(129)+CHR$(67)+CHR$(0)+CHR$(232)+CHR$(3)+CHR$(44)+CHR$(4) | ||
| Line 375: | Line 393: | ||
== ECC Code == | == ECC Code == | ||
'''READ ECC''' | '''READ ECC Formula''' | ||
ECC (error correction code): ECC applies 16 bit summation code. It is a two byte integer with the low byte before the high byte. | ECC (error correction code): ECC applies 16 bit summation code. It is a two byte integer with the low byte before the high byte. | ||
READ ECC = | READ ECC = (parameter code*100H + 52H + Addr) modulus 10000H | ||
'''WRITE ECC''' | '''WRITE ECC Formula''' | ||
WRITE instrument CRC check code: | WRITE instrument CRC check code: | ||
WRITE instrument ECC = module of (parameter code*100H + 43H + writing value + Addr) / 1000H The range of Addr is 0~80 ... appears to be version 7.0 of Yudian | WRITE instrument ECC = module of (parameter code*100H + 43H + writing value + Addr) / 1000H The range of Addr is 0~80 ... appears to be version 7.0 of Yudian | ||
Addr -> has the 80H backed out of it !!!! | |||
'''Write Example ECC #1''' | |||
*COMM1.OUTPUT= 129 129 67 0 232 3 44 4 | |||
ECC= modulus ( 0*100H + 43H + 3E8 + 1H ) / 1000H = 42C = 1068 Dec ............AGREES: should be 1068 Dec -OR- 42C Hex | |||
'''Write Example ECC #2''' | |||
*COMM1.OUTPUT= 129 129 67 0 200 0 12 1 | |||
ECC(from ecc bytes)= 1 * 256 + 12 = 268 ?=? 256 * ( 0 ) + 67 + 200 + 1=268 | |||
'''Write Example ECC #3''' - for the assumption the register address should be 80H | |||
*COMM1.OUTPUT= 129 129 67 128 200 0 () () | |||
ECC(from ecc bytes ) = 1 * 256 + 12 = 268 ?=? 256 * ( 0 ) + 67 + 200 + 1=268 | |||
== Response CheckSum Example == | |||
*byte stream:= (238 0) (232 3) (101) (96) (232 3) (36 105) | |||
*ECC of Returned data: = (PV + SV + (alarm status*256+MV) + parameter value + Addr)module 10000H <-- limit the ECC to 2 bytes!! | |||
*1000H == 4096 | |||
*PV = ( 238 0 ) = 238 | |||
*SV = ( 232 3 ) =1000 | |||
*MV = 101 | |||
*Alarm Status = 96 | |||
*Param Value = 1000 | |||
*( 238 + 1000 + 96*256 + 101 + 1000 + 1) mode 4096 = 2340 ==924H --- ECC_Hi=105 Ecc_Lo=36 | |||
== Communication Specification == | == Communication Specification == | ||
| Line 398: | Line 454: | ||
Note: For AI-5 series instruments, the writing interval is better longer than 2 minutes. Otherwise, the | Note: For AI-5 series instruments, the writing interval is better longer than 2 minutes. Otherwise, the | ||
longevity of storage unit may be shortened. | longevity of storage unit may be shortened. | ||
== Serial Port Setup Values == | |||
*baud rate equal to the instrument | |||
*Number of data bits = 8 | |||
*Number Stop Bits = 2 | |||
*parity = None | |||
Latest revision as of 14:03, 4 August 2008
Temperature-Controller-Software-Domination-Project
AIBUS Communication Interface Protocol Instruction[edit]
Version 7.0 Yudian AIBUS
Summary:
AIBUS is the communication protocol for Yudian AI series instruments. It features:
- Performs powerful functions by simple instructions.
- High speed. 3-10 times faster than other protocols (for example MODBUS), and suitable for
building large system.
- Applies 16 bit summation ECC (error correction code) and provides reliable communication.
- Supports baud rate of 1200, 2400, 4800, 9600 and 19200. With baud rate 19200, the average
communication time to access an AI-7 or AI-8 series instrument is 20ms, and that of an AI-5 series instrument is 50ms.
- An RS485 communication interface can connect to up to 80 instruments.
Interface Specifications:
AI series instrument apply asynchronous serial communication interface, and are RS232C and RS485 compatible. The data structure is 1 start bit + 8 data bit + 1 or 2 stop bit. The communication baud rate are selectable from 1200 to 19200 bit/second, generally 9600 bit/S. When a communication port connect to more than 40 instruments or quicker refresh speed is needed, 19200bit/S is recommended. When the communication is not stable, 4800bit/S is recommended. If RS232C communication interface is used, a computer communication port can connect to 1 instrument. If RS485 interface is used, a communication port can connect to up to 80 instruments.
RS485 communication interface is superior to RS232. The communication distance of RS485 can be longer than 1KM, and multiple instruments can communicate with computer through only two wires. A computer with RS232C communication port or USB port can realize RS485 communication by a RS232/RS485 or USB/RS485 communication interface converter. Yudian specially developed its own RS232/RS485 and USB/RS485 interface converter. Compared to competing products, it is smaller, can run without initialization or power supply, and provides protection from thunderbolt. According to RS485 standard, a communication line can only connect maximum 32 of instruments or computers unless a repeater is installed or communication interfaces with special chip such as 75LBC184 or MAX487 are used. Yudian communication interface adopts 75LBC184 chip, can connect up to 60 instruments without repeater, and provides protection from thunderbolt and static electricity. The RS232C and RS485 communication interfaces of AI instruments apply electric isolation technology to separate the communication interface and the other part of the instrument circuit. When an instrument can work, it won’t affect other instruments. If there is any problem with communication or with the computer, the instrument can still work well, and can be operated by its front panel. The 16 bit ECC can guarantee the reliability of the data. In case of communication malfunction, for example, when there are instruments with same address or there are products from other company, due to the 16 bit ECC, the instruments and computers can still independently work well without data confusion. Therefore, the distributed control system composed by AI instruments has high reliability. The control computer can be common PC which has rich software resource and is developing very fast. The AI application software for control computer can work in WINDOWS operating system. It is powerful and has friendly user interface. The Yudain AIDCS is cheaper than traditional DCS, but its performance and reliability are better.
Communication Instruction[edit]
Instructions and data of AI instruments are in hexadecimal structure. After optimization, the instructions are condensed to two: one is reading, another is writing. This is very simple but can full control the instrument.
The reading/writing instructions are as below:
- READ : address code + 52H (82) + code of the parameter to be read + 0 + 0 + ECC.
- WRITE : address code + 43H(67) + code of the parameter to be written + LSB of the value to be written + MSB of the value to be written + ECC.
1. Address code: Every instrument in the same communication line should have a unique address which is from 0 to 80. So one communication line can connect to up to 81 AI instruments. The instrument address is defined by parameter “Addr”. The instrument address code is a two byte integer with every byte from 128 to 208 (80H to D0H hexadecimal), and the two byte are all equal to instrument adress+80H. For example, if the instrument address is 10 (0AH, 0AH+80H=8AH), then the address code is 8A8AH. For multi-channel instruments, every active channel take one unique address. For example, an
AI-7048 has 4 channels of controls, and takes 4 addresses. If Addr=5, then 5,6,7,8 are the communication address for its 4 channels.
2. Parameter code: a parameter of AI instrument is represented by a parameter code which is one byte in hexadecimal format. The parameter code was summarized as below.
- Address
Controller AI-708/808/708P/808P Multi-channel Indictor Flow Totalizer AI-708H/Y Frequency controller /IO Controller V7.5 (AI-501/701/519/7048 (V7.0 V7.1) AI-702/704/706M (V7.6) module AI-301M )
00H
SV (setpoint) or SteP (program segment)
SV (batch control setpoint)
SV (Frequency control setpoint)
SP1 or SP2 or SteP (program type)
01H HIAL (High limit alarm) HIA(X) FHIA HIAL HIAL* (High limit alarm)
02H LoAL (Low limit alarm) LoA(X) FLoA LoAL LOAL*(Low limit alarm)
03H dHAL (Deviation High limit alarm) SPE dHAL HdAL (deviation high limit alarm)
04H dLAL (Deviation low limit alarm) Act dLAL LdAL (deviation low limit alarm)
05H dF (Dead band) dF(X) Esn dF AHYS* (hysteresis)
06H Ctrl(Control mode) FSc Ctrl At * (auto-tuning switch)
07H M5 (Hold parameter) PdIH M5 P (proportional band)
08H P (Rating parameter) CSc P I (integral time)
09H t (Lag parameter) CdIH t d (derivative time)
0AH CtI (Control period) Cut CtI CtI
0BH Sn (Input specification) Sn(X) FdIH Frd (Frequency range) InP (input specification)
0CH dIP (Decimal point position) dIP (X) FdIP dIP dPt (Decimal point position)
0DH dIL (Input low limit) Dil(X) PA dIL SCL (Input low Limt)
0EH dIH (Input high limit) dIH(X) Po dIH SCH (Input high limt)
0FH ALP (Alarm output allocation) ALP(X) Co ALP AOP (Alarm output allocation)
10H Sc (Input offset) Sc (X) Frd Switch status SCb (Input offset)
11H OP1 (Output mode) oPn (retransmission output channel) CF oP1 OPt (output mode)
12H OPL (mV output low limit) IoL (retransmission Low limit) Bc OPL OPL
13H OPH (mV output high limit)IoH (retransmission high limt) IoL OPH OPH
14H CF (function selection) AF (function selection) FoH CF AF (Advanced function selection)
15H Instrument model identifier or program status code (program type) Model identifier Model identifier Model identifier Model identifier
16H addr (communication address) addr addr addr Addr
17H dL (input filter) dL Ioh dL FILt (input filter)
18H run (Run paramenter) no/nc (NO/NC selection) Dl Run A-M (auto/manual selection)
19H Loc (Parameter Lock) Loc Loc Loc Loc 1AH MV (manual output value) Or C01 (for program type) Spare Spare MV MV 1BH t01 spare FDF nonc (NO/NC selection) 1CH C02 CHIA unit (measurement unit) 1DH t02 CLOA CtrL (control mode) 1EH C03 PHIA Act (direct/reverse action) 1FH t03 PLOA CHYS (control hysteresis)
20H C04 ALP Fru (unit and power frequency selection)
21H t04 FSB Aut (auxiliary output type)
22H C05 CDIP OPrt (soft-start)
23H t05 PDIP OHEF (work range of OPH)
24H C06 PSc SPr (start slope control)
25H t06 CLN SPL (low limit of setpoint)
26H C07 FLJH SPH (upper limit of setpoint)
27H t07 FLJL SP1 (setpoint 1)
28H C08 EJH SP2 (setpoint 2)
29H t08 EJL
2AH C09 Batch accumulation clear
2BH – 55H T09 – C31 (program data)
56H Running time (read only)
57H MV (manual output value, for program type only)
Remarks:
- 1) No return for reading any parameter code not included in the above table. AI-501 and 701 have only part of the above parameters, the operation on a parameter code that AI-501/701 doesn’t possess is actually operated on parameter “SP1”.
- 2) The 1AH is the manual output value in the instruments with manual control function.
- 3) 15H is the instrument model specification:
Model Model Identifier
AI-518/708/808(V7.1) =Baud rate (4800/9600/19200) AI-518P/708P/808P(V7.1) = program control byte (<256) AI-501 = baud rate (compatible mode) or 1501 (made to order) AI-701 = baud rate (compatible mode) or 1701 (made to order) AI-519(V7.5) = baud rate (compatible mode) or 1519 (made to order), selectable by parameter AF
AI-702M/704M/706M 768 AI-708H/808H (flow channel) 256 (common accumulation mode); 258 (batch control mode) AI-808H (temperature/pressure channel) 257 AI-301M 512 AI-7048 7048 For AI-708P/808P series instruments, 15H is the program control digit. The MSB (Most Significant Byte) is 0, the LSB (Least Significant Byte) is as below: (X) (X) (X) (X) (EV2) (EV1) (HOLD) (STOP) The first four bits are not applicable. HOLD and STOP = 0, program run STOP = 0, HOLD = 1, program pause STOP = 1, HOLD = 1, program stop EV1 or EV2 indicates event output status. 1 means event output is working. 0 means event output is not working
4) Flow accumulation clear: The flow accumulation parameter FLJH and FLJL of AI-708H/808H can be reset to 0, but can’t be modified. The method is to write 30808 to FLJH, then the FLJH, FLJL (flow accumulation) and FJH, EJL (flow accumulation before compensation) will be reset to 0, and parameter CLn will increase 1. CLn is read-only. Writing 31808 to parameter code 2AH can clear batch accumulation value, and also reset batch control output relay.
3. ECC (error correction code): ECC applies 16 bit summation code. It is a two byte integer with the low byte before the high byte. READ instruction ECC = module of (parameter code*100H + 52H + Addr)/10000H WRITE instrument ECC = module of (parameter code*100H + 43H + writing value + Addr) / 1000H The range of Addr is 0~80.
4. Returned data[edit]
For both READ and WRITE instruction, the instrument will automatically return to the follow
data:
Process value (PV) + Set value (SV) + output value MV + alarm status + READ/WRITE parameter value + ECC
2 + 2 + 1 + 1 +1 +2 = 10 bytes ( memory map shows only 1 byte address for PV made of 2 bytes )
- PV, SV = 2 byte integers with low byte before high byte.
- MV = one byte with range -110~+110
- Alarm status = 1 byte
- ECC = 2 bytes.
The total number of bytes is 10.
The meaning of the returning data is as below: Model Controllers Multi-channel Indicators AI-708H/ 808H flow channel AI-808H temperature/pressure channel AI-301M frequency module PV Measurement value PV PV PV of Instant flow PV of temperature with unit 0.1℃ PV SV Setpoint SV Channel number Low byte of Accumulation flow or PV of batch control PV of pressure with unit 0.001MPa SV MV Output value MV or status byte B Status byte A Output value MV Status byte Status byte A Status byte A High byte of accumulation flow or SV of batch control Flow before compesation or frequency with unit 0.1Hz Status byte A Parameter Value The parameter value to be read or written. ECC of Returned data: = (PV + SV + (alarm status*256+MV) + parameter value + Addr) module 1000H The status byte A indicates some status of the instrument. The details are as follow: Controllers/Single-channel Multi-channel Controllers/Single-channel indicators (V7.0) indicators Indicators (V7.5) Bit 0 HIAL (high limit alarm) HIAL HIAL Bit 1 LoAL (Low limit alarm) LoAL LoAL Bit 2 dHAL (Deviation high limit alarm) 0 HdAL (Deviation high limit alarm) Bit 3 dLAL (Deviation low limit alarm) 0 LdAL (Deviation low limit alarm) Bit 4 orAL (input over range alarm) orAL orAL Bit 5 AL1 status, 0 means activate 0 Spare (0) Bit 6 AL2 status, 0 means action 0 0: MV output value 1: status byte B Bit 7 Always set to 0 The multiple-channel indicators have status byte B. For controllers and single-channel indicators with version 7.5 or above, if Bit 6 of status byte A is 0, MV byte means MV; if it is 1, MV byte means status byte B. The 0 to 6 bits of status byte B indicate the status of port OP1, OP2, AL1, AL2, AU1, AU2 and MIO. 0 means switch off or no output, and 1 means switch on or output. When OUTP or AUX works as control output, the corresponding bits is 0. By communication function, the host computer can input or output on-off signals via the above ports. The idle output port which is not set as alarm output port by parameter ALP, can be set as on-off signal input/output port. By parameter nonc (normal open/normal close) can output on-off signal. To input an on-off signal, nonc should be set to “no”. That 1 is read means that external switch is open or signal is input.
Programming[edit]
- READ : address code + 52H (82) + code of the parameter to be read + 0 + 0 + ECC.
Every time the control computer sends an instruction to the instrument, the instrument will return one data. The instrument should reply the data within 0-150ms. Computer cannot send a new instruction before receiving the reply; otherwise, it will cause some error. If the instrument does not reply after the maximum response time, there is some problem, for example, invalid instruction, communication line malfunction, error communication address or the instrument is power off. Then the control computer should send the instruction again.
For example, in order to set setpoint (the according parameter code is 0) of the instrument with ADDR=1 to 100.0℃ (the integer value is 1000), the program designed by VB is as below:
- 1. Initialize the communication port, includes set the baud rate equal to the instrument and set 8 data bit, 2stop bit, no parity bit. Note that some model of RS485 communication port or RS-232/RS-485 communication converter have some request for RTS or DTR control wire. The computer should program for those control wire.
- 2. VB program instruction:
- Address -> 81H == 129
- Write function -> 43H == 67
- Parameter Address -> 0 ( write set value )
100 degrees ==> 1000 integer : Conversion to decimal
1000 = 232 + 3 * 256
- LSB of value -> 232
- MSB of value -> 3
- ECC_LSB ->
- ECC_MSB ->
Calculation of ECC ... should result in 44,4
WRITE : address code + 43H(67) + parameter address + LSB of value + MSB of value + ECC_LSB + ECC_MSB
COMM1.OUTPUT= 81H....+ CHR$(67)+ CHR$(0)...........+ CHR$(232)....+ CHR$(3)......+ CHR$(44)+ CHR$(4)
COMM1.OUTPUT=CHR$(129)+CHR$(67)+CHR$(0)+CHR$(232)+CHR$(3)+CHR$(44)+CHR$(4)
- 3. Decimal point: the parameter value is an integer. The decimal digits can be read from parameter
code 0CH.
- 4. Engineering unit (for version 7.5 or above only): the engineering unit can get from parameter code
1CH.
ECC Code[edit]
READ ECC Formula
ECC (error correction code): ECC applies 16 bit summation code. It is a two byte integer with the low byte before the high byte.
READ ECC = (parameter code*100H + 52H + Addr) modulus 10000H
WRITE ECC Formula
WRITE instrument CRC check code:
WRITE instrument ECC = module of (parameter code*100H + 43H + writing value + Addr) / 1000H The range of Addr is 0~80 ... appears to be version 7.0 of Yudian
Addr -> has the 80H backed out of it !!!!
Write Example ECC #1
- COMM1.OUTPUT= 129 129 67 0 232 3 44 4
ECC= modulus ( 0*100H + 43H + 3E8 + 1H ) / 1000H = 42C = 1068 Dec ............AGREES: should be 1068 Dec -OR- 42C Hex
Write Example ECC #2
- COMM1.OUTPUT= 129 129 67 0 200 0 12 1
ECC(from ecc bytes)= 1 * 256 + 12 = 268 ?=? 256 * ( 0 ) + 67 + 200 + 1=268
Write Example ECC #3 - for the assumption the register address should be 80H
- COMM1.OUTPUT= 129 129 67 128 200 0 () ()
ECC(from ecc bytes ) = 1 * 256 + 12 = 268 ?=? 256 * ( 0 ) + 67 + 200 + 1=268
Response CheckSum Example[edit]
- byte stream:= (238 0) (232 3) (101) (96) (232 3) (36 105)
- ECC of Returned data: = (PV + SV + (alarm status*256+MV) + parameter value + Addr)module 10000H <-- limit the ECC to 2 bytes!!
- 1000H == 4096
- PV = ( 238 0 ) = 238
- SV = ( 232 3 ) =1000
- MV = 101
- Alarm Status = 96
- Param Value = 1000
- ( 238 + 1000 + 96*256 + 101 + 1000 + 1) mode 4096 = 2340 ==924H --- ECC_Hi=105 Ecc_Lo=36
Communication Specification[edit]
Model AI-301, AI-7/8 series instruments AI-5 series instruments Maximum return time (4800bit/S) 100mS 150mS Minimum return time (19200 bit/S) 5mS 5mS Average access period (19200bit/S) 20mS 50mS Available writing times 1 billion 10 million Note: For AI-5 series instruments, the writing interval is better longer than 2 minutes. Otherwise, the longevity of storage unit may be shortened.
Serial Port Setup Values[edit]
- baud rate equal to the instrument
- Number of data bits = 8
- Number Stop Bits = 2
- parity = None