DS80C410-based embedded CAN bus Dining Hall System

CAN bus (Controller Area Network Bus) is an effective support for distributed control of the serial communication network. Communication bus than the general more reliable, real-time and flexibility. CAN multi-master approach to work, the network took a node can be its own initiative at any time other nodes on the network to send information, but regardless of master and slave, and flexible communication without station node address information. CAN bus has been widely used in industrial control, residential security, environmental monitoring and many other areas.

2. System Structure

Real-time communication Dining Hall characteristics of the communication system is suitable for use CAN bus. Its short frame structure is very suitable system for anti-jamming capability and the ability to demand higher real-time communication, communication is very small single occasion; flexible networking features to fully address the large Dining Hall system, multiple dining outlets and more dispersed problems.

CAN bus Dining Hall on the system network structure shown in Figure 1. Use bus-type access method, consists mainly of three layers: server, repeaters and terminals. Which include the work server and backup server, the server, both servers work in the business at the same time, mutual backup, to ensure system reliability. Repeaters can extend the communication distance, increasing the number of terminals, transform communication rate, and can play the role of filtering and isolation. Terminal window is mainly used machine sales, but also report the loss machine, solution hang card / recharge machine.

DS80C410 embedded CAN bus based system design Dining Hall

Figure 1 Network structure diagram Dining Hall

DS80C410-based embedded CAN bus Dining Hall System

Figure 2 windows machine hardware block diagram

3. Window machine hardware design

Windows machine is directly dealing with the Canteen and the main reception equipment users. Figure 2 shows the hardware block diagram of the window plane. Dallas CAN controller with embedded microcontroller DS80C410 high-speed network as a Windows machine's microprocessor, the windows machine and the keyboard is responsible for monitoring. MMM non-contact IC (Mifare) Card read / write module. The module is under the control of the microprocessor, to complete a non-contact on the card read / write and other operations. Window machine communication tasks DS80C410 CAN controller embedded under the control of the CPU's, CAN controller via CAN bus transceiver PCA82C250 to receive the data on the bus for the CPU to read, also can be sent to the CPU data sent CAN bus. Embedded CAN controller through the DS80C410 chip P5.1 (C0RX-CAN receiver) and P5.0 (C0TX-CAN send) pin respectively transceiver RXD (receive data output) and TXD (transmit data input) pin is connected . Window machine hardware also includes a 4 × 4 keyboard (10 number keys, 6 function keys), before and after the 10-bit digital display (display exactly the same), 32KB of EEPROM (for storing consumer records), Watchdog, etc. part of the circuit.


4. Windows Software Design

4.1 Main program design

Windows machine with the Internet and offline operation types. Windows machine running the default work is divided into networking, and only in the event of network failure or other reason can not be networked to run only when the network through the switch is set to run off. Figure 3 for Windows machines running the main program flow chart. Window machine is initialized, the first treatment for the keyboard, LED display processing, and to determine whether the recovery of consumer records. Then check whether the read card, read the card, call the appropriate subroutine networked or offline, for business operations.

DS80C410-based embedded CAN bus Dining Hall System

Figure 3, the main program flow chart window machine

4.1.1 CAN Initialization

Window machine initialization, including initialization of the CAN module. When the system hardware reset, the first shield CAN interrupt, and then in the DS80C410's SFR (Special Function Register) in the C0C (CAN Control Register) of the CRST (reset) bit to 0, the CAN controller cleared the reset state, Meanwhile SWINT (software initialization) bits to be set to 1, which prohibits the CAN bus, so that it allows the program to the CAN module control registers and extended frame mask register (C0EGM0 ~ C0EGM3) to write, and set the communication wave special rate, window machine ID, window machine number, CAN state, CAN port enabled, CAN time and other parameters, initialize the CAN module. CAN interrupt the final restoration. After initialization, to clear SWINT bit, to restore the activities of CAN bus.

4.2 subroutine Design

4.2.1 Workflow

