A slave station positioning system, method and device based on CAN bus and a storage medium

By using a cascaded connection between master and slave stations in a CAN bus system and utilizing a processor-controlled electronic switch to automatically assign slave station identification information, the high cost and misoperation problems caused by manual intervention and hardware wiring in existing technologies are solved, thereby achieving accurate positioning of slave stations and improving communication efficiency.

CN116455698BActive Publication Date: 2026-04-21惠州市海葵信息技术有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
惠州市海葵信息技术有限公司
Filing Date
2023-04-28
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, CAN bus slave positioning methods require a lot of manual intervention or hardware wiring, resulting in high costs and the risk of misoperation.

Method used

A slave positioning system based on CAN bus is adopted. Through the cascading connection between the master station and the slave station, the processor controls the electronic switch to realize the automatic allocation and communication of slave station identification information, reducing manual intervention and hardware wiring.

Benefits of technology

It achieves accurate positioning of the slave station, reduces costs and lowers the risk of misoperation, and improves communication efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116455698B_ABST
    Figure CN116455698B_ABST
Patent Text Reader

Abstract

The application discloses a slave station positioning system, method and device based on a CAN bus and a storage medium. The system comprises a master station and at least two slave stations. The master station and the slave stations are connected in cascade. The slave stations are connected with the master station or the slave station of the upper level through electronic switches. The slave stations are connected with the slave station of the lower level through electronic switches. The communication between the slave stations and the master station or the slave station of the upper and lower levels is controlled by controlling the conduction or disconnection of the electronic switches. According to the communication feedback, automatic positioning in the process of distributing the identity information of the slave stations is realized. The embodiment of the application can accurately position the positions of the slave stations, reduces the cost, and can be widely applied to the technical field of communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a slave positioning system, method, apparatus and storage medium based on CAN bus. Background Technology

[0002] In a CAN communication bus, one CAN master connects to multiple CAN slaves. Slave IDs (Identity Documents) cannot be duplicated, and the master needs to know the exact location of each slave. In related technologies, IDs are distributed via broadcast or message, causing contention among slaves and resulting in out-of-order transmission of slave IDs on the bus, making it impossible for the master to locate them. Slave location methods include: 1. Manually determining the ID using DIP switches, requiring personnel to go to the device to set the ID at a specific location, resulting in significant manpower intervention; 2. Adding other communication methods, such as external I / O or PWM signal lines, requiring personnel to connect them one-to-one at the device, leading to extensive maintenance and on-site hardware checks to determine if communication problems exist. These methods have the following problems: increased labor or wiring costs, and the potential for operational errors. Summary of the Invention

[0003] In view of this, the purpose of this invention is to provide a slave positioning system, method, device and storage medium based on CAN bus, which can accurately locate the slave position and reduce costs.

[0004] In a first aspect, embodiments of the present invention provide a slave positioning system based on a CAN bus, comprising a master station and at least two slave stations. The master station includes a CAN transceiver and a processor, wherein the CAN transceiver in the master station is communicatively connected to the processor. Each slave station includes a CAN transceiver, a processor, five electronic switches, and a resistor. The CAN transceiver in the slave station is communicatively connected to the processor. Two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a first electronic switch and a second electronic switch to form a first port. Two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a third electronic switch. A fourth electronic switch forms a second port, and a fifth electronic switch is connected in series with a resistor to the two differential signal terminals of the CAN transceiver in the slave station. The processor in the slave station controls the first and second electronic switches in the station through a first signal, the third and fourth switches in the station through a second signal, and the fifth electronic switch in the station through a third signal. The circuit structure of each slave station is the same. The master station and at least two slave stations are connected in series. The two differential signal terminals of the CAN transceiver in the master station are connected to the first port in the first-level slave station, and the second port in the previous-level slave station is connected to the first port in the next-level slave station.

[0005] Optionally, the electronic switch may include an optocoupler or a relay.

[0006] Secondly, embodiments of the present invention provide a slave station positioning method based on a CAN bus, applied to a slave station, comprising:

[0007] The first signal controls the first and second electronic switches to turn on so that the first port is turned on; the second signal controls the third and fourth electronic switches to turn off so that the second port is turned off; the third signal controls the fifth electronic switch to turn on; the first identity information is received; and the identity information of the user is determined based on the first identity information.

