CN112929251B - CAN-based slave station data refreshing method, device and system - Google Patents

CAN-based slave station data refreshing method, device and system Download PDF

Info

Publication number
CN112929251B
CN112929251B CN202110174253.0A CN202110174253A CN112929251B CN 112929251 B CN112929251 B CN 112929251B CN 202110174253 A CN202110174253 A CN 202110174253A CN 112929251 B CN112929251 B CN 112929251B
Authority
CN
China
Prior art keywords
station
slave
data
slave station
stations
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.)
Active
Application number
CN202110174253.0A
Other languages
Chinese (zh)
Other versions
CN112929251A (en
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.)
Shenzhen Samkoon Technology Corp ltd
Original Assignee
Shenzhen Samkoon Technology Corp ltd
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 Shenzhen Samkoon Technology Corp ltd filed Critical Shenzhen Samkoon Technology Corp ltd
Priority to CN202110174253.0A priority Critical patent/CN112929251B/en
Publication of CN112929251A publication Critical patent/CN112929251A/en
Application granted granted Critical
Publication of CN112929251B publication Critical patent/CN112929251B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The application discloses a slave station data refreshing method, a slave station data refreshing device and a slave station data refreshing system based on a CAN, wherein the slave station data refreshing method based on the CAN comprises the following steps: step S100: assigning a station number of the slave station; step S110: configuring and sending a first communication frame according to the station number of the distributed slave station and an RS485 communication protocol; step S120: starting a data updating function of a plurality of slave stations according to the first communication frame; step S130: receiving data updated by the plurality of slave stations according to the data updating function within preset time; step S140: after the preset time, jumping to the step S100. The slave station data refreshing method based on the CAN solves the problem that the slave station consumes time for response due to communication overtime, and improves the bus utilization rate.

Description

