PLC communication principle and program design[Copy link]
Communication programming is increasingly used in automation systems, such as data exchange between PLC and operating interface, control of frequency converter through communication, PLC networking, etc.
To realize PLC communication programming, the selected PLC must first have strong communication capabilities, that is, the PLC operating system can support multiple communication formats. Usually, if a brand of PLC can provide users with more programming freedom, then the technical development capabilities of this brand will be stronger. Most brands can only provide fixed communication formats or protocols, which greatly limits the data exchange between PLC and other intelligent devices.
Our PLC products have two free communication ports, RS232 and photoelectrically isolated RS485. The two communication ports can send and receive data at the same time, which can adapt to almost all communication formats and can provide multiple verification methods such as CRC and BCC.
Take a PLC controlling multiple frequency converters of a certain brand through 485 communication as an example: if the baud rate of the frequency converter is 9600b/s, 8 data bits, odd parity, and 1 stop bit. Then you must first program a communication port setting statement in the initialization code area of the embedded C window of the plc: Set485Port(9600,o,8,1); just one statement completes the programming of the 485 communication port.
Since the 485 communication must set the master-slave relationship, here the plc controls multiple inverters, so the plc must be set as the master, so you also need to add an address and master-slave setting statement in the initialization code area: SetAddress(1,MASTER); In fact, for the master controller, the address has lost its meaning.