A kind of non-standard Canopen is from the Frame sending method of node and deviceTechnical field
The present invention relates to Canopen network communication field, in particular to a kind of non-standard CanopenFrom Frame sending method and the device of node.
Background technology
The most integrated and intelligent along with blower fan system, fan master control system needs to issue relevant controlInformation processed is to subsystems core component, and subsystems core component is also required to relevant shape simultaneouslyState information is sent to fan master control system.Can(Control Area Network, control area network)Network is owing to the features such as point spread is flexible, communication delay is less and error detection mechanism is perfect are existingField bus is widely used.
Canopen agreement is in CAL(CAN Application Layer, CAN application layer) on the basis ofExploitation, employ CAL communication and service protocol subset, it is provided that the one of dcsImplementation.CANopen allows the function of node arbitrarily to expand while ensureing network node interoperabilityExhibition, simple or complicated.In blower fan, the core component of a lot of subsystems is all supported and uses Canopen at presentAgreement.Leading between the systems such as the most existing master control system and change oar, driftage, gearbox fault diagnosis in advanceLetter uses Can network based on Canopen agreement.Master control system PLC(ProgrammableLogic Controller, PLD) as host node, remaining each subsystem core controllerAs from node, this network structure well ensure that between subsystems, the independence of communication is with reliableProperty.In addition, along with the function of unit is the most perfect, system needs add corresponding module, asFor the root of blade load measuring cell of independent pitch and the digital input and output modules of extension or mouldIntend input/output module etc., and they are required for completing to communicate with master control system PLC.Accordingly, it would be desirable toBased on Canopen protocol development from node.Traditional is based on Canopen protocol development from node, needsObject dictionary to be completed is write, to NMT(network management, Network management), SDO(clothesBusiness data object, Service Data Objects), PDO(Process Data Object, process data pairAs) and predefined message etc. be achieved.The Canopen being achieved in that is longer from the Node Development cycle,Canopen realizes extremely complex from the exploitation of node protocol, and development process needs consider a lot of withThe problem that chip performance is relevant, such as OD(object dictionary, object dictionary) realize during itsThe distribution of different read-write properties correspondence deposit positions, the requirement to chip performance of the method for four kinds of message realizationsDeng.Additionally, for application-specific, some message it is not necessary that.Such as certain from node onlyBeing for use as the module of I O function, under this situation, NMT, SDO and predefined message etc. are not haveNecessary.Visible, traditional is longer from the cycle of node based on Canopen protocol development, and realizesMore complicated.
Summary of the invention
The present invention provides a kind of non-standard Canopen Frame sending method from node and device, is used forSolve in prior art based on Canopen protocol development longer from the node cycle, and realize more multipleMiscellaneous problem.
The invention provides a kind of non-standard Canopen Frame sending method from node, including:
Process data object PDO in Canopen network is filled in the identifier position that Frame is arbitrated fieldFunction code and communication object identifier, and in data fields, fill data to be sent, obtain the first dataFrame;Carry out verifying and generating check results to sent data;Check results is added to the first dataIn frame, obtain the second Frame, the second Frame is sent the host node device to Canopen network.
Further, said method also includes: the second Frame is being sent the master to Canopen networkAfter node device, send heartbeat message to host node device.
Further, said method also includes: after obtaining the first Frame, enters the first FrameLine flag, obtains the labelling of the first Frame;The labelling of the first Frame is added together with check resultsIn the first Frame.
Wherein, the first Frame is marked includes: to the first data before sending the first FrameFrame counts, and obtains the count value that current data frame is corresponding, using count value as the first FrameLabelling.
Wherein, carry out verification to sent data to include: data to be sent entered in units of byteRow XOR, obtains the result after XOR;Result after XOR and count value are carried out XOR, obtains schoolTest result.
According to another aspect of the present invention, it is provided that a kind of non-standard Canopen is from the Frame of nodeDispensing device, including: processing module, fill Canopen for Frame being arbitrated the identifier position of fieldThe function code of process data object PDO and communication object identifier in network, and fill in data fields and treatThe data sent, obtain the first Frame;Correction verification module, for carrying out verifying also to sent dataGenerate check results;First sending module, for check results being added in the first Frame, obtainsSecond Frame, sends the host node device to Canopen network by the second Frame.
Further, said apparatus also includes: the second sending module, for being sent by the second FrameAfter the host node device of Canopen network, send heartbeat message to host node device.
Further, said apparatus also includes: mark module, is used for after obtaining the first Frame,First Frame is marked, obtains the labelling of the first Frame;First sending module includes: addUnit, adds to the labelling of the first Frame in the first Frame together with check results.
Wherein, above-mentioned mark module includes: counting unit, for sending before the first Frame theOne Frame counts, and obtains the count value that current data frame is corresponding, using count value as firstThe labelling of Frame.
Wherein, above-mentioned correction verification module includes: the first XOR unit, is used for data to be sent with byteCarry out XOR for unit, obtain the result after XOR;Second XOR unit, for by the result after XORCarry out XOR with count value, obtain check results.
Technical scheme, by by Frame to be sent in Can2.0 equipment according to CanopenThe communication pattern of network host node is packaged, thus by the data frame format of Can2.0A and CanopenPDO content in traffic model is mapped, it is achieved that off-gauge from node and Canopen networkThe communication function of host node.Such that it is able to shorten based on Canopen protocol development from the cycle of node, andAnd reduce the complexity of operation.
Accompanying drawing explanation
Fig. 1 is the potential field composition schematic diagram of Frame;
Fig. 2 is arbitration field composition schematic diagram;
Fig. 3 is that the non-standard Canopen of according to embodiments of the present invention 1 is from the Frame sending method of nodeFlow chart;
Fig. 4 is that the non-standard Canopen of according to embodiments of the present invention 2 is from the Frame sending method of nodeFlow chart;
Fig. 5 be according to embodiments of the present invention 3 realization be similar to the stream of message method of HeartbeatingCheng Tu;
Fig. 6 is that the non-standard Canopen of according to embodiments of the present invention 4 is from the Frame dispensing device of nodeStructured flowchart;And
Fig. 7 be according to embodiments of the present invention 4 the non-standard Canopen of another kind send out from the Frame of nodeSend apparatus structure block diagram.
Detailed description of the invention
Understandable, below in conjunction with the accompanying drawings for enabling the above-mentioned purpose of the present invention, feature and advantage to become apparent fromWith detailed description of the invention, the embodiment of the present invention is described in further detail.
Embodiment 1
The present embodiment is to use only to support Can2.0A equipment as Canopen network from node, it is achieved itsThe method communicated with Canopen network host node.Wherein, Can2.0A is by 4 different frame classesType represents and controls, i.e. Frame, remote frame, erroneous frame, overload frame, the present embodiment is concerned only with andRealize being similar to the Frame that PDO communication function is relevant.The potential field of Frame forms as shown in Figure 1,, arbitration field initial by frame, controlling filed, data fields, CRC check field, response field, End of Frame form.The present embodiment is paid close attention to emphatically arbitration field, data fields.Wherein arbitrate the composition of field as shown in Figure 2, secondaryCutting out in field and be made up of identifier and the long-range request position that sends, data fields is made up of 8 byte.
Fig. 3 is that the non-standard Canopen of according to embodiments of the present invention 1 is from the Frame sending method stream of nodeCheng Tu, as it is shown in figure 1, this method comprises the following steps:
Step 301: Canopen network is filled in the identifier position of the arbitration of Frame from node device fieldThe function code of middle process data object PDO and communication object identifier, and fill to be sent in data fieldsData, obtain the first Frame;
Step 302: carry out verifying and generating check results to sent data;
Step 303: check results added in the first Frame, obtains the second Frame, by secondFrame sends the host node device to Canopen network.
In above-mentioned steps 301, due to communication object identifier in distinct device, may be because of equipmentConfiguration changes and changes, and therefore, in the present embodiment, predefines with conventional CanopenPrincipal and subordinate's peer objects illustrates, and can determine that according to give the NodeID from node distribution in host nodeCorresponding predefined communication object identifier, i.e. may determine that required arbitration in conjunction with corresponding function codeIdentifier position in Chang.Simultaneously for the request that remotely the sends position of arbitration field, due in the present embodiment fromNode sends Frame to host node, and therefore, this remotely sends request position RTR, is set to dominant.It addition, fill data the most to be sent in eight positions of the data fields of Frame, in these eight positionsData to be sent are then equivalent to four words transmitted in PDO.
The Frame verification to sending of the equipment of the Can2.0A in this step is specifically, in units of byteCarry out XOR to sent Frame, the result obtained is being carried out XOR with above-mentioned count value,The result obtained eventually is as check results.Specifically data to be sent can will be filled in the three of PDO words,Check results is inserted in a remaining word.The verification that this assay can realize sending data is beatenBag or the Canopen network host node data to receiving unpack inspection, when the main joint of Canopen networkPoint receive from based on Can2.0A from the Frame of node device time, according to this check results,To judge in the transmission of data, if frame losing or other error of transmission occur.
Additionally, in above-mentioned steps 301 method of calibration to data to be sent can also use even-odd check,The methods of calibration such as CRC check realize.
The present embodiment by by non-standard Canopen network Frame to be sent from node device according toThe data frame format of Canopen network service is packaged, it is achieved that non-standard Canopen network is from nodeCommunication between equipment and Canopen network host node, thus avoid based on Canopen network development fromNode is wasted time and energy, is realized more complicated problem, and then saves manpower, reduces the choosing to equipmentRequirement during type.
Embodiment 2
Fig. 4 is that the non-standard Canopen of according to embodiments of the present invention 2 is from the Frame sending method stream of nodeCheng Tu, as shown in Figure 4, this method comprises the following steps:
Step 401: Canopen network is filled in the identifier position of the arbitration of Frame from node device fieldThe function code of middle process data object PDO and communication object identifier, and fill to be sent in data fieldsData, obtain the first Frame;
Step 402: be marked the first Frame, obtains the labelling of current data frame;
Step 403: carry out verifying and generating check results to sent data;
Step 404: labelling and check results are filled in the first Frame, obtains the second Frame,Second Frame is sent the host node device to Canopen network.
In the present embodiment, in order to make Canopen network host node realize it from the monitoring of node,During in above-mentioned steps 404, the labelling of current data frame is filled into above-mentioned first Frame, so that this labellingSent along with current data frame to Canopen network host node equipment.The wherein labelling of current data frameThen can play the effect of heartbeat message, when host node receives this Frame, by this heart beating reportThe detection of literary composition, it may be determined that the most whether Frame mistake occurs.Wherein, the first Frame is enteredCurrently processed Frame can be counted by line flag, obtains the count value that current data frame is corresponding,Using count value as the labelling of the first Frame.Can also be when when transmission current data frame, will be currentData be labeled as 1, when send next Frame time, data labelling upset be 0, whenever sending a frameDuring data, carry out once inside out.
Based on realizing the purpose of heartbeat message, in the present embodiment, can be first at first three word of PDOThe data that middle filling is to be sent;It is separately provided an enumerator, every Fixed Time Interval for each PDOAdd one, reset when counter overflow;In units of byte, first three word of PDO is carried out XOR, gainedTo result value with enumerator again carry out XOR, obtain the check results of a byte;By enumeratorValue is put in the high eight-bit of the 4th word of PDO, and check results is put in the low eight of the 4th word of PDO.ThisSample just completes the packing of tetra-words of PDO, the wherein high eight-bit of the 4th word, the value of the most above-mentioned enumerator,Can realize being similar to the testing mechanism of heartbeat message, low eight verifications that can realize sending data are beatenWrap or unpack inspection to receiving data.In addition it is also possible to periodically send according to fixed time intervalHeartbeat message is to the host node of Canopen network.In the present embodiment, take while sending FrameWith heart beating herein, it is achieved that the host node of Canopen network is to from the monitoring of node, thus ensure thatThe correctness of communication and reliability.
Embodiment 3
The method that the equipment only supporting Can2.0A realizes in Canopen network communication includes following twoIndividual part:
Part I: realize being similar to the message of PDO communication, fills in the identifier position of arbitration fieldThe function code of PDO and COB-ID in Canopen Communication Model.In different equipment, COB-ID may be because joiningThe change put and change, this sentences conventional Canopen and predefines principal and subordinate's peer objects and illustrate,Corresponding predefined according to can determine that host node to this NodeID from node distributionCOB-ID, i.e. can determine that the identifier position in required arbitration field in conjunction with corresponding function code;In arbitration" dominant ", " recessive " position accordingly are filled in the request that remotely the sends position of field.It is data due to sendFrame, fills " dominant " position remotely sending at request position, position.8 byte of data fields fillData to be sent, are equivalent to four words transmitted in standard PDO.
Part II, it is achieved be similar to heartbeat message, owing to not being similar to heart beating report in Can2.0AThe agreement of literary composition function, can choose a word to realize this function in the PDO message that Part I realizes.
Fig. 5 be according to embodiments of the present invention 3 realization be similar to the method flow diagram of heartbeat message.
As it is shown in figure 5, the method comprises the following steps:
Step 501: fill data to be sent in first three word of PDO;
Step 502: being separately provided an overflow value for each PDO is the enumerator of 256, when fixingBetween interval add 1, when counter overflow reset;
Step 503: in units of byte, first three word of PDO is carried out XOR, acquired results again with enumeratorXOR, obtains the check results of a byte;
Step 504: the value of enumerator is put in the most-significant byte of the 4th word of PDO, above-mentioned check results is putLeast-significant byte in the 4th word of PDO.
Through above step, just completing the packing of tetra-words of PDO, wherein the most-significant byte of the 4th word is permissibleRealizing being similar to the monitoring mechanism of heartbeat message, least-significant byte can realize the verification packing sending data simultaneouslyOr unpack inspection to accepting data.From the point of view of above procedure sends for data, data are connectIt is subject to and unpacks testing sequence to be similar to.When " heartbeat message " lost efficacy or unpacked check errors, report communication eventBarrier.
Embodiment 4
Fig. 6 is that the non-standard Canopen of according to embodiments of the present invention 4 is from the Frame dispensing device knot of nodeStructure block diagram.
As shown in Figure 6, this non-standard Canopen includes from the Frame dispensing device 60 of node:
Processing module 61, for filling the identifier position of the arbitration of Frame from node device fieldThe function code of process data object PDO and communication object identifier in Canopen network, and in data fieldsThe data that middle filling is to be sent, obtain the first Frame;
Correction verification module 62, for carrying out verifying and generating check results to sent data;
First sending module 63, for check results being added in the first Frame, obtains the second dataFrame, sends the host node device to Canopen network by the second Frame.
In order to realize Canopen network host node to from the monitoring of node, said apparatus can also include:Second sending module, for the second Frame is being sent after the host node device of Canopen network,Heartbeat message is sent to this host node device.
In order to make Canopen network host node realize it from the monitoring of node, as it is shown in fig. 7, this realityThe device 70 executing example can also include: mark module 71, for after obtaining the first Frame, rightFirst Frame is marked, and obtains the labelling of current data frame;Based on this mark module, above-mentioned firstSending module also needs to include: adding device, for adding check results and labelling to second dataIn frame.
The most above-mentioned mark module may include that counting unit, for carrying out currently processed FrameCounting, obtains the count value that current data frame is corresponding, using count value as the labelling of the first Frame.
The most above-mentioned correction verification module can also include: the first XOR unit, for by data to be sent withByte is that unit carries out XOR, obtains the result after XOR;Second XOR unit, for by after XORResult and count value carry out XOR, obtain check results.
It should be noted that in this article, the relational terms of such as first and second or the like is used merely toOne entity or operation are separated with another entity or operating space, and not necessarily requires or implyRelation or the order of any this reality is there is between these entities or operation.And, term " includes "," comprise " or its any other variant is intended to comprising of nonexcludability, so that include that one isThe process of row key element, method, article or equipment not only include those key elements, but also include the brightestOther key elements really listed, or also include intrinsic for this process, method, article or equipmentKey element.In the case of there is no more restriction, statement " including ... " key element limited,It is not precluded from there is also other identical element in including the process of key element, method, article or equipment.
These are only presently preferred embodiments of the present invention, be not intended to limit protection scope of the present invention.All any modification, equivalent substitution and improvement etc. made within the spirit and principles in the present invention, all compriseWithin the scope of the present invention.