CAN-based slave station data refreshing method, device and system
Technical Field
The present application relates to the field of CAN bus technologies, and in particular, to a slave station data refreshing method, device and system based on a CAN.
Background
In the related art, the CAN is widely used in the automobile industry and the industrial control industry, because the CAN allow a plurality of master stations and a plurality of slave stations to mutually transmit on a bus, any station on the bus is allowed to transmit a request, any station CAN receive a corresponding message, and if the message CAN pass through an ID filter of a certain station, the message CAN be processed by software; otherwise it will be discarded by the station. After the message of the sending request is received, more than one station possibly needs to occupy the bus to send the message, the arbitration of the second characteristic of the CAN is embodied, if a plurality of stations intend to send the message, the ID part in the message determines the sending sequence, and the specific logic is realized by hardware without software intervention. However, in order to standardize the rhythm of the bus, most of the usages of the CAN are mainly based on question answering, and in the case of ordinary question answering, the overtime is an unavoidable phenomenon that the utilization rate of the bus is delayed, when data transmission is carried out, the condition that a part of stations fall off to cause communication overtime exists, then the applied stations send data requests again, the rest of the stations on the bus reply once again, and the fallen stations trigger overtime again, so that the comprehensive utilization rate of the CAN bus is not high, in other words, the time percentage occupied by the transmitted data is not high.
Disclosure of Invention
The present application is directed to solving at least one of the problems in the prior art. Therefore, the application provides a slave station data refreshing method, device, system and computer readable storage medium based on CAN, which CAN continue to perform data updating without continuing to wait for the responses of the remaining slave stations when the responses of the slave stations are overtime, solve the problem that the slave station communication is overtime and consumes time to wait for the responses, and improve the utilization rate of a CAN bus.
The CAN-based slave station data refreshing method according to the embodiment of the first aspect of the application comprises the following steps:
step S100: assigning a station number of the slave station;
step S110: configuring and sending a first communication frame according to the station number of the distributed slave station and an RS485 communication protocol;
step S120: starting a data updating function of a plurality of slave stations according to the first communication frame;
step S130: receiving data updated by a plurality of slave stations according to a data updating function in a preset time;
step S140: after the preset time, jumping to the step S100.
The CAN-based slave station data refreshing method has at least the following beneficial effects: firstly, station numbers of the slave stations are distributed, then, a first communication frame is configured and sent in combination with an RS485 communication protocol, a data updating function of the slave stations is started, the host receives data updated by the slave stations according to the data updating function, at the moment, if the time for receiving the data updated by the slave stations exceeds preset time, the station numbers of the slave stations are distributed again, the step that when the response of the slave stations is overtime is abandoned, the host waits for the response, the step that the slave stations with overtime response are not waited for, the station numbers are distributed to the slave stations again, the data updated by the slave stations which have responded are received again, and the data are updated quickly. Therefore, the slave station data refreshing method based on the CAN CAN continue to perform data updating without continuing to wait for the rest of slave station responses when the slave station responses are overtime, solve the problem that the slave station communication is overtime and consumes time to wait for the responses, and improve the bus utilization rate.
According to some embodiments of the application, the assigning of the station number of the secondary station comprises:
configuring and sending a second communication frame according to an RS485 communication protocol; the second communication frame comprises a station number of the first slave station;
and allocating station numbers to the plurality of slave stations according to the station number of the first slave station.
According to some embodiments of the application, said assigning station numbers to a plurality of said secondary stations in dependence on the station number of said first secondary station comprises:
transmitting station numbers of the first slave station in sequence;
and according to the transmission sequence, sequentially allocating station numbers to the plurality of slave stations.
According to some embodiments of the present application, the first communication frame includes information to initiate a data update;
the starting of the data updating function of the plurality of slave stations according to the first communication frame comprises the following steps:
starting data updating functions of a plurality of slave stations according to the information for starting data updating;
and circularly updating the data of a plurality of the secondary stations.
According to some embodiments of the application, after the assigning the station number of the slave station, further comprising:
receiving parameter information sent by a plurality of slave stations corresponding to station numbers;
configuring configuration frames of a plurality of slave stations according to a CAN communication protocol and the parameter information;
and transmitting configuration frames of a plurality of slave stations according to the CAN communication protocol.
According to some embodiments of the application, the parameter information comprises station numbers of a plurality of the secondary stations which have been allocated;
the receiving, within a preset time, data updated by the slave stations according to the data updating function includes:
receiving a plurality of updated data transmitted by the slave station onto the CAN bus;
counting the station number of each slave station on the CAN bus according to a plurality of updated data sent to the CAN bus by the slave station;
matching the counted station number of the slave station with the station number of the slave station which is already allocated one by one;
and if the station number of each slave station appears once in the preset time, clearing the station number of each slave station counted.
According to some embodiments of the present application, the CAN-based slave station data refreshing method of the first aspect of the present application further includes:
if the station number of at least one slave station does not appear in the preset time, configuring and sending the second communication frame according to the RS485 communication protocol;
receiving response information sent by the plurality of secondary stations according to the second communication frame; the response information comprises station numbers of a plurality of the slave stations;
acquiring a first maximum station number according to the station numbers of the distributed multiple slave stations;
acquiring a second maximum station number according to the station numbers of the plurality of slave stations in the response message;
if the second maximum station number is consistent with the first maximum station number, sending the first communication frame, starting a data updating function of the plurality of slave stations, and adjusting the communication rhythm of the CAN bus;
and if the second maximum station number is not consistent with the first maximum station number, reconfiguring and sending the second communication frame.
The CAN-based slave station data refreshing device according to the embodiment of the second aspect of the application comprises:
the first distribution module is used for distributing station numbers of the slave stations;
the configuration sending module is used for configuring and sending a first communication frame according to the station number of the distribution slave station and an RS485 communication protocol;
the data updating module is used for starting data updating functions of the slave stations according to the first communication frame;
the receiving module is used for receiving the data updated by the plurality of slave stations according to the data updating function within preset time;
and the second distribution module is used for executing the function of the first distribution module after the preset time.
According to the CAN-based slave station data refreshing device, at least the following beneficial effects are achieved: the slave station data refreshing device based on the CAN in the embodiment of the present application CAN execute the slave station data refreshing method based on the CAN in the embodiment of the first aspect. Firstly, station numbers of slave stations are distributed, then, a first communication frame is configured and sent in combination with an RS485 communication protocol, a data updating function of the slave stations is started, and a host receives data updated by the slave stations according to the data updating function. Therefore, the slave station data refreshing device based on the CAN in the embodiment of the present application CAN execute the slave station data refreshing method based on the CAN in the first aspect of the embodiment, and the method CAN continue to execute data updating without continuing to wait for the responses of the remaining slave stations when the responses of the slave stations are overtime, thereby solving the problem that the slave station communication is overtime and consumes time to wait for the responses, and improving the bus utilization rate.
A CAN-based slave station data refresh system according to an embodiment of the third aspect of the present application includes:
at least one memory;
at least one processor;
at least one program;
the programs are stored in the memory, and the processor executes at least one of the programs to implement the CAN-based slave station data refresh method as embodied in the first aspect of the present application.
According to a computer-readable storage medium of an embodiment of the fourth aspect of the present application, the computer-readable storage medium stores computer-executable instructions for causing a computer to execute the CAN-based slave station data refreshing method as in the embodiment of the first aspect of the present application.
Additional aspects and advantages of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Drawings
The present application is further described with reference to the following figures and examples, in which:
fig. 1 is a schematic flow chart of a CAN-based slave station data refreshing method according to an embodiment of the present application;
fig. 2 is a schematic connection diagram of a CAN bus and an RS485 bus provided in an embodiment of the present application;
fig. 3 is a schematic flow chart of a CAN-based slave station data refreshing method according to another embodiment of the present application;
fig. 4 is a schematic connection diagram of a CAN-based slave data refreshing apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a CAN-based slave station data refreshing system according to an embodiment of the present application.
Reference numerals:
a first allocation module 100, a configuration sending module 110, a data updating module 120, a receiving module 130, a second allocation module 140, a memory 200, a processor 300.
Detailed Description
Reference will now be made in detail to the embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application.
It should be noted that although functional block divisions are provided in the system drawings and logical orders are shown in the flowcharts, in some cases, the steps shown and described may be performed in different orders than the block divisions in the systems or in the flowcharts. The terms etc. in the description and claims and the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
In the description of the present application, the meaning of a plurality is one or more, the meaning of a plurality is two or more, and the above, below, exceeding, etc. are understood as excluding the present number, and the above, below, within, etc. are understood as including the present number. If there is a description of first and second for the purpose of distinguishing technical features only, this is not to be understood as indicating or implying a relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of technical features indicated.
In the description of the present application, unless otherwise specifically limited, terms such as set, installed, connected and the like should be understood broadly, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present application in combination with the specific contents of the technical solutions.
In the description of the present application, reference to the description of the terms "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
CAN and RS485 are briefly described below.
Can (control Area network): a serial bus communication mode is characterized in that two lines are physically arranged, data are transmitted through a group of differential signals, and all stations on a bus can receive and analyze the transmitted data. With the help of the ID filter, the data CAN be filtered by hardware, a plurality of stations on the bus are allowed to simultaneously transmit data, queuing transmission is realized through the arbitration function of the CAN, and data transmission CAN be completed without software intervention.
ID filter: in a data frame of the CAN, a part of data bits are called ID; wherein, the standard frame is 11 bits, and the extended frame is 29 bits. The ID filter is used for screening IDs which do not meet the conditions, so that the pressure of software is relieved, and only data frames which can pass through the ID filter are processed.
RS 485: a serial bus communication mode is physically two lines, data are transmitted by a group of differential signals, and the serial bus communication mode is different from a CAN (controller area network) mode in that an ID (identity) filter is not arranged, so that the serial bus communication mode is a simpler serial communication mode.
A CAN-based slave data refresh method according to an embodiment of the present application is described below with reference to fig. 1.
As shown in fig. 1, the slave station data refreshing method based on CAN includes:
step S100: assigning a station number of the slave station;
step S110: configuring and sending a first communication frame according to the station number of the distributed slave station and an RS485 communication protocol;
step S120: starting a data updating function of a plurality of slave stations according to the first communication frame;
step S130: receiving data updated by a plurality of slave stations according to the data updating function within preset time;
step S140: after a preset time, it jumps to step S100.
Firstly, station numbers of slave stations are distributed, then, a first communication frame is configured and sent in combination with an RS485 communication protocol, a data updating function of the slave stations is started, and a host receives data updated by the slave stations according to the data updating function. Therefore, the slave station data refreshing method based on the CAN CAN continue to perform data updating without continuing to wait for the rest of slave station responses when the slave station responses are overtime, solve the problem that the slave station communication is overtime and consumes time to wait for the responses, and improve the bus utilization rate.
It is understood that assigning the station number of the slave station includes:
configuring and sending a second communication frame according to an RS485 communication protocol; the second communication frame comprises a station number of the first slave station;
according to the station number of the first slave station, station numbers are allocated to the plurality of slave stations.
RS485 sends the second communication frame, and the structure user of second communication frame can be according to the needs self-defining, nimble flexible, for example, the structure of second communication frame is "function code + data + check-up content".
It is understood that assigning station numbers to a plurality of slave stations based on the station number of the first slave station comprises:
transmitting station numbers of the first slave station in sequence;
according to the order of transmission, station numbers are sequentially assigned to a plurality of slave stations.
It will be appreciated that the assignment of station numbers to the plurality of slave stations in turn, according to the order of delivery, includes:
adding one to the station number of the first slave station every time the first slave station passes through;
and recording the station number of each slave station.
It is understood that, as shown in fig. 2, station numbers are assigned to the slave stations on all connections by RS485, and information of the respective slave stations is recorded. Through the simple application of RS485, the CAN CAN be rapidly assisted to distribute station numbers of the slave stations.
As shown in fig. 2, RS485 is connected end to end without using a bus connection. Therefore, the last slave station that has successfully communicated will send its own slave information and will pass through all the slave stations in front, and all the stations on the bus will know that there are a total of several slave stations on the CAN. The slave station information comprises the type, the station number, the software and hardware version number and the like of the slave station.
It can be understood that, as shown in fig. 2, the specific station number assignment process is as follows:
when the slave station 1 receives a second communication frame of the station number allocated by the master station through RS485 communication, firstly, the slave station 1 receives the station number of the first slave station sent by the host through an RS485 data line, and takes the station number of the first slave station as the station number of the slave station; then, the slave station 1 returns the information corresponding to the slave station 1 through another RS485 data line, and adds one to the station number of the first slave station contained in the second communication frame; then, the slave 1 transmits the station number of the first slave added with one to the slave 2 as the station number of the slave 2. Similarly, the slave station 2 receives the slave station number sent by the slave station 1 through one RS485 data line, the slave station 2 takes the received slave station number as the station number of the slave station, and sends self information back through another RS485 data line, the self information sent back by the slave station 2 passes through the slave station 1, the slave station 1 stores the information of the slave station 2 and then continuously sends back the information of the slave station 2 to the host, and the slave station 1 only stores the information of the slave station 2 and does not perform other processing. For example, the master sends the second communication frame with the station number of 001 of the first slave station to the slave station 1, the slave station 1 takes 001 as the station number of the slave station, transmits the slave station information of the slave station back to the master, and simultaneously adds 1 to 001 to become 002 to be sent to the slave station 2; the slave station 2 receives the 002 as its own station number and transmits its own information back to the slave station 1, and the slave station 1 stores the information of the slave station 2 and the slave station 1 also transmits the information of the slave station 2 back to the host. And so on, allocating station numbers to the slave station N.
It is to be understood that the second communication frame further includes an ID, and part of the data in the ID is the slave station number, and the transmission of the second communication frame through the RS485 can set the ID of each slave station. Specifically, when the slave station receives the second communication frame and the ID of the second communication frame is inconsistent with the setting of the ID filter of the CAN of the current slave station, the ID filter of the CAN of the current slave station is reset, so that the ID in the ID filter of the CAN of the current slave station is consistent with the ID of the second communication frame, otherwise, the setting of the ID filter is skipped, and the communication frame returning and the post-transmitting work are continued.
It is understood that the configuration frames of the plurality of slave stations are configured and transmitted according to the CAN communication protocol and the parameter information. Specifically, the slave stations are subjected to preliminary operation parameter configuration through the CAN, and the slave stations adopt a question-and-answer mode, so that the rhythm of the CAN bus is standardized. For example, the slave station 1 is a temperature measuring module with a 4-channel, and supports temperature sensors such as Pt100, Ni120, K-type, T-type thermocouples, and the like. At this time, if the configured module operation information stored in the host is performed in the Pt100 test mode, the host may send the communication configuration to the module of the slave station 1 through the CAN, and the content of the configuration frame is the information of the operating mode of the 4-way channel, the filtering times, the compensation coefficient, and the like. When the slave station 1 successfully acquires the content of the frame and the calculation and verification result shows that the data is not in disorder, a correct response frame is returned to the host. Although this process takes place on one bus, in other words, all slave stations on the bus have the condition to receive the frame, since the configuration is a one-to-one process, the information of the configuration frame is meaningless for other slave stations by using a one-to-one method.
It is to be understood that, as shown in fig. 1, the first communication frame includes information to initiate data update;
starting a data update function of a plurality of slave stations according to a first communication frame, comprising:
starting data updating functions of a plurality of slave stations according to the information for starting data updating;
and circularly updating the data of the plurality of secondary stations.
It can be understood that the host sends a first communication frame to all the slave stations through RS485, the purpose of the first communication frame is to start the data updating function of the slave stations, and the content of the first communication frame may be simply "data updating function code + start/close + check".
It is understood that after the station number of the slave station is assigned, the method further comprises:
receiving parameter information sent by a plurality of slave stations corresponding to station numbers;
configuring configuration frames of a plurality of slave stations according to the CAN communication protocol and the parameter information;
according to the CAN communication protocol, configuration frames of a plurality of slave stations are transmitted.
According to the requirement, the CAN is used for carrying out preliminary operation parameter configuration, and the CAN is communicated with each slave station in a question-and-answer mode.
It is to be understood that, as shown in fig. 1, the parameter information includes station numbers of a plurality of slave stations that have been assigned;
receiving updated data from a plurality of secondary stations, comprising:
receiving a plurality of updated data transmitted from the slave station to the CAN bus;
counting station numbers of each slave station on the CAN bus;
matching the station numbers of the counted slave stations with the station numbers of the distributed slave stations one by one;
and if the station numbers of the slave stations appear once, clearing the station numbers of the counted slave stations.
It will be appreciated that in the present application, all the secondary stations are provided with two ID filters, a first ID filter and a second ID filter respectively. An ID filter of the slave station is equivalent to a condition for screening messages, and only messages meeting specific conditions are left. The first ID filter is set to receive messages of the host, and the second ID filter is set to receive messages of other slave stations.
It CAN be understood that, according to the previous method of assigning the station numbers of the slave stations, each slave station already knows the station number and the number of the slave stations on the CAN bus, so that when the slave station receives the first communication frame of the host informing the start of data update, the latest data updated by the slave station is sent to the CAN bus, and the updated data of the slave station includes an ID containing the station number of the slave station, meanwhile, the second ID filter starts to count the station numbers of the slave stations in all the IDs appearing on the CAN bus, and matches the counted station number of the slave station with the station number of the slave station already stored, if the counted station numbers of all the slave stations appear once, it indicates that all the slave stations successfully respond once, and then the slave station clears the count record.
It can be understood that after all the slave stations successfully make a response, the statistical records of the slave stations may not be cleared, and this scheme may be implemented by modifying the trigger mechanism, for example, in the first step, all the ID records are set to 1; secondly, triggering and sending the ID after the ID is completely recorded; thirdly, clearing the ID; and fourthly, recording the ID until all the IDs appear.
It is understood that after the preset time, jumping to step S100 includes:
and if the time for receiving the updated data of the plurality of slave stations exceeds the preset time, jumping to step S100 to reallocate the station numbers of the slave stations. Specifically, the preset time is the sum of the time required by all the slave stations to transmit data. By reassigning the station number of the slave station, the number of slave station IDs obtained from the station number of the reassigned slave station is used as a comparison standard of the statistical IDs after starting the data update function of the slave station, and thus the waiting time can be eliminated. And data updating is continued according to the station numbers of the redistributed slave stations, so that the utilization rate of the CAN bus is effectively improved.
It CAN be understood that, as shown in fig. 3, the CAN-based slave station data refreshing method according to the embodiment of the present application further includes:
if the station number of at least one slave station does not appear in the preset time, configuring and sending a second communication frame according to an RS485 communication protocol;
receiving response information sent by the plurality of slave stations according to the second communication frame; the response information comprises station numbers of a plurality of slave stations;
acquiring a first maximum station number according to the station numbers of the distributed multiple slave stations;
acquiring a second maximum station number according to the station numbers of the plurality of slave stations in the response message;
if the second maximum station number is consistent with the first maximum station number, sending a first communication frame, starting a data updating function of a plurality of slave stations, and adjusting the communication rhythm of the CAN bus;
if the second maximum station number is not consistent with the first maximum station number, the second communication frame is reconfigured and sent.
It can be understood that the station numbers of the plurality of slave stations are obtained according to the station numbers of the slave stations in the response message; and obtaining a second maximum station number according to the station numbers of the plurality of slave stations. According to the second maximum station number, the second maximum station number is compared with the first maximum station number, the host CAN know whether the slave station restores to be on-line or not, and when the slave station restores to be on-line, the host CAN resend the first communication frame and adjust the communication rhythm of the CAN bus; the first communication frame comprises a message for starting a data updating function. After the slave station is disconnected, the slave station CAN automatically stop uploading data to the CAN bus, so that the host needs to retransmit the first communication frame to start the data updating function of the disconnected slave station.
A CAN-based slave data refresh apparatus according to an embodiment of the present application is described below with reference to fig. 4.
As shown in fig. 4, the CAN-based slave station data refresh apparatus includes:
a first assigning module 100 for assigning station numbers of slave stations;
a configuration sending module 110, configured to configure and send a first communication frame according to the station number of the assigned slave station and the RS485 communication protocol;
a data updating module 120, configured to start a data updating function of the multiple slave stations according to the first communication frame;
a receiving module 130, configured to receive, within a preset time, data updated by a plurality of slave stations according to the data updating function;
and a second distribution module 140 for performing the function of the first distribution module after a preset time.
The slave station data refreshing device based on the CAN CAN execute the slave station data refreshing method based on the CAN. Firstly, station numbers of slave stations are distributed, then, a first communication frame is configured and sent in combination with an RS485 communication protocol, a data updating function of the slave stations is started, and a host receives data updated by the slave stations according to the data updating function. Therefore, the slave station data refreshing device based on the CAN according to the embodiment of the present application CAN execute the slave station data refreshing method based on the CAN according to the embodiment of the first aspect, and the method CAN continue to execute data updating without continuing to wait for the remaining slave station responses when the slave station responses are overtime, thereby solving the problem that the slave station communication is overtime and consumes time to wait for the responses, and improving the bus utilization rate.
A CAN-based slave data refresh system according to an embodiment of the present application is described below with reference to fig. 5.
As shown in fig. 5, the CAN-based slave station data refreshing system according to the embodiment of the present application may be any type of smart terminal, such as a mobile phone, a tablet computer, a personal computer, and the like.
It is understood that the CAN-based slave data refresh system includes:
at least one memory 200;
at least one processor 300;
at least one program;
programs are stored in the memory 200 and the processor 300 executes at least one program to implement the CAN-based slave data refresh method described above. Fig. 5 illustrates an example of a processor 300.
The processor 300 and the memory 200 may be connected by a bus or other means, and fig. 5 illustrates a connection by a bus as an example.
The memory 200 is a non-transitory computer readable storage medium, and CAN be used to store non-transitory software programs, non-transitory computer executable programs, and signals, such as program instructions/signals corresponding to the CAN-based slave data refresh system in the embodiments of the present application. The processor 300 executes various functional applications and data processing, namely, a CAN-based slave station data refreshing method according to the embodiment of the present application, by executing non-transitory software programs, instructions and signals stored in the memory 200.
The memory 200 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area CAN store relevant data of the CAN-based slave station data refreshing method and the like in the embodiment of the method. Further, the memory 200 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 200 optionally includes memory located remotely from processor 300, and these remote memories may be connected to the campus-based distress signal detection system via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more signals are stored in the memory 200 and, when executed by the one or more processors 300, perform the CAN-based slave data refresh method in any of the method embodiments of the present application. For example, method steps S100 to S140 in fig. 1 are performed.
A computer-readable storage medium according to an embodiment of the present application is described below with reference to fig. 5.
As shown in fig. 5, a computer-readable storage medium stores computer-executable instructions that, when executed by one or more processors 300, for example, by one of processors 300 in fig. 5, cause the one or more processors 300 to perform the CAN-based slave data refresh method in the above-described method embodiment. For example, the method steps S100 to S140 in fig. 1 described above are performed.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
From the above description of embodiments, those of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media and communication media. The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. In addition, communication media typically embodies computer-readable signals, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as is well known to those skilled in the art.
The embodiments of the present application have been described in detail with reference to the drawings, but the present application is not limited to the embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the gist of the present application. Furthermore, the embodiments and features of the embodiments of the present application may be combined with each other without conflict.

