CN-121984650-A - Long-distance CAN (controller area network) fiber conversion device
Abstract
The invention discloses a long-distance CAN fiber conversion device, and relates to the technical field of bus communication. The self-adaptive method comprises the steps of detecting the communication baud rate of a local CAN bus and measuring the optical fiber time delay to determine the self-defined ACK bit position, detecting the starting time of a standard ACK bit in a frame by a standard ACK bit time detection module, shielding standard ACK response signals from other devices on the local CAN bus when a data frame or a remote frame is forwarded by a local ACK shielding module, detecting whether an effective ACK response exists at an opposite end or not in a monitoring period from the starting time of the standard ACK bit to the starting time of the self-defined ACK bit by an opposite end ACK monitoring module, outputting a corresponding level signal to the local CAN bus in the self-defined ACK bit time according to the detection result of the opposite end ACK monitoring module, and configuring whether the standard ACK response signals generated by the device are transmitted to the local CAN bus or not by the local ACK feedback module.
Inventors
- Xie Zhongluan
- WANG WEI
- CHEN ZHIZHAO
- CHEN GUOQIANG
- MAO WEIXIN
Assignees
- 珞微科技(杭州)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260119
Claims (10)
- 1. A long-distance CAN-to-fiber device, comprising: the parameter self-adaptive module is used for detecting the communication baud rate of the local CAN bus and determining the position of the self-defined ACK bit by measuring the transmission delay of the optical fiber link; The standard ACK bit time detection module is used for detecting the starting time of the standard ACK bit in a data frame or a remote frame when equipment on the CAN bus of the local end sends the frame; The local ACK shielding module is used for shielding standard ACK response signals from other devices on the CAN bus of the local end when forwarding the data frame or the remote frame to the opposite end; the opposite end ACK monitoring module is used for detecting whether an opposite end has a valid ACK response or not in a monitoring period from the starting moment of a standard ACK bit to the starting moment of a self-defined ACK bit; the self-defining ACK module is used for outputting corresponding level signals to the local CAN bus in the self-defining ACK bit period according to the detection result of the opposite end ACK monitoring module; And the local end ACK feedback module is used for configuring whether the standard ACK response signal generated by the device is transmitted to the local end CAN bus.
- 2. The long-range CAN fiber-optic device of claim 1, wherein the custom ACK bit is located in a delimiter bit following a standard ACK bit in a data frame or a remote frame, and any bit in an end-of-frame field of the frame.
- 3. The long-distance CAN fiber optic device of claim 1, wherein the parameter adaptation module is configured to detect a local CAN bus communication baud rate, comprising: responding to the triggering of the baud rate detection button, and controlling the local terminal device to enter a baud rate detection mode; Under the baud rate detection mode, traversing a preset standard CAN baud rate set, and sequentially configuring the communication baud rate of a CAN controller built in a control system into the currently traversed baud rate value; For each configured baud rate value, the CAN controller is controlled to send a test data frame to the local CAN bus at the baud rate; If the test data frame is successfully received by other devices on the CAN bus and the CAN controller detects that an dominant level appears on the CAN bus within the ACK field period of the test data frame, the currently configured baud rate value is successfully matched with the communication baud rate of the CAN bus, and the baud rate value is determined to be the communication baud rate of the local CAN bus.
- 4. The long-distance CAN fiber optic device of claim 1, wherein the parameter adaptation module is further configured to perform fiber optic transmission delay measurement and custom ACK bit determination, comprising: responding to the triggering of the self-defined ACK detection buttons of the local end device and the opposite end device, and controlling the local end device and the opposite end device to cooperatively enter an optical fiber time delay measurement mode; in the optical fiber time delay measurement mode, the local end device is controlled to generate and send a preset measurement code stream to the opposite end device through an optical fiber link; The opposite terminal device is configured to return a preset response code stream to the local terminal device through an optical fiber link after the measurement code stream is identified; recording the sending time of the measurement code stream and the receiving time of the response code stream, and calculating the bidirectional transmission time delay of the optical fiber link according to the time difference between the sending time and the receiving time; and calculating and determining the position of the self-defined ACK bit in the frame based on the bidirectional transmission delay, the bit time corresponding to the determined communication baud rate of the local CAN bus and the frame structure of the data frame or the remote frame.
- 5. The long-distance CAN fiber optic device of claim 1, wherein the standard ACK bit instant detection module is configured to: the CAN controller built in the control system is configured to be in a passive error state; Configuring a general input/output interface of a local end control system into a falling edge triggering interrupt mode and connecting the general input/output interface to a transmitting pin of a CAN controller; when other devices on the CAN bus of the local end send data frames or remote frames and the CAN controller obtains frame information conforming to protocol specifications through a receiving pin of the CAN controller, the CAN controller outputs dominant level as a response signal through a sending pin of the CAN controller; When the universal input/output interface detects the falling edge jump from the recessive level to the dominant level on the connected transmitting pin, an interrupt is triggered, and the moment of the interrupt is determined as the starting moment of the standard ACK bit.
- 6. The long-distance CAN fiber optic device of claim 1, wherein the local ACK shielding module is configured to: The local end control system controls the general input/output interface to output an effective level in a period lasting one bit duration from the starting moment at the starting moment of the standard ACK bit; the general input/output interface is connected to the enabling control end of the hardware gate circuit and is used for controlling the hardware gate circuit in the time period, so that the standard ACK bit signal sent to the opposite end through the optical fiber is forced to be an recessive level.
- 7. The long-distance CAN fiber optic device of claim 1, wherein the peer ACK listening module is configured to: The local end control system controls the general input/output interface to output an effective level in a monitoring period at the starting moment of a standard ACK bit so as to disconnect the analog switch and block the signal return from the optical fiber link; Meanwhile, detecting the signal level of the optical fiber link in a monitoring period by setting another general input/output interface of which the falling edge triggers an interrupt mode; if the dominant level lasting one bit duration is detected through the general input/output interface in the monitoring period, the response of the opposite terminal ACK is judged to be valid.
- 8. The long-distance CAN fiber optic device of claim 1, wherein the custom ACK module is configured to: If the response of the opposite end ACK is judged to be effective, the local end control system controls the general input/output interface to output an implicit level to the local end CAN bus in the self-defined ACK bit period; If the response of the opposite end ACK is invalid, the local end control system controls the general input/output interface to output dominant level to the local end CAN bus in the self-defined ACK bit period, and maintains one bit duration.
- 9. The long-distance CAN fiber optic device of claim 1, wherein the local end ACK feedback module is configured to: The local control system controls the on-off of the analog switch through the general input/output interface; When the general input/output interface outputs an effective level, the analog switch is controlled to be turned on, so that a standard ACK response signal generated by a CAN controller arranged in a control system in a standard ACK bit period is transmitted to a local CAN bus; and when the output of the general input/output interface is invalid, the analog switch is controlled to be turned off so as to block the transmission of the standard ACK response signal to the local CAN bus.
- 10. The long distance CAN fiber optic device of claim 1 further supporting CAN-FD and CAN-XL protocols.
Description
Long-distance CAN (controller area network) fiber conversion device Technical Field The invention relates to the technical field of bus communication, in particular to a long-distance CAN fiber conversion device. Background A Controller Area Network (CAN) bus is widely applied to the industrial field due to high reliability and real-time performance, but transmission based on a cable is limited by signal attenuation, electromagnetic interference and strict bit timing requirements, and a communication distance is difficult to meet remote requirements of hundreds of meters or more particularly at a high speed. The attenuation and interference problems CAN be overcome by adopting optical fiber transmission, however, propagation delay introduced by the optical fiber CAN form challenges for a response mechanism of a CAN protocol core. In the standard CAN protocol, the transmitting node reserves a reply time slot of only one bit in length in the data frame or remote frame and expects the receiving node to pull the bus to a dominant level as an acknowledgement in this window. When the communication distance is extended to hundreds of meters, the round trip delay brought by the optical fiber may exceed the fixed time window, so that the response of the receiving node cannot be returned in time. The sending node will thus decide that the acknowledgement is out of time, consider the transmission to be failed and possibly initiate retransmissions, which not only increases the network load, but also, more importantly, destroys the original real-time feedback characteristics of the protocol, so that the sending node cannot learn the receiving state of the far end in the current frame period. The existing CAN fiber conversion equipment generally only realizes physical layer signal conversion and fails to solve the response failure problem caused by the time delay. Some of the improved schemes attempt to add an additional acknowledgement protocol or an independent acknowledgement frame at the application layer, but this introduces additional communication overhead and delay, fails to maintain the original simplicity and efficiency of the CAN protocol, and fails to realize a true "single intra-frame acknowledgement". Therefore, a new solution is needed to transparently adapt to long-distance optical fiber delay without modifying standard frame structures and existing devices, and ensure that a transmitting node can reliably sense the opposite-end receiving state in a frame. Disclosure of Invention Based on the above-mentioned drawbacks of the prior art, an object of the present invention is to provide a long-distance CAN fiber-optic device, so as to solve the above-mentioned technical problems. In order to achieve the purpose, the invention provides the following technical scheme that the long-distance CAN fiber conversion device comprises: the parameter self-adaptive module is used for detecting the communication baud rate of the local CAN bus and determining the position of the self-defined ACK bit by measuring the transmission delay of the optical fiber link; The standard ACK bit time detection module is used for detecting the starting time of the standard ACK bit in a data frame or a remote frame when equipment on the CAN bus of the local end sends the frame; The local ACK shielding module is used for shielding standard ACK response signals from other devices on the CAN bus of the local end when forwarding the data frame or the remote frame to the opposite end; the opposite end ACK monitoring module is used for detecting whether an opposite end has a valid ACK response or not in a monitoring period from the starting moment of a standard ACK bit to the starting moment of a self-defined ACK bit; the self-defining ACK module is used for outputting corresponding level signals to the local CAN bus in the self-defining ACK bit period according to the detection result of the opposite end ACK monitoring module; And the local end ACK feedback module is used for configuring whether the standard ACK response signal generated by the device is transmitted to the local end CAN bus. The invention is further arranged such that the custom ACK bit is located in a delimiter bit following a standard ACK bit in a data frame or a remote frame, and any bit in an end of frame field of the frame. The invention is further configured to detect a local CAN bus communication baud rate in the parameter adaptive module, including: responding to the triggering of the baud rate detection button, and controlling the local terminal device to enter a baud rate detection mode; Under the baud rate detection mode, traversing a preset standard CAN baud rate set, and sequentially configuring the communication baud rate of a CAN controller built in a control system into the currently traversed baud rate value; For each configured baud rate value, the CAN controller is controlled to send a test data frame to the local CAN bus at the baud rate; If the test data