[0008] The first signal controls the first and second electronic switches to disconnect the first port, and the second signal controls the third and fourth electronic switches to turn on the second port. The device sends its own identification information to the next slave station at a preset time interval and waits for a response signal.

[0009] If a response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, and the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port. The first information is sent to the main station, and the first information includes its own identification code.

[0010] If no response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, and the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port. The second information is sent to the master station, and the second information includes the self-identification code and interrupt information.

[0011] Optionally, the method further includes:

[0012] If a response message is received from the master station for the first message, the third and fourth electronic switches are disconnected via the second signal to enable the second port to conduct, and the fifth electronic switch is disconnected via the third signal.

[0013] Thirdly, embodiments of the present invention provide a slave station positioning method based on a CAN bus, applied to a master station, including:

[0014] Send initial identification information to the slave station;

[0015] Receive first or second information sent by the slave station; the first information includes its own identification code, and the second information includes its own identification code and interrupt information.

[0016] The location information of the slave station in normal communication is determined based on the first information, or the location information of the slave station in normal communication and whether there is any abnormality in communication are determined based on the second information.

[0017] Optionally, the location information of the slave station in normal communication and whether there is an anomaly in the communication are determined based on the second information, specifically including:

[0018] The location information of the slave station is determined based on its own identification code in the second information;

[0019] The corresponding identity information is determined based on the self-identification code in the second information, and the identity information corresponding to the self-identification code is compared with the termination identity information.

[0020] If the identity information corresponding to the self-identification code is the same as the terminated identity information, the identity information allocation is complete and communication is normal.

[0021] Otherwise, communication will be abnormal.

[0022] Optionally, the method further includes:

[0023] If communication fails, send an exception handling instruction based on the interruption information in the second message.

[0024] Optionally, the interruption information includes power failure, connection error, or identity error. The step of sending an error handling instruction based on the interruption information in the second information specifically includes:

[0025] If the interruption information is a power outage, after power is restored, a command to continue allocating identity information will be sent.

[0026] If the interruption message indicates a connection error, send a command to reassign identity information.

[0027] If the interruption message indicates an identity error, send an instruction to assign identity information.

[0028] Fourthly, embodiments of the present invention provide a slave positioning method apparatus based on a CAN bus, comprising:

[0029] At least one processor;

[0030] At least one memory for storing at least one program;

[0031] When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0032] Fifthly, embodiments of the present invention provide a storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the methods described above.

[0033] Implementing the embodiments of the present invention has the following beneficial effects: In this embodiment, the master station and the slave station are cascaded. The master station and the slave station are connected through the first port of the slave station. Between slave stations, the second port in the upper-level slave station is connected to the first port in the lower-level slave station. The processor in the slave station controls the conduction or disconnection of the first port and the second port, thereby realizing communication between the slave station and the master station or between upper and lower-level slave stations. The slave station determines its own identity information based on the received first identity information and sends its own identity information or interruption information to the master station. The master station accurately locates the location information and abnormal communication information of the slave station based on the identity information or interruption information, thereby reducing costs. Attached Figure Description

[0034] Figure 1 This is a structural block diagram of a slave positioning system based on a CAN bus provided in an embodiment of the present invention;

[0035] Figure 2 This is a circuit schematic diagram of a slave station provided in an embodiment of the present invention;

[0036] Figure 3 This is a flowchart illustrating the steps of a positioning method for slave stations based on a CAN bus, as provided in an embodiment of the present invention.

[0037] Figure 4 This is a flowchart illustrating the steps of a positioning method based on a CAN bus applied to a master station, as provided in an embodiment of the present invention.

[0038] Figure 5 This is a structural block diagram of a slave positioning device based on a CAN bus provided in an embodiment of the present invention. Detailed Implementation

[0039] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. The step numbers in the following embodiments are only for ease of explanation and do not limit the order of the steps. The execution order of each step in the embodiments can be adapted according to the understanding of those skilled in the art.