Claims (8)

1. The CAN-based slave station data refreshing method is characterized by comprising the following steps:
step S100: allocating station numbers of the slave stations;
step S110: configuring and sending a first communication frame according to the station number of the distributed slave station and an RS485 communication protocol;
step S120: starting a data updating function of a plurality of slave stations according to the first communication frame;
step S130: receiving data updated by the plurality of slave stations according to the data updating function within preset time;
step S140: after the preset time, jumping to the step S100;
after the station number of the slave station is allocated, the method further comprises the following steps:
receiving parameter information sent by a plurality of slave stations corresponding to station numbers;
configuring configuration frames of a plurality of slave stations according to a CAN communication protocol and the parameter information;
transmitting configuration frames of a plurality of slave stations according to the CAN communication protocol;
the parameter information includes station numbers of a plurality of the slave stations which have been allocated;
the receiving, within a preset time, data updated by the slave stations according to the data updating function includes:
receiving a plurality of updated data transmitted by the slave station onto the CAN bus;
counting the station number of each slave station on the CAN bus according to a plurality of updated data sent to the CAN bus by the slave station;
matching the counted station number of the slave station with the station number of the slave station which is already allocated one by one;
and if the station number of each slave station appears once in the preset time, clearing the station number of each slave station counted.
2. The CAN-based slave data refresh method of claim 1, wherein said assigning a station number of a slave comprises:
configuring and sending a second communication frame according to an RS485 communication protocol; the second communication frame comprises a station number of the first slave station;
and allocating station numbers to the plurality of slave stations according to the station number of the first slave station.
3. The CAN-based slave station data refresh method of claim 2, wherein said assigning a station number to a plurality of said slave stations according to a station number of said first slave station comprises:
transmitting station numbers of the first slave station in sequence;
and according to the transmission sequence, sequentially allocating station numbers to the plurality of slave stations.
4. The CAN-based slave data refresh method of claim 1, wherein the first communication frame includes information to initiate a data update;
the starting of the data updating function of the plurality of slave stations according to the first communication frame comprises the following steps:
starting data updating functions of a plurality of slave stations according to the information for starting data updating;
and circularly updating the data of a plurality of the secondary stations.
5. The CAN-based slave data refresh method of claim 2, further comprising:
if the station number of at least one slave station does not appear in the preset time, configuring and sending the second communication frame according to the RS485 communication protocol;
receiving response information sent by the plurality of secondary stations according to the second communication frame; the response information comprises station numbers of a plurality of the slave stations;
acquiring a first maximum station number according to the station numbers of the distributed multiple slave stations;
acquiring a second maximum station number according to the station numbers of the plurality of slave stations in the response message;
if the second maximum station number is consistent with the first maximum station number, sending the first communication frame, starting a data updating function of the plurality of slave stations, and adjusting the communication rhythm of the CAN bus;
and if the second maximum station number is not consistent with the first maximum station number, reconfiguring and sending the second communication frame.
6. Slave station data refreshing device based on CAN, its characterized in that includes:
the first distribution module is used for distributing station numbers of the slave stations;
the configuration sending module is used for configuring and sending a first communication frame according to the station number of the distribution slave station and an RS485 communication protocol; the system is also used for receiving parameter information sent by a plurality of secondary stations corresponding to station numbers; the CAN communication protocol is used for sending parameter information to the slave station; the CAN communication protocol is used for transmitting configuration frames of a plurality of slave stations; further for the parameter information to include station numbers of a plurality of the secondary stations that have been allocated;
the data updating module is used for starting data updating functions of the slave stations according to the first communication frame;
the receiving module is used for receiving the data updated by the plurality of slave stations according to the data updating function within a preset time;
the receiving, within a preset time, data updated by the slave stations according to the data updating function includes:
receiving a plurality of updated data transmitted by the slave station onto the CAN bus;
counting the station number of each slave station on the CAN bus according to a plurality of updated data sent to the CAN bus by the slave station;
matching the counted station number of the slave station with the station number of the slave station which is already allocated one by one;
if the station number of each slave station appears once in the preset time, clearing the station number of each slave station counted;
and the second distribution module is used for executing the function of the first distribution module after the preset time.
7. Slave station data refreshing system based on CAN, characterized by including:
at least one memory;
at least one processor;
at least one program;
the programs being stored in the memory, the processor executing at least one of the programs to implement the CAN-based slave data refresh method of any of claims 1 to 5.
8. A computer-readable storage medium having stored thereon computer-executable instructions for causing a computer to perform the CAN-based slave data refresh method of any one of claims 1 to 5.
CN202110174253.0A 2021-02-07 2021-02-07 CAN-based slave station data refreshing method, device and system Active CN112929251B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110174253.0A CN112929251B (en) 2021-02-07 2021-02-07 CAN-based slave station data refreshing method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110174253.0A CN112929251B (en) 2021-02-07 2021-02-07 CAN-based slave station data refreshing method, device and system

