Circuit for automatically determining ID (Identity) in CAN (Controller Area Network) communication and distribution method
By using ADC and DAC chips in the CAN network to detect voltage and determine the module position through arithmetic sequence decrement, automatic ID allocation of CAN communication is achieved, solving the problems of cumbersome and high cost in traditional ID configuration, and achieving flexibility and low latency ID assignment.
Patent Information
- Application Number
- CN202411289128.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-12-27
AI Technical Summary
In CAN networks, traditional ID configuration methods require manual settings, resulting in cumbersome configuration and error-proneness. The allocation process is complicated when there are many nodes, which increases communication costs.
A circuit for automatically determining ID in CAN communication is designed. ADC and DAC chips are used to realize module position detection and automatic allocation of ID through resistor and capacitor components. The voltage difference value of arithmetic sequence is used to determine the module position, and the MCU is connected to the IIC bus. Automatic ID allocation.
It realizes configuration flexibility and low communication costs, simplifies the ID allocation process, reduces the error rate, and has the advantages of fast and accurate, low cost and no time delay.
Smart Images

Figure CN119210925A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a circuit and a distribution method for automatically determining IDs in CAN communication. Background Art
[0002] CAN (Controller Area Network) communication is a serial communication protocol widely used in automobiles, industrial control and other embedded systems. It is used to achieve efficient data transmission and communication between microcontrollers and devices on the same network.
[0003] In a CAN network, each node (device) requires a unique identifier (ID) for correct data exchange and identification. Traditional CAN systems usually require manual settings or manual configuration tools to assign these IDs, which can make configuration cumbersome and error-prone in large systems.
[0004] Traditional ID configuration includes static ID configuration and dynamic ID configuration. Static ID configuration means manually assigning a unique ID to each CAN node during the system design phase. Although this method is simple, the configuration work is cumbersome in large systems and is prone to ID conflicts and configuration errors. Dynamic ID configuration means dynamically assigning IDs to each slave device (Slave) through the master controller (Master) on the CAN bus. Although this method improves configuration flexibility, it still requires additional communication costs, and the allocation process becomes complicated when the number of network nodes is large. Summary of the invention
[0005] The purpose of the present invention is to provide a technical solution of a circuit and allocation method for automatically determining ID in CAN communication in view of the deficiencies in the prior art. The circuit is not only flexible in configuration, but also greatly reduces the communication cost. When the number of network nodes is large, the allocation process can be simplified by automatic allocation, which is less prone to errors. The allocation method can not only quickly and accurately determine the position of the module in the entire combination, but also automatically allocate the ID, which has the advantages of low cost, simple algorithm and no time delay.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] A circuit for automatically determining ID via CAN communication, characterized in that:
[0008] CAN bus;
[0009] and a plurality of modules, the modules being connected to a CAN bus;
[0010] Each module includes an ADC chip, a DAC chip, a DCI pin connected to the ADC chip, and a DCO pin connected to the DAC chip. The DCI pin is connected to a resistor R46, and the DCO pin is connected to a resistor R49. The ADC chip is used to detect the voltage of the DCI pin, and the DAC chip is used to generate a target voltage and assign it to the DCO pin.
[0011] When two adjacent modules are connected, the DCO pin of the previous module is connected to the DCI pin of the next module, and the voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module. The position of the module is determined along the CAN bus, and the module automatically assigns an ID.
[0012] This circuit not only has flexible configuration, but also greatly reduces communication costs. When the number of network nodes is large, the allocation process can be simplified through automatic allocation, making it easier to make mistakes.
[0013] Furthermore, the voltage values of the DCI pins of two adjacent modules decrease in an arithmetic progression.
[0014] Furthermore, the decreasing difference of the arithmetic progression is the ratio of the power supply voltage to the total number of modules.
[0015] Furthermore, the target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (power supply voltage-Vout) / (R46+R49)=(Vin-Vout) / R49.
[0016] Furthermore, each module includes an MCU and an IIC bus, and the MCU is connected to the ADC chip and the DAC chip through the IIC bus.
[0017] Further, the VIN+ pin of the ADC chip is connected to resistor R47, resistor R47 is connected to the DCI pin, capacitor C31 and resistor R46, capacitor C31 is connected to CAN_GND, and resistor R46 is connected to CAN_5V.
[0018] Further, the VIN- pin of the ADC chip is connected to capacitor C33, capacitor C32 and CAN_GND, and the VDD pin of the ADC chip is connected to capacitor C33, capacitor C32 and CAN_5V.
[0019] Further, the SCL pin and the SDA pin of the DAC chip are connected to the SCL pin and the SDA pin of the ADC chip respectively.
[0020] Further, the VOUT pin of the DAC chip is connected to resistor R49 and capacitor C37, resistor R49 is connected to the DCO pin, the VSS pin of the DAC chip is connected to capacitor C37, CAN_GND, capacitor C38 and capacitor C39, and the VDD pin of the DAC chip is connected to capacitor C38, capacitor C39 and CAN_5V.
[0021] The method for allocating a circuit for automatically determining an ID in CAN communication as described above is characterized by comprising the following steps:
[0022] S1, selecting a module at a certain position in the circuit, the DCI pin of the module corresponding to the position is not connected to the DCO pin of other modules, detecting the voltage of the DCI pin through the ADC chip of the module, and assigning the power supply voltage of the circuit to the DCI pin;
[0023] S2, the ADC chip of the module detects that the voltage of the DCI pin is the power supply voltage, and the module automatically assigns an ID of 1;
[0024] S3, determining the voltage values of the DCI pins of two adjacent modules, the voltage values decreasing in an arithmetic progression, and the difference of the decreasing arithmetic progression is the ratio of the power supply voltage to the total number of modules;
[0025] S4, connect the next module, the DCO pin of the previous module is connected to the DCI pin of the next module, the voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module, the target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (power supply voltage - Vout) / (R46+R49)=(Vin-Vout) / R49, determine the position of the next module on the CAN bus, and automatically assign an ID;
[0026] S5. The remaining modules are positioned on the CAN bus in the same manner and IDs are automatically assigned.
[0027] This allocation method can not only quickly and accurately determine the position of the module in the entire combination, but also automatically allocate IDs, and has the advantages of low cost, simple algorithm, and no time delay.
[0028] The present invention has the following beneficial effects due to the adoption of the above technical solution:
[0029] 1. The present invention not only has flexible configuration, but also greatly reduces the communication cost. When the number of network nodes is large, the allocation process can be simplified through automatic allocation, which makes it easier to make mistakes.
[0030] 2. The allocation method of the present invention can not only quickly and accurately determine the position of the module in the entire combination, but also automatically allocate IDs, and has the advantages of low cost, simple algorithm, and no time delay. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The present invention will be further described below in conjunction with the accompanying drawings:
[0032] Figure 1 A topological structure diagram of a circuit for automatically determining IDs in CAN communication and a method for automatically determining IDs in the present invention;
[0033] Figure 2 It is a structural schematic diagram of a single module in the present invention;
[0034] Figure 3 This is a circuit connection diagram of a single module ADC chip and a DAC chip in the present invention;
[0035] Figure 4 This is a flow chart of automatically determining ID in the present invention. DETAILED DESCRIPTION
[0036] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0037] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only embodiments of a part of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0039] like Figures 1 to 3 As shown, a circuit for automatically determining ID in CAN communication includes a CAN bus and several modules, wherein the modules are connected to the CAN bus.
[0040] Each module includes an ADC chip, a DAC chip, a DCI pin connected to the ADC chip, and a DCO pin connected to the DAC chip. The DCI pin is connected to a resistor R46, and the DCO pin is connected to a resistor R49. The ADC chip is used to detect the voltage of the DCI pin, and the DAC chip is used to generate a target voltage and assign it to the DCO pin.
[0041] Each module also includes an MCU and an IIC bus, and the MCU is connected to the ADC chip and the DAC chip through the IIC bus.
[0042] The VIN+ pin of the ADC chip is connected to resistor R47, resistor R47 is connected to the DCI pin, capacitor C31 and resistor R46, capacitor C31 is connected to CAN_GND, and resistor R46 is connected to CAN_5V.
[0043] The VIN- pin of the ADC chip is connected to capacitor C33, capacitor C32 and CAN_GND, and the VDD pin of the ADC chip is connected to capacitor C33, capacitor C32 and CAN_5V.
[0044] The SCL pin and SDA pin of the DAC chip are connected to the SCL pin and SDA pin of the ADC chip respectively.
[0045] The VOUT pin of the DAC chip is connected to resistor R49 and capacitor C37, resistor R49 is connected to the DCO pin, the VSS pin of the DAC chip is connected to capacitor C37, CAN_GND, capacitor C38 and capacitor C39, and the VDD pin of the DAC chip is connected to capacitor C38, capacitor C39 and CAN_5V.
[0046] When two adjacent modules are connected, the DCO pin of the previous module is connected to the DCI pin of the next module, and the voltage values of the DCI pins of the two adjacent modules decrease in an arithmetic progression. The difference of the decreasing arithmetic progression is the ratio of the power supply voltage to the total number of modules.
[0047] The target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (supply voltage-Vout) / (R46+R49)=(Vin-Vout) / R49.
[0048] The voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module, the position of the module is determined along the CAN bus, and the module automatically assigns an ID.
[0049] This circuit not only has flexible configuration, but also greatly reduces communication costs. When the number of network nodes is large, the allocation process can be simplified through automatic allocation, making it easier to make mistakes.
[0050] like Figure 4 As shown, a method for allocating a circuit for automatically determining an ID in CAN communication of the present invention comprises the following steps:
[0051] S1, selecting a module at a certain position in the circuit, the DCI pin of the module corresponding to the position is not connected to the DCO pin of other modules, detecting the voltage of the DCI pin through the ADC chip of the module, and assigning the power supply voltage of the circuit to the DCI pin;
[0052] S2, the ADC chip of the module detects that the voltage of the DCI pin is the power supply voltage, and the module automatically assigns an ID of 1;
[0053] S3, determining the voltage values of the DCI pins of two adjacent modules, the voltage values decreasing in an arithmetic progression, and the difference of the decreasing arithmetic progression is the ratio of the power supply voltage to the total number of modules;
[0054] S4, connect the next module, the DCO pin of the previous module is connected to the DCI pin of the next module, the voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module, the target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (power supply voltage - Vout) / (R46+R49)=(Vin-Vout) / R49, determine the position of the next module on the CAN bus, and automatically assign an ID;
[0055] S5. The remaining modules are positioned on the CAN bus in the same manner and IDs are automatically assigned.
[0056] This allocation method can not only quickly and accurately determine the position of the module in the entire combination, but also automatically allocate IDs, and has the advantages of low cost, simple algorithm, and no time delay.
[0057] This application is explained by taking 4 modules as an example. In this application, R46=100k, R49=1k, and the power supply voltage is 5V as an example, and the formula for Vout and Vin is: Vout=1.01Vin-0.05V.
[0058] For the module at position 1 in the topology, since its DCI is not connected to the DCO pin of other modules, the voltage detected by its ADC is 5V. Since the power supply voltage is 5V, the voltage range that the ADC can recognize is 0~5V. Assuming that there are 10 modules connected according to the above topology, the expected DCI voltage of each module after connection is 5V / 10=0.5V lower than the voltage detected by the previous module.
[0059] That is, the DCI detected at bit 1 is 5V, which is the highest voltage, and the module automatically assigns ID 1.
[0060] At the same time, in order to make the DCI voltage of the module at position 2 5V-0.5V=4.5V, the DCO voltage of the module at position 1 Vout=1.01*4.5V-0.05V=4.495V, that is, the DAC output voltage at position 1 is 4.495V.
[0061] The module at position 2 detects that the voltage of the DCI pin is 4.5V, and thus determines its position in the module combination and automatically assigns an ID of 2.
[0062] At the same time, in order to make the voltage detected by the DCI of the next module 4.5V-0.5V=4V, the output voltage of the DAC of the module at position 2 is Vout=1.01*4.0V-0.05V=3.99V.
[0063] At this time, the voltage detected by the DCI of the module at position 3 is 4V, and the module can automatically confirm the position and automatically assign the CAN bus ID to 3. The same goes for the remaining modules.
[0064] The above are only specific embodiments of the present invention, but the technical features of the present invention are not limited thereto. Any simple changes, equivalent replacements or modifications made based on the present invention to achieve basically the same technical effects are all included in the protection scope of the present invention.
Claims
1. A circuit for automatically determining ID in CAN communication, characterized in that: include CAN bus; and a plurality of modules, wherein the modules are connected to the CAN bus; Each of the modules includes an ADC chip, a DAC chip, a DCI pin connected to the ADC chip, and a DCO pin connected to the DAC chip, the DCI pin is connected to a resistor R46, the DCO pin is connected to a resistor R49, the ADC chip is used to detect the voltage of the DCI pin, and the DAC chip is used to generate a target voltage and assign it to the DCO pin; When two adjacent modules are connected, the DCO pin of the previous module is connected to the DCI pin of the next module, and the voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module. The position of the module is determined along the CAN bus, and the module automatically assigns an ID.
2. A circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The voltage values of the DCI pins of two adjacent modules decrease in an arithmetic progression.
3. A circuit for automatically determining ID by CAN communication according to claim 2, characterized in that: The decreasing difference of the arithmetic progression is the ratio of the supply voltage to the total number of modules.
4. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (supply voltage-Vout) / (R46+R49)=(Vin-Vout) / R49.
5. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: Each of the modules includes an MCU and an IIC bus, and the MCU is connected to the ADC chip and the DAC chip via the IIC bus.
6. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The VIN+ pin of the ADC chip is connected to a resistor R47, the resistor R47 is connected to the DCI pin, the capacitor C31 and the resistor R46, the capacitor C31 is connected to CAN_GND, and the resistor R46 is connected to CAN_5V.
7. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The VIN- pin of the ADC chip is connected to the capacitor C33, the capacitor C32 and CAN_GND, and the VDD pin of the ADC chip is connected to the capacitor C33, the capacitor C32 and CAN_5V.
8. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The SCL pin and the SDA pin of the DAC chip are connected to the SCL pin and the SDA pin of the ADC chip respectively.
9. The circuit for automatically determining ID by CAN communication according to claim 1, characterized in that: The VOUT pin of the DAC chip is connected to the resistor R49 and the capacitor C37, the resistor R49 is connected to the DCO pin, the VSS pin of the DAC chip is connected to the capacitor C37, CAN_GND, capacitor C38 and capacitor C39, and the VDD pin of the DAC chip is connected to the capacitor C38, the capacitor C39 and CAN_5V.
10. A method for allocating a circuit for automatically determining ID in CAN communication according to any one of claims 1 to 9, characterized in that The following steps are involved: S1, selecting a module at a certain position in the circuit, the DCI pin of the module corresponding to the position is not connected to the DCO pin of other modules, detecting the voltage of the DCI pin through the ADC chip of the module, and assigning the power supply voltage of the circuit to the DCI pin; S2, the ADC chip of the module detects that the voltage of the DCI pin is the power supply voltage, and the module automatically assigns an ID of 1; S3, determining the voltage values of the DCI pins of two adjacent modules, the voltage values decreasing in an arithmetic progression, and the difference of the decreasing arithmetic progression is the ratio of the power supply voltage to the total number of modules; S4, connect the next module, the DCO pin of the previous module is connected to the DCI pin of the next module, the voltage of the DCI pin of the next module is equal to the target voltage of the DCO pin of the previous module, the target voltage Vout generated by the DAC chip of the previous module and the voltage Vin of the DCI pin of the next module satisfy the formula: (power supply voltage - Vout) / (R46+R49)=(Vin-Vout) / R49, determine the position of the next module on the CAN bus, and automatically assign an ID; S5. The remaining modules are positioned on the CAN bus in the same manner and IDs are automatically assigned.
