Embodiment
(embodiment 1, protocol conversion module)
Fig. 1 to Fig. 4 has shown a kind of embodiment of protocol conversion module in the utility model, wherein Fig. 1 is a kind of circuit structure block diagram of protocol conversion module in the utility model, Fig. 2 is a kind of circuit theory diagrams of protocol conversion module shown in Figure 1, Fig. 3 is the main program flow chart of protocol conversion module shown in Figure 1, and Fig. 4 is the fundamental diagram of protocol conversion module shown in Figure 1.
The present embodiment is the protocol conversion module of a kind of Can and Modbus, the MCU that comprises embedded CAN controller, the RS485 driver module be connected with MCU, the two isolation of DC/DC stabilized voltage supply, optocoupler, configuration button, communication pilot lamp, with the CAN driver module that optocoupler is connected with the two isolation of DC/DC stabilized voltage supply, the two isolation of described DC/DC stabilized voltage supply also is connected with the RS485 driver module.
Below the present embodiment is described in detail:
The power supply 24V of converter general employing fieldbus in applying at the scene powers, and this power supply is unstable power supply, and has many interference, thus can not directly access converter, must be through voltage stabilizing and isolation.
Product to many chip manufacturers on market contrasts and screens; the PIC18F that has chosen the Microchip company of cost and development difficulty less is the class chip; Microchip company has IDE development kit---the MPLAB of own chip special use; engage the dedicated emulated device ICD3 that they are released; can carry out on-line debugging emulation to the PIC single-chip microcomputer; saved development difficulty and cycle, and the confidentiality of PIC single-chip microcomputer is better, is conducive to protect the product rights and interests
[39-42].The PIC single-chip microcomputer of selecting is embedded with the CAN controller.
In order to realize the reliability and stability of adapter, need to, by CAN fieldbus and adapter electrical isolation, need to select suitable isolated component.
Modbus adopts the RS485 standard of differential transfer, need to select the chip with the transient current inhibit feature, saves cost and wiring space.
In adapter two-way communication process, need the two ends bus parameter that configuration is correct, could normally carry out the information conversion, these parameters arrange in the single-chip microcomputer initialization, but the data in single-chip microcomputer can't be revised by the user at any time, after program burn writing advances single-chip microcomputer, just can't revise, cause adapter there is no versatility.In order to address this problem, designed a kind of parameter configuration mode, by the activation of external key, single-chip microcomputer can enter the configuration mode of parameter acquisition, and under this pattern, the user used the PC couple in adapter, with the configuration software of designing, the adapter parameter was done to setting.These messaging parameters are stored in the embedded EEPROM of single-chip microcomputer, can not lose after power down.
Because the CAN bus packet contains good verification scheme, so adapter removes the CRC check field after initiatively the Modbus upstream data being done to the CRC verification, remaining data are changed to the CAN bus.In like manner, from the downlink data that the CAN bus receives, the CAN controller can be to removing check field after CAN data hardware check, for the descending Modbus data that make to change out can with the slave computer proper communication, we carry out adding check field after CRC check to data, to meet the requirement of Modbus consensus standard frame
[43].Certainly, in order to meet the user's request of different occasions, whether this CRC process can be selected to carry out in configuration mode.
In order to make the visual communication of seeing data of user, design two pilot lamp, the downlink data communication of indication from CAN to Modbus; The uplink communication of another indication from Modbus to CAN.
The build-out resistor of 120 idols of CAN bus requirements, adapter CAN end interface can select whether to access this resistance.
In this design, adopted the PIC18F458 chip with the CAN controller.This design is compared traditional MCU and is added the independently method for designing of CAN controller, makes greatly design simplification, has also increased the reliability of system simultaneously.
PIC18F458 is powerful, data RAM in the 1536k sheet, 3 16 bit timings/counters, 18 the interior ADC of sheet that defeated people are simulated on house dog WDT timer, 8 tunnels.House dog WDT timer is used for the running status of supervisory programme, in case CPU because accidental cause departs from outside normal procedure, WDT will be by force cpu reset, makes it return to normal procedure
[44].The PIC18F458CAN module, except the agreement of following the CAN bus, also has the characteristics of oneself simultaneously, mainly comprises: (1) supports CAN agreement CAN2.0A, CAN2.0B; (2) support standard frame, expansion frame, remote frame, overload frame, erroneous frame etc.; (3) 2 reception buffers, 3 transmission buffers; (4) 6 receiving filtration devices; (5) 2 shield filters.Select powerful PIC18F458 single-chip microcomputer, greatly simplified circuit design, provide cost savings.
That S485 bus driver chip is selected is 6LB184, and this chip is with the transient current inhibit feature.6LB184 is in semiduplex mode, inside comprises a transmitter and a receiver, need to be by enabling to bring in control " receipts " and " sending out " when work, its Enable Pin RE is connected together with DE, then receive the RD4 pin of PIC single-chip microcomputer, in software by the set to RD4 with reset to control 6LB184 and receive and send out.
CAN bus driver module adopts PCA82C251, and it has higher voltage breakdown, and draws electric current little under stealthy state, can improve the bus output characteristics under power-down conditions.After the pin TxD of PCA82C251 and RxD pass through the two optocoupler 1201AR of high-speed figure, receive respectively on the CANTX and CANRX pin of PIC single-chip microcomputer, use the two optocouplers of digital high-speed can improve message transmission rate, and eliminate interference and the deleterious effect of external circuit to converter; On the CAN joint at CAN bus two ends, can select whether to access 120 Europe build-out resistors, this build-out resistor effect be the reflex while removing impedance discontinuity
[45].Bus and ground is the little electric capacity of a 30pF in parallel separately, with anti-electromagnetic radiation and anti-high frequency interference.
In hardware design, also comprised DC the design of DC power unit, because comprised the two optocouplers of 1201AR numeral, the power supply of optocoupler both sides must be isolated, the power supply 24V of converter general employing fieldbus in applying at the scene powers, this power supply is unstable power supply, and have many interference, thus can not directly access converter, must be through voltage stabilizing and isolation.
In converter, need 2 tunnels isolation+direct supply of 5V, be respectively the VCC1 of the required first via+5V of MCU and RS485 transceiver module, the VCC2 of required the second tunnel of CAN bus transceiver module+5V.Thereby consider to select 1 24V to turn the power module of two-way isolation+5V.Therefore, this converter has been selected the power module of the WRD240505S-1W of Jin Shengyang company, in the access of VCC1 and VCC2 two ends, contains the filter regulator circuit of the tantalum electric capacity of representative value.
During converter work, be connected to the both sides bus, for proper communication, must the messaging parameter of communication module in MCU be arranged, just can make the converter normal operation, therefore for the user arranges these parameters more easily, configuration button of access on converter, button one terminates on the RB0 pin of MCU, and by pull-up resistor stretching+5V; Other end ground connection drags down
[41].At button, press and be, the current potential of RB0 pin can be dragged down, MCU enters configuration mode after the RB0 potential change being detected, by a USB, turns the module access converter of RS485, can relevant parameter and the communication mode of the two ends communication of converter be arranged.
This converter adopt PIC18F458 built-in the EEPROM of 128b, the parameter that signal post is used all is stored in here.Data power down in EEPROM is not lost, and can facilitate the user, need to not repeat converter parameters is configured in same occasion.
Software for Design is worked out with the C language by the developing instrument Mplab of microchip, mainly comprises initialize routine, CAN interrupt service routine, USART interrupt service routine, master routine, and protocol convertor.
In program, defined 4 data buffer areas, be respectively CAN and receive buffer area, CAN sends buffer area, and Modbus receives buffer area, and Modbus sends buffer area
[42].
The program principal function comprises two parts, and first is that the CAN bus data is converted to the modbus protocol data, and second portion is that the modbus protocol data is converted to the CAN bus data.Third part is configuration mode.
First is as figure, at first carry out the CAN module initialization, it is mainly the communication baud rate of configuration CAN module, working method, send identifier and send identifier, corresponding accepts filtrator and receives the shielding device, and the priority sent etc., after initialization, open the CAN receive interruption, wait for and receive the CAN bus data.
If, if the CAN module of single-chip microcomputer receives data, can carry out hardware check to these frame data, comprise whether identifier mates and the CRC check of CAN data.The data that verification is correct, can there be it in single-chip microcomputer in these 8 registers of RXB0D0~RXB0D7, judge subsequently whether this secondary data is single bag data, or wrap which bag of data more, when single-chip microcomputer confirms that this secondary data is single bag data or last bag data of wrapping data more, can subpackage restructuring agreement according to the rules carry out data recombination, whether the many bags of check data are complete simultaneously, if detect normal, data conversion storage after restructuring can be sent to buffer area to the Modbus data, now program can be carried out CRC check to the data that the Modbus data send in buffer area, and 16 CRC check fields that will produce are added in the data end
[42].This has just completed the conversion to the Modbus data of CAN protocol data.If the Modbus data length is greater than 8 bytes, fibrous root carries out subpackage according to subpackage restructuring agreement to it, and the subpackage rule is as follows:
Table 1 subpackage rule
DATA0.0: last position of first data of data fields, function is the subpackage mark, shows whether this frame message is the subpackage transmission, and 0 means single packet voice, and 1 means a minute packet voice;
DATA1.X: second data of data fields, when DATA0.0=0, this DATA1 byte is the data of message normal transmission; When DATA0.0=1, this DATA1 byte is the subpackage attribute byte, and wherein DATA1.7-1.6 is the subpackage attribute, and 00 means the first subpackage, and 01 means middle subpackage, and 10 mean last subpackage; DATA1.5-1.0 is the subpackage index, shows the sequence number of this frame message, if the N bag, this index sequence number is exactly N.Illustrate as follows:
Table 2 index sequence number
Subsequently, by the DE pin set of RS485 driver module, namely by the RD0 set of single-chip microcomputer, enable 485 driver module sending functions, then the USART asynchronous serial data that starts single-chip microcomputer sends, and the data that the Modbus be converted to sends in buffer area are sent.Finally return to the judgement of CAN data receiver.
Second portion as shown in Figure 4, at first carries out the USART initialization, is mainly the mode that serial transmission is set, verification mode, baud rate etc., and the DE pin of RS485 driver module is resetted, namely the RD0 of single-chip microcomputer is resetted, enable 485 driver module receiving functions.Then open the USART receive interruption.
In the USART interrupt service routine, adopt not limit for length Modbus data receiver, do not limit the length of Modbus data, also need not stipulate start byte or end byte
[46].The purpose of this program design is in order to make equipment have better versatility, to be applicable to the communication of various Modbus equipment.
After the USART initialization, program can inquire about whether receive the Modbus data, if now there is the Modbus communication data to import into, receive this Modbus data, deposit the Modbus data that receive in Modbus data receiver buffer area, then the data that deposit buffer area in are carried out to CRC check
Third part, be pressed when monitoring the configuration button, and microcontroller enters configuration mode.In configuration mode, the user can use configuration software to open PC end serial ports connection the utility model converter, messaging parameter and communication pattern to converter are selected, and the parameter after microprocessor is selected the user is stored in EEPROM, rear for powering on next time.
(embodiment 2, protocol conversion module)
The present embodiment is substantially the same manner as Example 1, and difference is: shown in indicating member also comprise LCDs and the debugging button.
(embodiment 3, intelligent breaker)
Fig. 5 to Fig. 7 has shown a kind of embodiment of intelligent breaker in the utility model, wherein Fig. 5 is a kind of perspective view of intelligent breaker the first structure in the utility model, and Fig. 6 is a kind of perspective view of protocol translation module in intelligent breaker shown in Figure 5; A kind of perspective view of Fig. 7 when to be protocol translation module shown in Figure 6 observe from another angle.
The present embodiment is a kind of intelligent moulded case circuit breaker that adopts above-described embodiment 2 to make, and sees Fig. 5 to Fig. 7, comprises breaker of plastic casing body 1, long-range action actuating mechanism (within being positioned at upper cover, not drawing on figure) and the described protocol conversion module 2 of embodiment 1; The breaker of plastic casing body comprises base 11 and upper cover 12.
Protocol conversion module 2 comprises LCDs 21, debugging button 22 and two pilot lamp 23 (the locations of structures design of power interface and toggle switch belongs to those skilled in the art's common practise, and Gu Tushang does not draw); The upper cover of described breaker of plastic casing body comprises panel 121 and sidewall 122, and this panel and sidewall are provided with a breach 123, and described protocol conversion module is arranged in this breach.Described sidewall is provided with two guide runners 13 in the breach both sides, the both sides of the housing of described protocol conversion module respectively are provided with a guide chute 24, described protocol conversion module inserts described breach from outside to inside from the outside of sidewall, and described guide runner 13 is arranged in guide chute 24.In concrete practice, the shape of described guide runner 13 and guide chute 24 and particular location can conversion, but within all belonging to protection domain of the present utility model.
LCDs in the present embodiment not only can also be carried out data to it by the debugging button and preset, adjust and check for display working condition, effectively widens its range of application.
The side that described protocol conversion module is positioned at the upper cover inboard is provided with Modbus communication interface 26, and another side of described protocol conversion module exposes the sidewall of upper cover, and equal with sidewall, and this side is provided with Can communication interface 27.
In the present embodiment, in described upper cover, be fixed with a Modbus communication inserting terminal, when under the position-limiting action of described protocol conversion module at guide runner, inserting breach, its inboard Modbus communication interface is inserted in this Modbus communication inserting terminal.On protocol conversion module in the present embodiment, also be provided with fastening screw 25, each fastening screw is telescopic to be arranged on the protocol conversion module housing, in described upper cover or sidewall be provided with the pilot hole matched with each fastening screw, when each fastening screw indentation, insert in corresponding pilot hole its bottom, thereby protocol conversion module is positioned in breach.Again by after each fastening screw once, fastening screw is from pilot hole, ejecting, thereby can dismantle this protocol conversion module.
(embodiment 4, intelligent breaker)
Fig. 8 to Figure 10 has shown the another kind of embodiment of intelligent breaker in the utility model, wherein Fig. 8 is a kind of perspective view of intelligent breaker the second structure in the utility model, and Fig. 9 is a kind of perspective view of protocol translation module in intelligent breaker shown in Figure 8; A kind of perspective view of Figure 10 when to be protocol translation module shown in Figure 9 observe from another angle.
The present embodiment is substantially the same manner as Example 3, difference is: see Fig. 8 to Figure 10, the outboard end that described agreement is changed the revolving die piece stretches out the upper cover sidewall, and each side that stretches out upper cover sidewall sections housing is equipped with Can communication interface 27, this be because, if as embodiment 3, external Can communication inserting terminal is inserted along the direction vertical with the upper cover sidewall, so adjacent electrical equipment must be abdicated space for this reason; This structure of the present embodiment can, so that external Can communication inserting terminal can insert Can communication interface 27 along the direction with the upper cover parallel sidewalls, take up room thereby reduce integral body.In addition, the fastening screw in the present embodiment 25 has also been adjusted position thereupon.
Obviously, above-described embodiment of the present utility model is only for the utility model example clearly is described, and is not the restriction to embodiment of the present utility model.For those of ordinary skill in the field, can also make other changes in different forms on the basis of the above description.Here exhaustive without also giving all embodiments.And these belong to apparent variation or the change that connotation of the present utility model extends out and still belong to protection domain of the present utility model.