Publications (2)

Publication Number Publication Date
CN112929251A CN112929251A (en) 2021-06-08
CN112929251B true CN112929251B (en) 2022-09-09

Family

ID=76171269

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110174253.0A Active CN112929251B (en) 2021-02-07 2021-02-07 CAN-based slave station data refreshing method, device and system

Country Status (1)

Country Link
CN (1) CN112929251B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114389911A (en) * 2022-01-13 2022-04-22 上海步科自动化股份有限公司 Parameter setting method, device, terminal and storage medium
CN114500151B (en) * 2022-01-19 2024-01-30 南京科远智慧科技集团股份有限公司 Motion control communication system and communication method based on CAN bus

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976074A (en) * 2010-11-03 2011-02-16 浙江工业大学 Industrial control system based on field bus and control network
CN105450489A (en) * 2015-12-02 2016-03-30 大连理工计算机控制工程有限公司 HEBus efficient fieldbus system for preferably realizing shortest message in output and communication method
CN105743757A (en) * 2016-01-27 2016-07-06 南京埃斯顿自动化股份有限公司 Free networking method of RS485 communication terminal
WO2017113080A1 (en) * 2015-12-29 2017-07-06 深圳配天智能技术研究院有限公司 Slave station firmware update method, system, master station and slave station
CN111030906A (en) * 2019-12-12 2020-04-17 山东鼎维数字技术有限公司 Method for automatically addressing slave station address based on RS485 bus cascade

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7266608B2 (en) * 2000-01-20 2007-09-04 Mitsubishi Denki Kabushiki Kaisha System for punctually sending and receiving serial data and a method for sending and receiving the serial data

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101976074A (en) * 2010-11-03 2011-02-16 浙江工业大学 Industrial control system based on field bus and control network
CN105450489A (en) * 2015-12-02 2016-03-30 大连理工计算机控制工程有限公司 HEBus efficient fieldbus system for preferably realizing shortest message in output and communication method
WO2017113080A1 (en) * 2015-12-29 2017-07-06 深圳配天智能技术研究院有限公司 Slave station firmware update method, system, master station and slave station
CN105743757A (en) * 2016-01-27 2016-07-06 南京埃斯顿自动化股份有限公司 Free networking method of RS485 communication terminal
CN111030906A (en) * 2019-12-12 2020-04-17 山东鼎维数字技术有限公司 Method for automatically addressing slave station address based on RS485 bus cascade

