CN116886244A - CAN bus equipment coding method - Google Patents

CAN bus equipment coding method Download PDF

Info

Publication number
CN116886244A
CN116886244A CN202310898460.XA CN202310898460A CN116886244A CN 116886244 A CN116886244 A CN 116886244A CN 202310898460 A CN202310898460 A CN 202310898460A CN 116886244 A CN116886244 A CN 116886244A
Authority
CN
China
Prior art keywords
host
extension
hash value
bus
received
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310898460.XA
Other languages
Chinese (zh)
Inventor
张金广
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Individual filed Critical Individual
Priority to CN202310898460.XA priority Critical patent/CN116886244A/en
Publication of CN116886244A publication Critical patent/CN116886244A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0009Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the channel coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC

Abstract

The invention provides a CAN bus equipment coding method, and relates to the technical field of equipment coding. The CAN bus equipment coding method specifically comprises the following steps: s1, setting hardware; s2, powering up and sending; s3, sending by an extension; s4, resending; s5, bus transmission; s6, setting an ID; s7, restoring the result. The invention can fully automatically operate, can solve the sub-equipment coding problem under the same network on line, the equipment does not need to be off-line, and can not interrupt the communication in the sub-network, if the sub-equipment is installed in other equipment, the sub-equipment ID coding problem can be solved without disassembling and assembling other equipment, the ID setting is carried out on the sub-equipment in sequence, and the sub-equipment does not need to leave the network, and can carry out other communication to replace the broken sub-equipment, thereby the invention has the advantages of small workload and high working efficiency.

Description