In the networking case, when the windows machine by MMM access card number, the card number will be sent to the server, the server upon receipt of card number, card number in the database to find the corresponding user and return the balance to the windows machine. Windows machine shows the user receives the balance of business operation is completed once and the window unit will users always spending sent to the server Fu Wuqi spending Hou received the corresponding database record of Geng Xin Jin Xing, Bing Jiang Yi received spending the Queren frame ( ACK) back to the windows machine. If the windows machine to read the card number (SNR) sent to the server during the frame loss, that is, the window server machine does not receive the balance of the frame, then the window machine waiting for a retransmission time frame not received the balance of the server , it will resend the previous card number. Most re-issued three times, when the re-issued three times still could not receive server response frame, the display the appropriate message. If the checkout after the windows machine to the server's user spending frame loss, that is, spending the server does not receive frames, the corresponding records can not be updated, re-issued the same way to the user spending. Figure 4 for the networked subroutine flow chart.

Figure 4 networked subroutine flowchart

Offline case, the window machine is used in accounting methods, will be off net state spending under the user's card number and all records stored in the window

I machine EEPROM, networking and other systems resume operation after the server to recover from the windows machine stored data, updates the server database. As the offline case windows machine and the server can not communicate in real time, so the program is relatively simple, no longer gives a flow chart.

DS80C410-based embedded CAN bus Dining Hall System

Figure 5 send subroutine

DS80C410-based embedded CAN bus Dining Hall System

Figure 6 Receiver subroutine

4.2.2 to send and receive frames

DS80C410 CAN module provides the message center 15, as a send or receive data memory. Frame to send and receive messages through the center 15 to achieve, you can select one or more message center to send or receive frames. This 15 message center to send or receive data packets in order of priority are arranged in the center reverse. Message Center 1-14 can be set to receive or send data, message center 15 can receive data. Message center control register (C0M1C ~ C0M15C) SFR is located in the. Center of each packet has a format register (C0MyF), 4 个 arbitration registers and 8 bytes (C0MyD0 ~ C0MyD7) data area. Arbitration register value can be set in the initialization can also be set in the sending process, and its value can be received automatically as the data changes. In addition, the message center 15 C015M0 ~ C015M3 register, you can also perform additional filtering.
When the network is to send a window state machine, the first center on the use of the initialization packet, the packet to be sent into message center, message center arbitration register value as the identifier of the frame sent. Figure 5 to use the message center to send data through a flowchart, which MSRDY (message center ready), DTUP (data update), MTRQ (CPU sends a request) and so is the message center of a bit of control register C0M1C bit.

When the window unit is receiving state, CAN controller Genju mask register and receive reports for the Center of the value of arbitration registers the ID of the received frame identifier to judge, to determine whether the received message center, and only when the received frame identifier arbitration register value equal to the time frame Caibei receiver; In addition, CAN module mask register and the media are the media arbitration register can receive data frames 0 and 1 additional two-byte checksum. Figure 6 is to use the message center 2, the procedure to receive data flow diagram. One MSRDY, DTUP, MTRQ other bits are message center 2 control register C0M2C bit.

5. Conclusion

DS80C410 is a network with Ethernet and CAN microcontrollers. Include a 10/100 Ethernet MAC, three full-duplex hardware serial port, 8-way 8-bit ports, an optional CAN2.0B ,1-Wire ® master controller and 64 I / O pins and used to store user applications and the network stack of 64K bytes of internal SRAM. Embedded CAN module supports standard (11 bit) and extended (29 bit) identifier and the common mask, the media byte filtering, DeviceNet ™, SDS and high-level CAN protocols, automatic baud rate mode and SIESTA low-power mode. DS80C410-based embedded system CAN bus Dining Hall, not only have good stability, security and reliability, and real-time response capability, network maintenance easy, user friendly interface, software, upgrades and migration are easily and cheaply.

This innovation: DS80C410 integration higher, 16MB continuous storage space, can simultaneously monitor and keyboard on the windows. Up to 75MHz system clock frequency, so that only a single cycle instruction 54ns. Embedded CAN module, so that the window machine hardware configuration is simpler to save hardware resources. CAN module message center 15 to increase communication efficiency. CAN module on the operation and expansion of the MCU external program / data memory operation is the same, software is not complicated.

Declined comment