Also Published As

Publication number Publication date
CN112929251A (en) 2021-06-08

Similar Documents

Publication Publication Date Title
CN112929251B (en) CAN-based slave station data refreshing method, device and system
EP2523522B1 (en) Contention media access control for telecommunications
CN110808948B (en) Remote procedure calling method, device and system
CN114553373A (en) Data transmission method, device, equipment and storage medium
CN111064788B (en) Signal transmission method, robot, and computer-readable storage medium
CN112437454A (en) Data transmission method and device, storage medium and electronic device
CN108684030B (en) Method and device for detecting network identification conflict
CN107483310B (en) Method and system for networking between terminal and forwarding node
CN107231284B (en) Message sending method and terminal equipment
CN107171915B (en) Communication protocol changing method and device
CN114087727B (en) Wireless pairing method, device and system, upper and lower computer nodes and air conditioning unit
CN105812203B (en) A kind of request message processing method and equipment
US11803494B2 (en) Data communication method, master device and system
CN116185649A (en) Storage control method, storage controller, storage chip, network card, and readable medium
CN111475439A (en) Communication control method and device based on asynchronous transmission protocol and electronic equipment
CN112788778B (en) Data sending method and device
CN117544596B (en) Automatic address allocation method for telemetry system, telemetry system and storage medium
CN111698342A (en) Temperature controller communication address allocation method and system
CN113853011A (en) Data interaction method, gateway, data interaction device and data interaction system
CN111431780B (en) Communication method and device of 1553B bus system
US9847919B2 (en) Data network device discovery optimization to reduce data transfer volume
CN111935199A (en) Vehicle-mounted software version information synchronization method, device and system and vehicle
CN110944059B (en) Communication method and device
CN109117340A (en) A kind of mobile terminal and its monitoring method, the storage medium of interprocess communication
CN115297178B (en) Message sending method and device, storage medium and electronic device

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
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Method, device, and system for refreshing data from slave stations based on CAN

Granted publication date: 20220909

Pledgee: Shenzhen Rural Commercial Bank Co.,Ltd. Shenzhen Shantou Special Cooperation Zone Branch

Pledgor: SHENZHEN SAMKOON TECHNOLOGY Corp.,Ltd.

Registration number: Y2024980009185