Xi Menzi PLC and Ying Wei vacate CHV series transducer to correspond
- Time:
- Click:28
- source:MAJA CNC Machining
Address of communication of 0=1 // transducer is PC0 of 1 .
Baud of 1=3 // communication is led 9.
PC0 of 6K .
Data of 2=1 // communication occasionally P0 of desired result .
The moving instruction of 01=2 // transducer uses P0 of communication means .
The A frequency set of 03=7 // transducer uses communication means 2. Sure meeting uses the process designing of free communication port of PLC of series of S7-200 of Xi Menzi of PLC memory service instruction to two to dictate, namely XMT (send) instruction and RCV (receive) instruction. The need when writing a program appoints data buffer for these two instructions, regard data as the initiative address of buffer for the address of 0 with lowermost digit commonly. 1. Send instruction XMT buffer (write / read) the byte that instruction of VB100 //xmt wants to send address of communication of transducer of the VB101 // that count (01) function of VB102 //modbus is piled up (06/03) VB103 // transducer by address perch / transducer is read VB104 // transducer of of initiative address perch by. The byte that should receive instruction of VB200 //rcv of instruction RCV buffer address of transducer of the VB201 // that count (01) function of VB202 //modbus is piled up (06/03) VB203 // transducer by address perch / be occupied by reading byte several exalted VB204 // transducer by address low / . Subprogram of CRC desired result (SBR0) the MODBUS agreement that Ying Wei vacates the buy inside transducer of CHV series vector uses RTU to transmit a format, the data frame that means of use CRC desired result is opposite this format to be given out every time or receives has desired result. Accordingly, this subprogram used many local variable, call with convenient other subprogram. Fall in environment of process designing of Xi Menzi STEP 7-Micro/Win (if pursue one) , in needing to express in the local variable of this subprogram beforehand set is the following and local variable: (1) input local variable (VAR_INPUT) 1d_0:DWORD; // is waited for send Lw_4:W of of variable of data address fingerORD; // is waited for send data byte several variable (2) output local variable (VAR_OUTPUT) Lb_6:BDesired result of YTE; // CRC is worth Lb_7:B of exalted and variable Cost of desired result of YTE; // CRC is low a variable (3) face variable of ministry of the current political situation (VAR) Lw_8:WORD; // is waited for send data byte Lw_10:W of of several computation variableORD; // is waited for transmit data 8 binary systems count every byte LD SM0 of of of Network 1 of computation variable .
MOVW 16#FFFF of 0 , LW6 // is whole place of LW6 of register of 16 CRC desired result LD SM0 of of of Network 2 of 1 .
FOR LW8 of 0 , + 1, LW4 // is treated send data byte several (LW4) computation (LW8) LD SM0 of of of circular Network 3.
LD0 of * of XORB of 0 , LB7 // makes wait for the first byte that transmits data (* LD0) with / / register of CRC desired result is low a byte (LB7) undertake different or LD SM0 of of of operation Network 4.
INCD LD0 //ld_0 of 0 is pointed to wait for the of Network 5 of next address that transmits data LD SM0.
0 FOR LW10, + 1, + 8 // to every byte 8 binary systems count computation (LW10) LD SM0 of of of circular Network 6.
SRW LW6 of 0 , LW6 of register of 1 //CRC desired result is right move LD SM1 of of of Network 7 of a .
After 1 // is like shift spill over value SM1.
1 for XORW 16#A001 of 1 , LW6 // makes be worth 16#A001 and LW6 to undertake NEXT // of different or of of operation Network 8 ends every byte NEXT // of of of Network 9 of of loop of computation of 8 binary number ends byte of every data frame several computation circulate 3. Initialization subprogram (SBR1) this program moves in the cycle of the first scanning of PLC, the communication format that basically is port of setting CPU224 freedom, data receives format and restoration each check area (refer to manual of process designing of Xi Menzi S7-200) . Communication form content includes: Baud is led 9.
Digit of 6K, every byte 8, occasionally desired result (attention and transducer are consistent) . Data receives a format to consult completely set of MODBUS RTU format, with not less than 3.
The interval of communication mouth leisure of 5 byte transmission time serves as what data receives to begin to reach end signal. According to the agreement, PLC can monitor communication mouth first before preparation receives data disengaged, if successive and free time exceeded 3.
The transmission time of 5 byte, criterion PLC acquiescent data is received begin, the information that appears on mouth of after this communication is considered as the content of frame of a data namely. Manage together, transmit as the last byte of frame of a data finish, can appear again 3.
5 byte transmit the disengaged interval of time, will represent the end that frame of a data transmits. (refer to MODBUS agreement standard and communication of transducer of CHV series vector to block operation instruction handbook) Nextpage is right 9.
For the communication baud rate of 6K, 3.
5 byte transmit time to be 5ms left and right sides about. Because every instruction of this form prepares those who receive frame of a data to pass on information only, the leisure before receiving data so detects time can be set for 0, namely PLC begins to receive data instantly after issueing data, but the transmission end of frame of a data detects idly time still needs to set for 5ms above. LD SM0 of of Network 1 .
MOVB 16#49 of 0 , SMB30 // installs MOVW +0 of of format of free communication mouth, interval of SMW90 // vacant line detects MOVW +5 of of time 0ms , overtime of the timer between SMW92 // character detects MOVB 20 of of time 5ms , the biggest buffer that SMB94 // receives information 20 byte MOVB 148, SMB87 // installs the data of free communication mouth to receive format FILL +0, QW0, 1 // outputs FILL +0 of of restoration of impressional check area, MW0, FILL +0 of of restoration of area of check of 1 // mark, VW100, 5 // sends FILL +0 of buffer restoration , VW200, 5 // receives ATCH INT_0 of buffer restoration , 23 // is received finish interrupt ATCH INT_1, 9 // is sent finish interrupt ENI // to be enabled in overall situation interrupt CNC Milling CNC Machining