CAN bus equipment coding method
Technical Field
The invention relates to the technical field of equipment coding, in particular to a CAN bus equipment coding method.
Background
The CAN bus is a serial communication protocol bus for real-time applications, which CAN use twisted pair wires to transmit signals, and is one of the most widely used fieldbuses worldwide. On the same network using CAN bus communication, each sub-device needs to have a unique ID. For a zonal molecular device.
In the conventional method of using the CAN bus, ID configuration is performed on each piece of sub-equipment in advance, and the configuration method may be that a computer is used or that dial switches are used for configuration one by one, so that workload is high and mistakes are easy to occur.
Disclosure of Invention
(one) solving the technical problems
Aiming at the defects of the prior art, the invention provides a CAN bus equipment coding method, which solves the problems of high error rate and high labor cost of the existing manual scheme.
(II) technical scheme
In order to achieve the above purpose, the invention is realized by the following technical scheme: the CAN bus equipment coding method is characterized by comprising the following steps of:
s1, hardware setting
Setting a host and a plurality of extensions;
s2, power-on transmission
When the automatic ID coding function is needed, the host sends a CAN frame informing the extension to enter an ID setting flow, the extension enters the ID setting flow, after the host delays for 100 milliseconds, the host powers on an addr+ line, after the first extension detects the power-on information of an address line through an optocoupler, the MCU calculates a HASH value according to the MCU ID and sends the HASH value to a CAN bus;
s3, sending by extension
After receiving the HASH value, the host computer is put into a first position of a two-dimensional array, and after the slave machine sends a successful HASH value CAN frame, an address output optocoupler is opened to electrify an Addr output line of the slave machine;
s4, resending
After the next extension receives the address line power-on information, the HASH value is also sent according to the flow of generating the HASH by the first extension;
s5, bus transmission
After all the extensions send HASH values, the host sends HASH values and extension IDs to the bus according to the sequence in the own array;
s6, setting ID
After receiving the data frame matched with the HASH value of the extension, the extension sets an ID for the extension according to the ID of the extension in the data, and sets a successful CAN frame for the bus sending ID;
s7, restoring the result
After receiving successful CAN frames of ID setting of all extensions, the host closes the address output line, ends ID setting flow, and when the host cannot receive replies of all extensions, the host reports error fault of ID setting.
Preferably, the host and the plurality of extensions are unified in a system.
Preferably, the host system continues to perform the downward operation if the sensor reply is received, and continues the operation if the sensor reply is not received, until the sensor reply is received.
Preferably, if the sensor has data is received, the host system continues to perform the operation downwards, and if the sensor has data is not received, the operation is continued until the sensor has data is received.
Preferably, if the host system receives the responses from all the sensors, the host system continues to perform the operation downwards, and if the host system does not receive the responses from all the sensors, the host system continues to perform the operation until the responses from all the sensors are received.
Preferably, in the sensor system, if the host computer inquires the Hash value CAN frame and the code line is powered on, the operation is continuously executed downwards, and if the host computer inquires the Hash value CAN frame and the code line is not received, the operation is continuously waited until the host computer inquires the Hash value CAN frame and the code line is powered on.
Preferably, if the configuration frame with the Hash value and the ID is received, the sensor system continues to perform the downward operation, and if the configuration frame with the Hash value and the ID is not received, the sensor system continues to wait until the configuration frame with the Hash value and the ID is received.
(III) beneficial effects
The invention provides a CAN bus equipment coding method. The beneficial effects are as follows:
the invention provides a CAN bus equipment coding method, which CAN realize full-automatic operation in an automatic coding mode, solve the problem of sub-equipment coding under the same network on line, ensure that the equipment does not need to be off-line, avoid interrupting communication in a sub-network, solve the problem of sub-equipment ID coding without disassembling and assembling other equipment if the sub-equipment is installed in other equipment, and improve the working efficiency and reduce the error probability by using the method.
Drawings
FIG. 1 is a schematic diagram of a hardware flow of the present invention;
FIG. 2 is a schematic software flow chart of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Examples:
as shown in fig. 1-2, an embodiment of the present invention provides a method for encoding a CAN bus device, which specifically includes the following steps:
s1, hardware setting
Setting a host and a plurality of extensions;
s2, power-on transmission
When the automatic ID coding function is needed, the host sends a CAN frame informing the extension to enter an ID setting flow, the extension enters the ID setting flow, after the host delays for 100 milliseconds, the host powers on an addr+ line, after the first extension detects the power-on information of an address line through an optocoupler, the MCU calculates a HASH value according to the MCU ID and sends the HASH value to a CAN bus;
s3, sending by extension
After receiving the HASH value, the host computer is put into a first position of a two-dimensional array, and after the slave machine sends a successful HASH value CAN frame, an address output optocoupler is opened to electrify an Addr output line of the slave machine;
s4, resending
After the next extension receives the address line power-on information, the HASH value is also sent according to the flow of generating the HASH by the first extension;
s5, bus transmission
After all the extensions send HASH values, the host sends HASH values and extension IDs to the bus according to the sequence in the own array;
s6, setting ID
After receiving the data frame matched with the HASH value of the extension, the extension sets an ID for the extension according to the ID of the extension in the data, and sets a successful CAN frame for the bus sending ID;
s7, restoring the result
After receiving successful CAN frames of ID setting of all extensions, the host closes the address output line, ends ID setting flow, and when the host cannot receive replies of all extensions, the host reports error fault of ID setting.
The host machine and the plurality of extensions are unified in a system, if a sensor reply is received in the host machine system, the operation is continuously performed downwards, if the sensor reply is not received, the operation is continuously performed downwards until the sensor reply is received, if the sensor Hash data is received in the host machine system, the operation is continuously performed downwards until the sensor Hash data is received, if the responses of all the sensors are received in the host machine system, the operation is continuously performed downwards until the responses of all the sensors are received, if the responses of all the sensors are not received, the operation is continuously performed downwards until the host machine inquiry Hash value CAN frame is received, and the code line is powered on, if the configuration frame with Hash value and ID is received in the sensor system, the operation is continuously performed downwards until the configuration frame with Hash value and ID is received.
Based on the above method steps, further explanation is as follows:
the technology uses 4 cables to complete the automatic coding function of the CAN bus equipment. When the automatic ID coding function is needed, the host sends a CAN frame informing the extension to enter an ID setting process, the extension enters the ID setting process, after the host delays for 100 milliseconds, the host powers on an addr+ line, after the first extension detects the power-on information of the address line through an optocoupler, the MCU calculates the HASH value according to the MCU ID and sends the HASH value to a CAN bus, after the host receives the HASH value, the MCU is placed in the first position of a two-dimensional array, after the extension sends a successful HASH value CAN frame, the optocoupler is opened, the Addr output line of the extension is powered on, after the next extension receives the power-on information of the address line, the HASH value is also sent according to the process of the first extension, after all the extensions send the HASH value, the HASH value and the extension ID are sent to the bus according to the sequence in the array, after the extension receives a data frame matched with the self H value, the HASH value is set to the self-set ID according to the extension ID in the data, after the extension ID in the data is received, the HASH value is set to the self-set up ID, after the CAN frame is sent to the bus, after all the extension receives the successful HASH value, the address frame is set, and after all the extension CAN frames are successfully set, and after all the address frames are successfully set, the host CAN be successfully set, and the host CAN not be successfully set, and the host CAN be successfully has been set, and has been successfully set, and has been set.
The error rate is high based on the existing manual scheme, the labor cost is high, and according to the existing automatic coding scheme discovered by the literature, the sub-equipment needs to interrupt communication, and some data can be lost.
The invention has the following advantages:
1. the ID setting is performed on the sub-devices in sequence.
2. The sub-equipment can carry out other communication without off-line.
3. And the damaged sub-equipment is convenient to replace.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (7)

