【正文】
g ,Jinan Traffic University, ShandongAbstract—Aiming at solving problems in current bustible gas alarm field. A CANbased system bining with RS485 bus is proposed and realized. The main features of MCP2515 are introduced. The hardware and software design of the main controller and CAN/485 converter is described in details. At last, several important points in design are stressed specially. KeywordsCAN。 CAN/485。 AVR。 power monitoring. Using pulse method to detect mercial power, backup power and charging status. The design of various I/O modules is another key point. The schematic diagram is showed as . ATmega128, a low power CMOS 8bit MCU is used as the microcontroller and it uses RISC architecture. It includes 128KB flash, TWI, SPI, JTAG interface (used as simulation debugging and program download). Features of ATmega128 satisfy the demand to design the main controller. Amount of real time data and historical data are very large, so FM24C256(32K E2PROM) and SD2200EPI(clock chip with 32KB SDRAM) are extended via TWI bus. FM24C256 made by Ramtron Company has the features such as: it can read and write 10 billion times, record data for long time, and its readwrite speed is very fast paring with mon E2PROM. SD2200EPI, an industrial grade realtime clock chip with 32KB SDRAM can guarantee accuracy of the clock error less than minutes per year. SD2200EPI offers SDRAM to record realtime data and offers real time clock. MCP2515 produced by Microchip Technology Inc is selected as CAN controller. MCP2515 is a full controller area network(CAN) protocol controller implementing CAN specification It includes three transmit buffers and two receive buffers which reduce the amount of microcontroller management required. The MCU munication is implemented via an industry standard serial peripheral interface with data rates up to 5 Mb/s. 82C250 is used as bus transceiver. In order to ensure the system stability, Squelch suppressor, magnetic beads and lightning protection devices are added to the circuit. Considering high requirement to the system stability, MAX705, a lowcost, up supervisory circuit is used for system reset. Intelligent color LCD terminal connects to MCU via USART1. It supplies Chinese word and touch screen function. Dot, line, circle, rectangle, lattice and other plex figures can easily be designed by simple instruction. The terminal also offers much figure memory to store fixed picture and BMP image to store boot screen. The touch screen39。s core, it has high performanceprice ratio and has 16KB FLASH, 256 BYTES E2PROM, 1KB RAM, so it39。s ID, and receiver39。s ID and TXBnEID0 stores address of gas alarm or linkage module. So a set of data of gas alarm or linkage module can transmit by one frame data.2. Software Design of CAN/485 Converter Converter receives mands from the main controller by interruption based on CAN bus. Then it analyzes mands and executes different subfunction. Converter polls child nodes of this RS485 bus when it does