[0040] like Figure 1As shown, this embodiment of the invention provides a slave positioning system based on a CAN bus, including a master station and at least two slave stations. The master station includes a CAN transceiver and a processor, and the CAN transceiver in the master station is communicatively connected to the processor. Each slave station includes a CAN transceiver, a processor, five electronic switches, and a resistor. The CAN transceiver in the slave station is communicatively connected to the processor. The two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a first electronic switch and a second electronic switch to form a first port (H0 / L0). The two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a third electronic switch and a fourth electronic switch. A sub-switch forms a second port (H1 / L1). A fifth electronic switch is connected in series with a resistor to the two differential signal terminals of the CAN transceiver in the slave station. The processor in the slave station controls the first and second electronic switches in the station through the first signal I1, the third and fourth switches in the station through the second signal I2, and the fifth electronic switch in the station through the third signal I3. Each slave station has the same circuit structure. The master station and at least two slave stations are connected in series. The two differential signal terminals of the CAN transceiver in the master station are connected to the first port in the first-level slave station, and the second port in the previous-level slave station is connected to the first port in the next-level slave station.

[0041] The processor includes, but is not limited to, an MCU. Communication between the processor and the CAN transceiver is via level signals, while communication between the CAN transceivers is via differential signals. The CAN transceivers between the master and slave stations are connected via electronic switches, as are the CAN transceivers between slave stations. The electronic switches within a slave station are controlled by the processor within that station to be on or off. Communication between the CAN transceivers is only possible if all electronic switches are on; if any electronic switch is off, communication between the CAN transceivers is abnormal.

[0042] In one specific embodiment, the master station and the first-level slave station are connected via a first electronic switch and a second electronic switch of the first-level slave station. If the master station and the first-level slave station need to communicate identity information, both the first and second electronic switches need to be turned on. The differential signal terminal of the first-level slave station is connected to the next-level slave station via a third electronic switch and a fourth electronic switch. If the first-level slave station needs to communicate identity information with the next-level slave station, both the third and fourth electronic switches need to be turned on.

[0043] It should be noted that the number of slave stations is determined based on the actual application, and this embodiment does not impose a specific limit.

[0044] Optionally, the electronic switch may include an optocoupler or a relay.

[0045] It should be noted that electronic switches include, but are not limited to, optocouplers or relays, depending on the actual application. This embodiment does not impose any specific limitations.

[0046] See Figure 2 In one specific embodiment, the electronic switch is an optocoupler, U1 represents the CAN transceiver of the first-level slave station, CANL and CANH in U1 represent differential signal terminals, and MCU represents the processor. The differential signal terminals of U1 are respectively connected to one end of the first optocoupler K1 and the first optocoupler K2, and the other ends of the first optocoupler K1 and the first optocoupler K2 form the first port H0 / L0, which is used to connect to the CAN transceiver of the master station; the differential signal terminals of U1 are respectively connected to one end of the third optocoupler K3 and the fourth optocoupler K4, and the other ends of the third optocoupler K3 and the fourth optocoupler K4 form the second port H1 / L1, which is used to connect to the CAN transceiver of the next-level slave station; the fifth optocoupler K5 and the resistor R5 are connected in series at the differential signal terminals of U1. The MCU's output1 acts as the first signal to control K1 and K2, the MCU's output2 acts as the second signal to control K3 and K4, and the MCU's output3 acts as the third signal to control K5.

[0047] like Figure 3 As shown, this embodiment of the invention provides a slave station positioning method based on a CAN bus, applied to a slave station, including steps S110 to S140:

[0048] S110: Control the first electronic switch and the second electronic switch to turn on through the first signal to turn on the first port; control the third electronic switch and the fourth electronic switch to turn off through the second signal to turn off the second port; control the fifth electronic switch to turn on through the third signal; receive the first identity information; and determine its own identity information based on the first identity information.

[0049] Specifically, see Figure 1 The system works as follows: First signal I1 controls the first and second electronic switches to conduct, enabling the first port to be open, allowing the slave station to communicate with the master station or a higher-level slave station regarding identity information. Second signal I2 controls the third and fourth electronic switches to deactivate, disconnecting the second port, preventing the slave station from communicating with the next-level slave station regarding identity information. Third signal I3 controls the fifth electronic switch to conduct, with a resistor connected to the CAN bus, allowing communication between connected slave stations or between the master station and the first-level slave station, with the communication content being identity identification information. For example, with the first-level slave station open and the resistor connected to the bus, it can communicate with the master station regarding identity information; with the second port closed, it cannot communicate with the next-level slave station regarding identity information.

[0050] Identity information refers to the identity information of the slave station, including but not limited to ID. First identity information refers to the already determined identity information, and self-identity information refers to the identity information of the slave station itself.