1. The CAN bus equipment coding method is characterized by comprising the following steps of:
s1, hardware setting
Setting a host and a plurality of extensions;
s2, power-on transmission
When the automatic ID coding function is needed, the host sends a CAN frame informing the extension to enter an ID setting flow, the extension enters the ID setting flow, after the host delays for 100 milliseconds, the host powers on an addr+ line, after the first extension detects the power-on information of an address line through an optocoupler, the MCU calculates a HASH value according to the MCUID and sends the HASH value to a CAN bus;
s3, sending by extension
After receiving the HASH value, the host computer is put into a first position of a two-dimensional array, and after the slave machine sends a successful HASH value CAN frame, an address output optocoupler is opened to electrify an Addr output line of the slave machine;
s4, resending
After the next extension receives the address line power-on information, the HASH value is also sent according to the flow of generating the HASH by the first extension;
s5, bus transmission
After all the extensions send HASH values, the host sends HASH values and extension IDs to the bus according to the sequence in the own array;
s6, setting ID
After receiving the data frame matched with the HASH value of the extension, the extension sets an ID for the extension according to the ID of the extension in the data, and sets a successful CAN frame for the bus sending ID;
s7, restoring the result
After receiving successful CAN frames of ID setting of all extensions, the host closes the address output line, ends ID setting flow, and when the host cannot receive replies of all extensions, the host reports error fault of ID setting.
2. The CAN bus device encoding method of claim 1, wherein: the host and the plurality of extensions are unified in a system.
3. The CAN bus device encoding method of claim 1, wherein: and if the host system receives the sensor reply, continuing to perform the operation downwards, and if the host system does not receive the sensor reply, continuing the operation until the sensor reply is received.
4. The CAN bus device encoding method of claim 1, wherein: and if the sensor HAHS data is received, continuing to perform the operation downwards in the host system, and if the sensor HAHS data is not received, continuing the operation until the sensor HAHS data is received.
5. The CAN bus device encoding method of claim 1, wherein: and if the host system receives the responses of all the sensors, continuing to perform the operation downwards, and if the host system does not receive the responses, continuing the operation until the responses of all the sensors are received.
6. The CAN bus device encoding method of claim 1, wherein: and if the host computer inquires the CAN frame with the Hash value and the code line is powered on, the sensor system continues to execute the operation downwards, and if the host computer inquires the CAN frame with the Hash value and the code line is not received, the sensor system continues to wait until the host computer inquires the CAN frame with the Hash value and the code line is powered on.
7. The CAN bus device encoding method of claim 1, wherein: and if the configuration frame with the Hash value and the ID is received, continuing to execute the operation downwards, and if the configuration frame with the Hash value and the ID is not received, continuing to wait until the configuration frame with the Hash value and the ID is received.
CN202310898460.XA 2023-07-21 2023-07-21 CAN bus equipment coding method Pending CN116886244A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310898460.XA CN116886244A (en) 2023-07-21 2023-07-21 CAN bus equipment coding method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310898460.XA CN116886244A (en) 2023-07-21 2023-07-21 CAN bus equipment coding method

Publications (1)

Publication Number Publication Date
CN116886244A true CN116886244A (en) 2023-10-13

Family

ID=88260175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310898460.XA Pending CN116886244A (en) 2023-07-21 2023-07-21 CAN bus equipment coding method

Country Status (1)

Country Link
CN (1) CN116886244A (en)

Similar Documents

Publication Publication Date Title
CN110635982B (en) Double-host communication method and system on communication bus, industrial control gateway and storage medium
CN102902653A (en) Serial communication protocol for controller
CN110704265A (en) Early warning information active reporting method and system based on Modbus protocol
CN104506516A (en) Gateway for conversion between Modbus RTU/ASCII (remote terminal unit/American standard code for information interchange) communication protocol and Modbus TCP (transmission control protocol) communication protocol and implementation method for gateway
CN113364638B (en) Method, electronic device and storage medium for EPA networking
US20090077455A1 (en) Transmission system
CN116699964A (en) Redundant operation method and system for industrial process controller
CN107528747B (en) Method and device for diagnosing communication state of master station and slave station and computer readable storage medium
CN110247936B (en) Communication protocol conversion card and communication protocol conversion system
CN105141657A (en) Novel network communication method suitable for intelligent household control system
CN101945088A (en) Communication processing method of wide area data collection
CN111405059A (en) Data transmission method of cloud equipment, electronic equipment and Internet of things system
CN104932373A (en) Intelligent industrial network protocol wireless converter
CN113039546A (en) Master-slave equipment communication system and method
CN104348645A (en) Server and data transmission method of server
CN106953809B (en) 485 time-sharing communication-based equipment resource acquisition method
CN116886244A (en) CAN bus equipment coding method
CN104539493A (en) Intelligent terminal system and method of management and control over intelligent household electric appliances based on USB interface
CN110913431A (en) Data wireless transmission method and device, computer equipment and storage medium
CN113377363B (en) Cloud implementation method for automatically generating source codes for various electric control end private protocols
CN111385172B (en) Control system, control method and storage medium based on bus
CN114116375A (en) Data transmission method and device based on PLDM protocol
CN113986299A (en) Equipment upgrading method and device, equipment to be upgraded and system
CN114422288A (en) Communication system based on Modbus protocol
CN202906948U (en) Communication apparatus based on modbus_RTU bus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination