以倉(cāng)庫(kù)智能改造為背景,主要介紹單片機(jī)和上位機(jī)之間通信網(wǎng)絡(luò)和通信協(xié)議的選擇,MODBUS協(xié)議通信指令和功能碼使用,重點(diǎn)闡述了基于RS-485總線(xiàn)的MODBUS通信協(xié)議在上位機(jī)和單片機(jī)之間的串行通信,實(shí)現(xiàn)上位機(jī)對(duì)單片機(jī)設(shè)備的遠(yuǎn)程控制和信息采集的功能。Based on the intelligent warehouse transformation as the background,mainly introduces between MCU and PC communication network and the choice of communication protocol,instruction and the function code using the MODBUS protocol communication,expounds the MODBUS communication protocol based on RS-485 bus serial communication between PC and single chip microcomputer,PC remote control of single chip computer equipment and the function of information collection.
1EC61131-3標(biāo)準(zhǔn)作為工業(yè)自動(dòng)化控制系統(tǒng)編程語(yǔ)言的國(guó)際標(biāo)準(zhǔn),其開(kāi)放性和先進(jìn)性得到了廣泛關(guān)注和充分肯定。開(kāi)發(fā)符合IEC61131-3標(biāo)準(zhǔn)的自動(dòng)化產(chǎn)品意義重大,也是必要的。本文根據(jù)IEC61131-3標(biāo)準(zhǔn)定義的編程模型,實(shí)現(xiàn)了下位機(jī)系統(tǒng)程序設(shè)計(jì)和與上位機(jī)的通信功能。下位機(jī)采用ATmega64微處理器,實(shí)現(xiàn)了對(duì)上位機(jī)用戶(hù)程序的裝載和執(zhí)行,包括串口通信、功能塊的執(zhí)行、用戶(hù)變量的地址分配等。上位機(jī)基于Visual C++ 6.0開(kāi)發(fā)了符合1EC61131-3編程標(biāo)準(zhǔn)的PLC用戶(hù)編程環(huán)境程序。本課題使用的處理器采用了ATMEL.公司的ATmega64單片機(jī),軟件開(kāi)發(fā)環(huán)境采用了ICCAVR編譯器和AVR Studio仿真器。在ICCAVR編寫(xiě)完成系統(tǒng)程序后,通過(guò)JTAG接口下載到PLC的FLASH存儲(chǔ)區(qū),并加密。