CN116708590B - Stabilizer control system and method based on CAN bus - Google Patents
Stabilizer control system and method based on CAN bus Download PDFInfo
- Publication number
- CN116708590B CN116708590B CN202310765563.9A CN202310765563A CN116708590B CN 116708590 B CN116708590 B CN 116708590B CN 202310765563 A CN202310765563 A CN 202310765563A CN 116708590 B CN116708590 B CN 116708590B
- Authority
- CN
- China
- Prior art keywords
- data
- stabilizer
- bus
- protocol
- control
- 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
Links
- 239000003381 stabilizer Substances 0.000 title claims abstract description 96
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000033001 locomotion Effects 0.000 claims description 19
- 238000004891 communication Methods 0.000 claims description 17
- 230000006870 function Effects 0.000 claims description 16
- 230000005540 biological transmission Effects 0.000 claims description 14
- 230000008569 process Effects 0.000 claims description 6
- 238000006243 chemical reaction Methods 0.000 claims description 4
- 238000004806 packaging method and process Methods 0.000 claims description 4
- 230000004044 response Effects 0.000 claims description 4
- 238000012545 processing Methods 0.000 description 9
- 230000009471 action Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000002159 abnormal effect Effects 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012795 verification Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000087 stabilizing effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/06—Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40006—Architecture of a communication node
- H04L12/40013—Details regarding a bus controller
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/08—Protocols for interworking; Protocol conversion
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/18—Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40215—Controller Area Network CAN
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Bus Control (AREA)
- Communication Control (AREA)
Abstract
The invention discloses a stabilizer control system and method based on a CAN bus, and relates to the field of stabilizer control. The stabilizer control method includes the steps of: associating and storing a plurality of protocol formats with the stabilizer model; initializing a serial port and a CAN protocol, and setting a preset protocol format according to the model of the stabilizer; starting a main cycle, and sending initial control data to the singlechip by the control console through a serial port; converting the initial control data into protocol control data according to a preset protocol format; transmitting protocol control data to the stabilizer through the CAN controller; the invention can realize the universal control of multiple types of stabilizers through the preset protocol format, and is convenient for the application and switching of the controller; and the method and the device provide diversified customization demands, different protocol formats are provided for different stabilizers, the customization demands of different users can be met, and the applicability and the flexibility of the controller are improved.
Description
Technical Field
The invention relates to the field of stabilizer control, in particular to a stabilizer control system and method based on a CAN bus.
Background
In the field of industrial automation, the CAN box is equipment integrating multiple functions, and comprises the functions of data acquisition, processing, storage and the like. In the application scene in the camera stabilizer, the CAN box mainly plays a role in receiving control data and processing.
However, the CAN boxes in the prior art are designed only for the data transmission requirement of the public, and cannot be directly applied to the camera stabilizer of the specific signal. The controlled camera stabilizer is often a highly optimized control system, and if a user uses a common control protocol format, a complex debugging process is inevitably needed, and certain uncertainty and risk exist; furthermore, a specific CAN box is adapted to only one type of stabilizer signal, which is very inconvenient for modern camera systems with diversified management and control tasks.
Disclosure of Invention
In order to solve the problems existing in the prior art, the invention adopts the following technical scheme:
a stabilizer control method based on CAN bus includes the steps:
s1, associating and storing a plurality of protocol formats with a stabilizer model;
s2, initializing a serial port and a CAN protocol, and setting a preset protocol format according to the model of the stabilizer;
s3, starting a main cycle, and sending initial control data to the singlechip by the control console through the serial port;
s4, converting the initial control data into protocol control data according to a preset protocol format;
s5, transmitting protocol control data to the stabilizer through the CAN controller;
the step S5 specifically includes the following steps:
s51, converting protocol control data into bus data in a CAN bus data format through a CAN controller and sending the bus data to a CAN bus; the bus data comprises a plurality of data frames and data frame IDs;
s52, the stabilizer identifies bus data, and if the data frame ID is matched with a preset receiving ID of the stabilizer, the bus data is received;
and S53, the stabilizer analyzes and processes the bus data into protocol control data, and posture adjustment is performed accordingly.
As a preferred solution, the step S1 specifically includes the steps of:
generating a configuration file in an editor;
writing the configuration file into a memory of the singlechip;
the configuration file comprises a plurality of protocol formats, stabilizer models and association information of the protocol formats and the stabilizer models.
Preferably, the step S2 includes the following steps:
s21, connecting a control console to RX and TX interfaces of the singlechip through a serial port line;
s22, initializing serial port parameters, wherein the serial port parameters comprise baud rate, stop bit and data bit;
s23, initializing CAN communication parameters, wherein the CAN communication parameters comprise CAN bus frequency and received and transmitted data frame IDs;
s24, checking the data transmission function of the serial port and the CAN protocol;
s25, setting a preset protocol format according to the model of the stabilizer.
Preferably, the initial control data comprises a motion instruction and an attitude adjustment parameter; the motion instruction comprises a motion speed, a motion direction and a response speed; the attitude adjustment parameters include pitch angle, roll angle, and yaw angle.
Preferably, the step S4 specifically includes the following steps:
s41, decomposing the initial control data according to a preset protocol format;
s42, converting the decomposed data into a designated coding format through a coding conversion function according to a coding mode corresponding to the preset protocol format;
s43, packaging the data with the appointed coding format according to a preset protocol format to generate protocol control data.
Preferably, the step S51 includes generating a CRC check, specifically:
s511, setting a generator polynomial; the generator polynomial is a fixed binary number value;
s512, shifting the data frame one bit to the left, and then adding 0 to the lowest bit to obtain extension data;
s513, shifting the extended data left by n bits, and then performing exclusive OR on the two polynomials to obtain a remainder; wherein the value of n is reduced by 1 for the number of bits of the generator polynomial;
s514, adding the remainder to the end of the data frame to generate bus data.
Preferably, the step S53 includes the steps of: the stabilizer uses the generator polynomial to perform CRC check, specifically:
s531, the stabilizer combines the received frame data with the check code to obtain data to be checked;
s532, expanding the data to be verified to obtain expanded data;
s533, dividing the expanded data by a generator polynomial to obtain a remainder;
s534, comparing the remainder with the check code sent by the sender; if the remainder is 0, the check passes, otherwise the check fails.
Preferably, the stabilizer control method of the present invention further comprises the steps of:
s6, feeding back an execution result to a control console by the stabilizer, wherein the execution result is specifically:
s61, the stabilizer sends a feedback data frame to the CAN bus; the feedback data frame includes a data frame ID;
s62, the CAN controller identifies a feedback data frame, and if the data frame ID of the feedback data frame is matched with a preset receiving ID of the CAN controller, the feedback data frame is received;
s63, the CAN controller analyzes the feedback data frame through the singlechip and transmits the feedback data frame to the console;
s64, the control console judges the state and updates the data according to the feedback data frame.
As a preferable scheme, SPI communication is adopted between the singlechip and the CAN controller.
The invention also provides a stabilizer control system based on the CAN bus, which is applied to executing the stabilizer control method, and comprises a console, a CAN box, the CAN bus, a processor and a stabilizer;
the processor is used for generating a configuration file and transmitting the configuration file to the singlechip; the CAN box and the stabilizer are respectively connected with a CAN bus; the CAN box comprises a singlechip and a CAN controller; the singlechip is used for converting initial control data into protocol control data according to a preset protocol format; the CAN controller is used for converting protocol control data into bus data in a CAN bus data format.
Compared with the prior art, the invention has the following beneficial effects:
the invention can realize the universal control of multiple types of stabilizers through the preset protocol format, and is convenient for the application and switching of the controller; the method and the device provide diversified customization demands, different protocol formats are provided for different stabilizers, the customization demands of different users can be met, and the applicability and the flexibility of the controller are improved;
the invention adopts CRC technology to detect errors and distortions in the data transmission process, thereby improving the reliability and safety of data transmission;
according to the invention, the execution result of the stabilizer is fed back to the control console to update data and judge state, and subsequent control decision real-time adjustment and abnormal conditions can be timely processed, so that the control accuracy, stability and safety are improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a stabilizer control method based on a CAN bus according to an embodiment of the present invention;
FIG. 2 is a flowchart of step S5 according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a stabilizer control system based on a CAN bus according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be clearly and completely described in connection with the embodiments, and it is obvious that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention. It is noted that relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
Referring to fig. 1, the invention provides a stabilizer control method based on a CAN bus, comprising the following steps:
s1, associating a plurality of protocol formats with the model of the stabilizer and storing the format into the singlechip.
Specifically, the protocol format and the stabilizer model may be in one-to-one relationship or one-to-many relationship. The protocol format should include data format, data type, transmission protocol, etc. elements of the control data.
As a preferred embodiment, step S1 specifically includes the steps of:
generating a configuration file in the editor, wherein the configuration file comprises a plurality of protocol formats, stabilizer models and associated information of the protocol formats and the stabilizer models; and writing the configuration file into a memory of the singlechip.
S2, initializing a serial port and a CAN protocol, and setting a protocol format according to the model matching of the stabilizer.
In one embodiment, the editor is Arduinoide, the singlechip is Arduinonano, and the CAN controller is MCP2515.
Based on the above embodiment, step S2 includes the steps of:
s21, connecting hardware: the console is connected to RX and TX interfaces of the singlechip through serial port lines.
S22, serial port initialization: in the ArduinoIDE development environment, serial parameters including baud rate, stop bits, data bits, etc. are initialized using a serial. For example: serial. Begin (115200), indicating that the serial baud rate is set to 115200.
S23, initializing a CAN protocol: in the development environment of ArduinoIDE, corresponding CAN bus libraries are loaded after being adapted, and CAN communication parameters are initialized by using a CAN.begin function, wherein the CAN communication parameters comprise CAN bus frequency, received and transmitted data frame IDs and the like.
S24, checking the data transmission function of the serial port and the CAN protocol: judging whether serial data exists or not by using a serial.available function, and then reading the serial data by using a serial.read function; judging whether the CAN message exists or not by using a CAN.message available function, and then reading the CAN message by using a CAN.read function; transmitting data using the serial. And judging whether the data transmission function of the serial port and the CAN communication is normal or not by reading and sending the data.
Wherein the functions are provided by a function library of ArduinoIDE.
S25, setting a preset protocol format according to the model of the stabilizer: different models of stabilizers may use different communication protocols, so that it is necessary to match its model to determine the protocol format used before processing the initial control data. Based on the configuration file in the memory, the preset protocol format corresponding to the stabilizer model is unique. Thus, the preset protocol format can be directly set by the stabilizer model.
S3, starting a main cycle, and sending initial control data to the singlechip by the control console through the serial port; wherein the initial control data includes at least a motion command and a gesture adjustment parameter. The motion instruction comprises instruction data such as motion speed, motion direction, response speed and the like; the attitude adjustment parameters comprise data such as pitch angle, roll angle, yaw angle and the like.
Further, the main cycle is specifically a CAN cartridge main cycle. The CAN box comprises a singlechip and a CAN controller, and the main cycle of the CAN box refers to the main control flow of the CAN box and is used for processing data receiving, transmitting and processing on a CAN bus. The CAN box main cycle is an infinite cycle, and runs continuously after the CAN box is started, and waits for new data to arrive on the CAN bus and is processed.
In an embodiment, the singlechip is Arduinonano, the CAN controller is MCP2515, SPI communication is adopted between Arduinonano and MCP2515, the singlechip is a master device, and the CAN controller is a slave device. Further, arduinonano communicates with MCP2515 via MOSI lines. ArduinoNano controls the clock signal through SCK line to maintain synchronism of data transmission. The ArduinoNano controls chip select signals of the MCP2515 module via SS lines to select communications with the MCP2515 module. In this way, data may be transferred between the ArduinoNano and MCP2515 modules via the SPI protocol.
S4, converting the initial control data into protocol control data according to a preset protocol format;
it should be noted that, the controlled stabilizer is a highly optimized control system, and is internally provided with rich control algorithms and sensors, and if a user uses a custom control protocol format, a complex debugging process is inevitably required, and there is a certain uncertainty and risk, so that initial control data needs to be converted into protocol control data.
The preset protocol format is matched with the controlled stabilizer, and the stabilizer can analyze and perform corresponding gesture adjustment and motion adjustment operations when receiving the protocol control data so as to meet the requirements of stability and accuracy.
Further, the step S4 specifically includes:
s41, decomposing initial control data: decomposing the initial control data according to a preset protocol format;
s42, code conversion, namely converting the decomposed data into a designated code format through a code conversion function according to a code mode corresponding to a preset protocol format;
s43, packaging a protocol: and packaging the data with the appointed coding format according to a preset protocol format to generate protocol control data.
In a specific implementation, the technical scheme of data analysis needs to be properly adjusted according to the protocol format and the specific application scenario so as to ensure the reliability of control data and the stability of a program.
In summary, since each stabilizer generally needs a set of specific control instructions and communication protocols, the invention can realize the generalized control of multiple types of stabilizers by burning multiple protocol formats into the singlechip, and is convenient for the application and switching of the controller. And provides diversified customization needs. Different protocol formats are provided for different stabilizers, so that the customization requirements of different users can be met, and the applicability and flexibility of the controller are improved.
S5, transmitting the protocol control data to the stabilizer through the CAN controller.
Further, referring to fig. 2, step S5 includes:
s51, converting protocol control data into bus data in a CAN bus data format through a CAN controller and sending the bus data to a CAN bus; the bus data comprises a plurality of data frames and a data frame ID, wherein the data frame ID is used for marking the destination address of the data frames. The CAN bus may connect a plurality of CAN boxes and a plurality of stabilizers.
S52, the stabilizer identifies bus data, and if the data frame ID is matched with a preset receiving ID of the stabilizer, the bus data is received;
on the CAN bus, each node CAN receive bus data transmitted on the bus, but needs to determine whether the received bus data is data required by the node. Therefore, each node adds a data frame ID to the data frame for indicating the destination address of the transmission bus data when transmitting the data. At the receiving end, whether the data frame needs to be received can be judged by judging whether the received data frame ID is matched with the ID required to be received by the node. If the IDs of the data frames match, it is indicated that the data frame is the data required by the node.
By the mode, the CAN node CAN accurately judge whether the received data is the data required by the CAN node. The method CAN save processing resources of nodes, reduce communication burden of the CAN bus and improve bus communication efficiency.
And S53, the stabilizer analyzes and processes the bus data into protocol control data, and posture adjustment is performed accordingly.
The protocol control data includes at least a motion instruction and a posture adjustment parameter corresponding to the initial control data. The motion instruction comprises instruction data such as motion speed, motion direction, response speed and the like; the attitude adjustment parameters comprise data such as pitch angle, roll angle, yaw angle and the like. The stabilizer adjusts the gesture and the movement of the camera by utilizing sensor data and calculation according to the movement instruction and gesture adjustment parameters so as to achieve the purpose of stabilizing shooting.
As a preferred embodiment, step S51 includes generating a CRC check, specifically:
s511, setting a generator polynomial, wherein the generator polynomial is a fixed binary value. The number of bits of the generator polynomial is at least 1 more than the number of bits of the data frame + the check code. For example, an 8-bit long binary frame requires the use of a 9-bit long generator polynomial to calculate the check code;
s512, shifting the data frame one bit to the left, and then adding 0 on the lowest bit to obtain extension data, so that the number of bits of the extension data is 1 less than that of the generated polynomial;
s513, shifting the extended data left by n bits, and then performing exclusive OR on the two polynomials to obtain a new polynomial and remainder; wherein the value of n is reduced by 1 for the number of bits of the generator polynomial;
s514, taking the remainder as a check code of the data frame. And attaching a check code to the end of the data frame to generate bus data.
Based on the above embodiment, the step S53 includes the steps of: the stabilizer uses the generating polynomial to carry out CRC check, and specifically comprises the following steps:
and S531, after the stabilizer receives the frame data and the check code, merging the frame data and the check code to obtain the data to be checked.
S532, expanding the data to be verified in the same way as in the step S512 to obtain expanded data.
S533, dividing the expanded data by a generator polynomial to obtain a remainder.
S534, comparing the remainder with the check code sent by the sender; if the remainder is 0, the data transmission is clear, and the verification passes; otherwise, the data transmission is error or distorted, the verification is not passed, and error processing is needed.
The embodiment of the invention can effectively detect errors and distortions in the data transmission process by adopting the CRC technology, and improves the reliability and safety of the data transmission.
As a preferred embodiment, the stabilizer control method of the present invention further comprises the steps of:
s6, feeding back an execution result to a control console by the stabilizer, wherein the method specifically comprises the following steps of:
s61, the stabilizer sends a feedback data frame to the CAN bus; the feedback data frame includes a data frame ID;
s62, the CAN controller identifies a feedback data frame, and if the data frame ID of the feedback data frame is matched with a preset receiving ID of the CAN controller, the feedback data frame is received;
s63, the CAN controller analyzes the feedback data frame through the singlechip and transmits the feedback data frame to the console;
s64, the control console performs operations such as state judgment, data updating and the like according to the feedback data frame.
According to the embodiment of the invention, the execution result of the stabilizer is fed back to the control console to perform data updating and state judging operations, so that data updating and state real-time judging are realized. For example, if the feedback data frame contains alarm information, the console may recognize the information and perform corresponding processing, such as sending an alarm prompt or turning off the associated actuator. According to the method, the control console can timely acquire the execution result of the executor, and can timely process subsequent control decision real-time adjustment and abnormal conditions, so that the control accuracy, stability and safety are improved.
Referring to fig. 3, the present invention further provides a stabilizer control system based on a CAN bus, for executing the above stabilizer control method, including a console, a CAN box, a CAN bus, a processor, and a stabilizer.
The processor is used for generating a configuration file and transmitting the configuration file to the singlechip.
The CAN box and the stabilizer are respectively connected with a CAN bus; the CAN box comprises a singlechip and a CAN controller; the singlechip is used for converting initial control data into protocol control data according to a preset protocol format; the CAN controller is used for converting protocol control data into bus data in a CAN bus data format. The number of CAN cartridges and stabilizers may be plural.
In the several embodiments provided in this application, it should be understood that the disclosed units and methods may be implemented in other ways. For example, the above-described embodiments of the units are merely illustrative, e.g., the division of the units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another unit, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of modules, electrical, mechanical, or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, i.e. may be located in one place, or may be distributed over a plurality of units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules.
The integrated modules, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM, randomaccess memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Claims (6)
1. A stabilizer control method based on a CAN bus is characterized in that: the method comprises the following steps:
s1, associating and storing a plurality of protocol formats with a stabilizer model;
s2, initializing a serial port and a CAN protocol, and setting a preset protocol format according to the model of the stabilizer;
s3, starting a main cycle, and sending initial control data to the singlechip by the control console through the serial port;
s4, converting the initial control data into protocol control data according to a preset protocol format;
s5, transmitting protocol control data to the stabilizer through the CAN controller;
the step S5 specifically includes the following steps:
s51, converting protocol control data into bus data in a CAN bus data format through a CAN controller and sending the bus data to a CAN bus; the bus data comprises a plurality of data frames and data frame IDs;
s52, the stabilizer identifies bus data, and if the data frame ID is matched with a preset receiving ID of the stabilizer, the bus data is received;
s53, the stabilizer analyzes and processes the bus data into protocol control data, and posture adjustment is carried out according to the protocol control data;
the step S51 includes generating a CRC check, specifically:
s511, setting a generator polynomial; the generator polynomial is a fixed binary number value;
s512, shifting the data frame one bit to the left, and then adding 0 to the lowest bit to obtain extension data;
s513, shifting the extended data left by n bits, and then performing exclusive OR on the two polynomials to obtain a remainder; wherein the value of n is reduced by 1 for the number of bits of the generator polynomial;
s514, attaching the remainder to the end of the data frame to generate bus data;
the step S53 includes the steps of: the stabilizer uses the generator polynomial to perform CRC check, specifically:
s531, the stabilizer combines the received frame data with the check code to obtain data to be checked;
s532, expanding the data to be verified to obtain expanded data;
s533, dividing the expanded data by a generator polynomial to obtain a remainder;
s534, comparing the remainder with the check code sent by the sender; if the remainder is 0, checking passing, otherwise checking failing;
the step S2 includes the steps of:
s21, connecting a control console to RX and TX interfaces of the singlechip through a serial port line;
s22, initializing serial port parameters, wherein the serial port parameters comprise baud rate, stop bit and data bit;
s23, initializing CAN communication parameters, wherein the CAN communication parameters comprise CAN bus frequency and received and transmitted data frame IDs;
s24, checking the data transmission function of the serial port and the CAN protocol;
s25, setting a preset protocol format according to the model of the stabilizer;
the stabilizer control method further includes the steps of:
s6, feeding back an execution result to a control console by the stabilizer, wherein the execution result is specifically:
s61, the stabilizer sends a feedback data frame to the CAN bus; the feedback data frame includes a data frame ID;
s62, the CAN controller identifies a feedback data frame, and if the data frame ID of the feedback data frame is matched with a preset receiving ID of the CAN controller, the feedback data frame is received;
s63, the CAN controller analyzes the feedback data frame through the singlechip and transmits the feedback data frame to the console;
s64, the control console judges the state and updates the data according to the feedback data frame.
2. The stabilizer control method according to claim 1, characterized in that: the step S1 specifically comprises the steps of:
generating a configuration file in an editor;
writing the configuration file into a memory of the singlechip;
the configuration file comprises a plurality of protocol formats, stabilizer models and association information of the protocol formats and the stabilizer models.
3. The stabilizer control method according to claim 1, characterized in that: the initial control data comprises a motion instruction and an attitude adjustment parameter; the motion instruction comprises a motion speed, a motion direction and a response speed; the attitude adjustment parameters include pitch angle, roll angle, and yaw angle.
4. The stabilizer control method according to claim 1, characterized in that: the step S4 specifically includes the following steps:
s41, decomposing the initial control data according to a preset protocol format;
s42, converting the decomposed data into a designated coding format through a coding conversion function according to a coding mode corresponding to the preset protocol format;
s43, packaging the data with the appointed coding format according to a preset protocol format to generate protocol control data.
5. The stabilizer control method according to claim 1, characterized in that: SPI communication is adopted between the singlechip and the CAN controller.
6. A stabilizer control system based on CAN bus is characterized in that: application to perform the stabilizer control method of any one of claims 1-5, comprising a console, a CAN box, a CAN bus, a processor and a stabilizer;
the processor is used for generating a configuration file and transmitting the configuration file to the singlechip; the CAN box and the stabilizer are respectively connected with a CAN bus; the CAN box comprises a singlechip and a CAN controller; the singlechip is used for converting initial control data into protocol control data according to a preset protocol format; the CAN controller is used for converting protocol control data into bus data in a CAN bus data format.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310765563.9A CN116708590B (en) | 2023-06-27 | 2023-06-27 | Stabilizer control system and method based on CAN bus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310765563.9A CN116708590B (en) | 2023-06-27 | 2023-06-27 | Stabilizer control system and method based on CAN bus |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116708590A CN116708590A (en) | 2023-09-05 |
CN116708590B true CN116708590B (en) | 2024-01-23 |
Family
ID=87837235
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310765563.9A Active CN116708590B (en) | 2023-06-27 | 2023-06-27 | Stabilizer control system and method based on CAN bus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116708590B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104484618A (en) * | 2014-12-05 | 2015-04-01 | 中国航空工业集团公司第六三一研究所 | Universal flying data storage method |
CN109644233A (en) * | 2017-02-24 | 2019-04-16 | 深圳市大疆创新科技有限公司 | More head assemblies |
CN113923352A (en) * | 2021-09-15 | 2022-01-11 | 浙江大华技术股份有限公司 | Holder control method, holder control device, electronic equipment and storage medium |
CN114389752A (en) * | 2021-12-15 | 2022-04-22 | 上海金仕达软件科技有限公司 | Cyclic redundancy check code generation method, apparatus, device, medium, and program product |
CN115882876A (en) * | 2023-02-16 | 2023-03-31 | 苏州浪潮智能科技有限公司 | Data coding verification method, system, equipment, medium and circuit |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130321656A1 (en) * | 2012-04-06 | 2013-12-05 | Hoverfly Technologies, Inc. | Wireless network connected camera positioning system |
-
2023
- 2023-06-27 CN CN202310765563.9A patent/CN116708590B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104484618A (en) * | 2014-12-05 | 2015-04-01 | 中国航空工业集团公司第六三一研究所 | Universal flying data storage method |
CN109644233A (en) * | 2017-02-24 | 2019-04-16 | 深圳市大疆创新科技有限公司 | More head assemblies |
CN113923352A (en) * | 2021-09-15 | 2022-01-11 | 浙江大华技术股份有限公司 | Holder control method, holder control device, electronic equipment and storage medium |
CN114389752A (en) * | 2021-12-15 | 2022-04-22 | 上海金仕达软件科技有限公司 | Cyclic redundancy check code generation method, apparatus, device, medium, and program product |
CN115882876A (en) * | 2023-02-16 | 2023-03-31 | 苏州浪潮智能科技有限公司 | Data coding verification method, system, equipment, medium and circuit |
Also Published As
Publication number | Publication date |
---|---|
CN116708590A (en) | 2023-09-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20150277415A1 (en) | Programmable logic controller and programming tool for programmable logic controller | |
US20040153907A1 (en) | Safety network using phantom address information | |
JP6163748B2 (en) | Communication coupler, communication system, control method, and program | |
CN112637013A (en) | CAN bus message abnormity detection method and device, equipment and storage medium | |
US11977508B2 (en) | Serial data communication with in-frame response | |
CN111104272A (en) | CAN bus controller testing method based on RX and TX | |
CN110941218A (en) | A kind of CAN bus controller test method | |
CN107205063A (en) | A kind of device conflict solution of Intelligent housing bus | |
CN101995841B (en) | Device for plugging into a computer system and computer system | |
CN117389167A (en) | Acceleration simulation method, device and system for SDM and storage medium | |
CN116708590B (en) | Stabilizer control system and method based on CAN bus | |
JP2014119906A (en) | Communication unit, communication system, control method, and program | |
EP1789858B1 (en) | Safety control device, safety control system, and method for detecting communication error | |
KR101937407B1 (en) | Apparatus and method for monitoring Microcontroller Unit | |
EP3656512A1 (en) | Device, system and method for plug-and-play integration of components in robotic systems | |
CN111010258B (en) | Computer interlocking system communication method based on coding | |
US7689301B2 (en) | Safety control device, safety control system, and method for detecting communication error | |
US20230032989A1 (en) | Serial data communication with in-frame response | |
CN113474762B (en) | Transmission of link data on the I2C bus | |
JPS6232813B2 (en) | ||
JP2018010331A (en) | Diagnostic device and diagnostic method | |
CN113127063A (en) | Operating circuit and control method | |
JP2018502465A (en) | Data transmission between at least one secure producer and at least one secure consumer | |
CN119150375B (en) | Multi-chip communication safety function system and method | |
Karvande et al. | High Performance Optimized and Unified Bus Monitor for Distributed Avionics Architecture Validation Under Hardware-in-Loop Simulation Framework |
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 |