[0051] After receiving the first identity information, the slave station determines its own identity information according to preset rules and the first identity information. For example, the first identity information is represented by ID. If the slave station receives the first identity information as ID=5, it will automatically increment the first identity information by one to generate its own identity information, that is, the slave station's own identity information is ID=6.

[0052] S120: The first electronic switch and the second electronic switch are disconnected by controlling the first signal to disconnect the first port, and the third electronic switch and the fourth electronic switch are turned on by controlling the second signal to turn on the second port. The device sends its own identification information to the next level slave station at a preset time interval and waits for a response signal.

[0053] It should be noted that the fifth electronic switch remains in the ON state at this time. The preset time interval is determined according to the actual application, and this embodiment does not impose specific limitations.

[0054] Specifically, see Figure 1 The first electronic switch and the second electronic switch are disconnected by the first signal I1, so that the first port is disconnected, meaning that the slave station cannot communicate identity information with the master station or slave station above it; the third electronic switch and the fourth electronic switch are turned on by the second signal I2, so that the second port is turned on, meaning that the slave station can communicate identity information with the next level slave station.

[0055] The slave station at this level sends its own identification information to the next-level slave station at preset time intervals and waits for a response signal. If the communication is normal, the next-level slave station will send a response signal after receiving the identification information sent by the previous level.

[0056] S130. If a response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port, and the first information is sent to the main station, the first information including its own identification code.

[0057] It should be noted that the fifth electronic switch remains in the ON state at this time. The preset time period corresponds to a preset number of transmissions; therefore, the preset time period can also be understood as the number of transmissions reaching a preset threshold. The preset time period or the preset transmission threshold is determined based on the actual application, and this embodiment does not impose specific limitations.

[0058] It should be noted that the self-identification code represents the location information of the slave station, and the self-identification code includes, but is not limited to, the SN (Serial Number) code.

[0059] Specifically, see Figure 1 The first electronic switch and the second electronic switch are turned on by the first signal I1 to make the first port open, that is, the slave station can communicate with the upper-level master station or slave station for identity information; the third electronic switch and the fourth electronic switch are turned off by the second signal I2 to make the second port open, that is, the slave station cannot communicate with the lower-level slave station for identity information.

[0060] If a response signal is received within the preset time, it indicates that the communication of the next-level slave station is normal. If the slave station is a first-level slave station, it will send the first information, including its own identification code, to the master station. If the slave station is not a first-level slave station, it will send the first information, including its own identification code, to the previous-level slave station, so that the previous-level slave station can send its first information to the master station. The master station receives the self-identification code sent by the slave station and confirms that the slave station at the corresponding position is communicating normally.

[0061] Optionally, the method further includes:

[0062] S131. If a response message to the first message sent by the master station is received, the third and fourth electronic switches are disconnected by the second signal to make the second port conduct, and the fifth electronic switch is disconnected by the third signal.

[0063] It should be noted that at this time, the first port is in the on state, the second port is in the off state, and the fifth electronic switch is in the on state.

[0064] If a response is received from the master station for the first message, it indicates that the slave station's identity information allocation is complete, and the slave station can enter the normal information transmission mode to receive the slave station's communication identity information. Therefore, the second signal controls the third and fourth electronic switches to disconnect to enable the second port to conduct, and the third signal controls the fifth electronic switch to disconnect.

[0065] S140. If no response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port, and the second information is sent to the master station. The second information includes the self-identification code and interrupt information.

[0066] It should be noted that the fifth electronic switch is still in the on state at this time.

[0067] Specifically, see Figure 1The first electronic switch and the second electronic switch are turned on by the first signal I1 to make the first port open, that is, the slave station can communicate with the upper-level master station or slave station for identity information; the third electronic switch and the fourth electronic switch are turned off by the second signal I2 to make the second port open, that is, the slave station cannot communicate with the lower-level slave station for identity information.

[0068] If no response signal is received within the preset time, it indicates that the slave station cannot communicate its identity information with the next-level slave station, resulting in an interruption. The slave station will then send a second message, including its own identification code and the interruption information, to the master station.

[0069] like Figure 4 As shown, this embodiment of the invention provides a slave station positioning method based on a CAN bus, applied to a master station, including:

[0070] S210. Send initial identification information to the slave station.

[0071] The initial identification information represents the identification information starting from the slave station. For example, the master station sends the initial identification information ID=0 to the first-level slave station. After receiving the initial identification information, the first-level slave station determines its own identification information based on the initial identification information, sends its identification information to the next-level slave station, receives the response signal from the next-level slave station, and determines whether to send the first or second information to the master station based on the response signal.

[0072] S220: Receive first information or second information sent by the slave station; the first information includes its own identification code, and the second information includes its own identification code and interrupt information.

[0073] The master station receives either the first or second message sent by the slave station. If the master station receives the first message, it indicates that the communication is normal during the slave station's allocation of identity information. If the master station receives the second message, it indicates that the communication is interrupted during the slave station's allocation of identity information.

[0074] S230. Determine the location information of the slave station in normal communication based on the first information, or determine the location information of the slave station in normal communication and whether there is an abnormality in communication based on the second information.

[0075] If the master station receives the first message, it only needs to determine the location information of the slave station; if the master station receives the second message, it needs to determine the location information of the slave station and at the same time determine whether there is any communication abnormality in the process of allocating identity information.

[0076] Communication interruption may occur in two ways: 1. Identity information has been allocated; 2. Identity information has not been allocated, and an anomaly occurred during the allocation process.

[0077] Optionally, the location information of the slave station in normal communication and whether there is an anomaly in the communication are determined based on the second information, specifically including:

[0078] S2301. Determine the location information of the slave station based on its own identification code in the second information.

[0079] There is a one-to-one correspondence between the slave station's self-identification code and its location information. Therefore, the location information of the slave station can be determined based on its self-identification code.

[0080] S2302. Determine the corresponding identity information based on the self-identification code in the second information, and compare the identity information corresponding to the self-identification code with the termination identity information.

[0081] The termination identification information represents the identification information of the last slave station.

[0082] There is a one-to-one correspondence between the slave station's self-identification code and identity information. Therefore, the slave station's identity information can be determined based on its self-identification code. Then, the determined identity information is compared with the termination identity information to determine whether the allocation of identity information has been completed.

[0083] S2303. If the identity information corresponding to the self-identification code is the same as the termination identity information, the identity information allocation is completed and communication is normal.

[0084] S2304. Otherwise, communication is abnormal.

[0085] If the identity information corresponding to the self-identification code is the same as the termination identity information, the identity information allocation is complete and communication is normal; if the identity information corresponding to the self-identification code has not reached the set termination identity information, the identity information allocation is not complete and there is a communication error in the allocation process.

[0086] Optionally, the method further includes:

[0087] S240. If communication is abnormal, send an exception handling instruction according to the interruption information in the second information.

[0088] If a communication failure occurs at the slave station, the master station needs to send an exception handling instruction based on the interruption information in the second information to restore the identity information to normal.

[0089] Optionally, the interruption information includes power failure, connection error, or identity error. The step of sending an error handling instruction based on the interruption information in the second information specifically includes:

[0090] S2401. If the interruption information is a power failure, after power is restored, send an instruction to continue allocating identity information.

[0091] If a power outage occurs during the ID allocation process, the logic for allocating identity information will continue to execute after power is restored until the identity information allocation is complete.

[0092] S2402. If the interruption information is a connection error, send a command to reassign identity information.

[0093] If the identification information (ID) of the entire line has been assigned, or if a communication failure occurs during the operation of a device that has ended the automatic assignment of identification information (heartbeat transmission failure of any slave station / CAN bus disconnection), the master station sends a command to the slave station, causing the slave station's processor to trigger a reset and re-enter the ID waiting state.

[0094] S2403. If the interruption information indicates an identity abnormality, send an instruction to assign identity information.

[0095] If the number of slave stations changes, such as the addition or deletion of slave stations, the identity identification information (ID) needs to be reassigned. The master station sends a broadcast command to make each slave station enter the ID waiting state.

[0096] See Figure 5 This invention provides a slave positioning method apparatus based on a CAN bus, comprising:

[0097] At least one processor;

[0098] At least one memory for storing at least one program;

[0099] When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0100] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0101] Furthermore, this application also discloses a computer program product or computer program stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the described method. Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0102] Implementing the embodiments of the present invention has the following beneficial effects: In this embodiment, the master station and the slave station are cascaded. The master station and the slave station are connected through the first port of the slave station. Between slave stations, the second port in the upper-level slave station is connected to the first port in the lower-level slave station. The processor in the slave station controls the conduction or disconnection of the first port and the second port, thereby realizing communication between the slave station and the master station or between upper and lower-level slave stations. The slave station determines its own identity information based on the received first identity information and sends its own identity information or interruption information to the master station. The master station accurately locates the location information and abnormal communication information of the slave station based on the identity information or interruption information, thereby reducing costs.

[0103] It is evident that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0104] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A slave positioning system based on a CAN bus, characterized in that, The system includes a master station and at least two slave stations. The master station includes a CAN transceiver and a processor, with the CAN transceiver and processor being communicatively connected. Each slave station includes a CAN transceiver, a processor, five electronic switches, and a resistor. The CAN transceiver in the slave station is communicatively connected to the processor. The two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a first electronic switch and a second electronic switch to form a first port. The two differential signal terminals of the CAN transceiver in the slave station are respectively connected to a third electronic switch and a fourth electronic switch to form a second port. A fifth electronic switch and a resistor are connected in series between the two differential signal terminals of the CAN transceiver in the slave station. The processor in the slave station controls the first and second electronic switches in the station via a first signal, controls the third and fourth switches in the station via a second signal, and controls the fifth electronic switch in the station via a third signal. The circuit structure of each slave station is identical. The master station and at least two slave stations are connected in series. The two differential signal terminals of the CAN transceiver in the master station are connected to the first port in the first-level slave station, and the second port in the previous-level slave station is connected to the first port in the next-level slave station.

2. The system according to claim 1, characterized in that, The electronic switch includes an optocoupler or a relay.

3. A slave positioning method based on CAN bus, characterized in that, The slave station applied to the system according to any one of claims 1-2 includes: The first signal controls the first and second electronic switches to turn on so that the first port is turned on; the second signal controls the third and fourth electronic switches to turn off so that the second port is turned off; the third signal controls the fifth electronic switch to turn on; the first identity information is received; and the identity information of the user is determined based on the first identity information. The first signal controls the first and second electronic switches to disconnect the first port, and the second signal controls the third and fourth electronic switches to turn on the second port. The device sends its own identification information to the next slave station at a preset time interval and waits for a response signal. If a response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, and the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port. The first information is sent to the main station, and the first information includes its own identification code. If no response signal is received within a preset time, the first electronic switch and the second electronic switch are turned on by the first signal to turn on the first port, and the third electronic switch and the fourth electronic switch are turned off by the second signal to turn off the second port. The second information is sent to the master station, and the second information includes the self-identification code and interrupt information.

4. The method according to claim 3, characterized in that, The method further includes: If a response message is received from the master station for the first message, the third and fourth electronic switches are disconnected via the second signal to enable the second port to conduct, and the fifth electronic switch is disconnected via the third signal.

5. A slave positioning method based on a CAN bus, characterized in that, The master station applied to the system according to any one of claims 1-2 includes: Send initial identification information to the slave station; Receive first or second information sent by the slave station; the first information includes its own identification code, and the second information includes its own identification code and interrupt information. The location information of the slave station in normal communication is determined based on the first information, or the location information of the slave station in normal communication and whether there is any abnormality in communication are determined based on the second information.

6. The method according to claim 5, characterized in that, The second piece of information determines the location information of the slave station in normal communication and whether there are any communication anomalies, specifically including: The location information of the slave station is determined based on its own identification code in the second information; The corresponding identity information is determined based on the self-identification code in the second information, and the identity information corresponding to the self-identification code is compared with the termination identity information. If the identity information corresponding to the self-identification code is the same as the terminated identity information, the identity information allocation is complete and communication is normal. Otherwise, communication will be abnormal.

7. The method according to claim 5, characterized in that, The method further includes: If communication fails, send an exception handling instruction based on the interruption information in the second message.

8. The method according to claim 7, characterized in that, Interruption information includes power outage, connection error, or identity error. The step of sending an exception handling instruction based on the interruption information in the second information specifically includes: If the interruption information is a power outage, after power is restored, a command to continue allocating identity information will be sent. If the interruption message indicates a connection error, send a command to reassign identity information. If the interruption message indicates an identity error, send an instruction to assign identity information.

9. A slave positioning method device based on CAN bus, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method as described in any one of claims 3-8.

10. A storage medium storing a processor-executable program, characterized in that, The processor-executable program, when executed by the processor, is used to perform the method as described in any one of claims 3-8.

Citation Information

Patent Citations

  • Battery system automatic networking method based on CAN bus

    CN110505135A

  • Communication state detection method, master station, slave station and readable storage medium

    CN114500323A