Data interaction method and data communication module of basic serial port

文档序号:190308 发布日期:2021-11-02 浏览:38次 中文

阅读说明:本技术 一种基础串口的数据交互方法和数据通信模块 (Data interaction method and data communication module of basic serial port ) 是由 王斌 王英超 赵丰 王海星 于 2021-08-23 设计创作,主要内容包括:本发明公开了种基础串口的数据通信模块,设置在家电上,包括主控板芯片和通过通用异步收发传输器与主控板芯片通信连接的通讯芯片,主控板芯片给通讯芯片发送与待配对端进行配对的配对指令,通讯芯片进入配对状态,并在配对过程中,通讯芯片朝向主控板芯片先后发送配对状态指令和配对结果确认命令,且在主控板芯片发生状态改变时,主控板芯片向通讯芯片发送状态变化指令,待配对端发生状态改变时,待配对端通过通讯芯片向主控板芯片发送状态变化指令。还公开了基于此模块的数据交互方法,提高了数据传输的正确性及通信的可靠性。(The invention discloses a data communication module of a basic serial port, which is arranged on a household appliance and comprises a main control board chip and a communication chip in communication connection with the main control board chip through a universal asynchronous receiving and transmitting transmitter, wherein the main control board chip sends a pairing instruction for pairing with a to-be-paired end to the communication chip, the communication chip enters a pairing state, in the pairing process, the communication chip sends a pairing state instruction and a pairing result confirmation instruction towards the main control board chip in sequence, when the state of the main control board chip is changed, the main control board chip sends a state change instruction to the communication chip, and when the state of the to-be-paired end is changed, the to-be-paired end sends a state change instruction to the main control board chip through the communication chip. Also discloses a data interaction method based on the module, which improves the correctness of data transmission and the reliability of communication.)

1. The utility model provides a data communication module of basic serial ports, sets up on household electrical appliances its characterized in that: the communication chip is in communication connection with the main control board chip through the universal asynchronous receiving and transmitting transmitter, the main control board chip sends a pairing instruction to be paired with a to-be-paired end to the communication chip, the communication chip enters a pairing state and is in a pairing process, the communication chip sends a pairing state instruction and a pairing result confirmation instruction towards the main control board chip, when the main control board chip changes the state, the main control board chip sends a state change instruction to the communication chip, and when the to-be-paired end changes the state, the to-be-paired end sends the state change instruction to the main control board chip through the communication chip.

2. The data communication module of the basic serial port according to claim 1, characterized in that: and the main control board chip and the communication chip carry out information interaction through data frames.

3. The data communication module of the basic serial port according to claim 2, characterized in that: the data frame comprises a 1-byte frame header, a 1-byte webpage, a 2-byte update identifier, 16-byte data and a 1-byte check.

4. The data communication module of the basic serial port according to claim 1, characterized in that: the main control board chip and the communication chip are respectively connected with an external crystal oscillator and a reset circuit which are correspondingly arranged, and the communication chip is further connected with an antenna circuit which is in communication connection with a terminal to be paired.

5. The data communication module of the basic serial port according to claim 1, characterized in that: the end to be paired comprises a remote controller and a router.

6. A data interaction method of a basic serial port is based on the communication module of any one of claims 1 to 5, and is characterized in that: when the to-be-paired end is paired with the communication chip, firstly, a pairing instruction for pairing with the to-be-paired end is sent towards the communication chip through the main control board chip, and the communication chip enters a pairing state; and in the pairing process, the communication chip returns a pairing state instruction to the main control board chip and then sends a pairing result confirmation command.

7. The data interaction method of the basic serial port according to claim 6, characterized in that: after the pairing of the paired end and the communication chip is completed, when the state of the main control board chip is changed, the main control board chip sends a state change instruction to the communication chip; and when the state of the end to be paired is changed, the end to be paired sends a state change instruction to the main control board chip through the communication chip.

8. The data interaction method of the basic serial port according to claim 6, characterized in that: the main control board chip and the communication chip carry out information interaction through a data frame, and the data frame comprises a 1-byte frame header, a 1-byte webpage, a 2-byte updating identifier, 16-byte data and 1-byte check.

Technical Field

The invention relates to the technical field of serial port information interaction, in particular to a data interaction method and a data communication module of a basic serial port.

Background

Serial communication is a communication mode for transmitting data between a peripheral and a computer bit by bit through a data signal line, a ground line, a control line and the like. This communication method uses fewer data lines, and can save communication cost in long-distance communication, but the transmission speed is lower than that of parallel transmission. Serial ports are a very common device communication protocol on computers. Most computers (not including laptops) contain two RS-232 based serial ports. The serial port is also a general communication protocol of the instrument and meter equipment; many GPIB-compatible devices also have an RS-232 port. Meanwhile, the serial port communication protocol can also be used for acquiring data of the remote acquisition equipment.

Serial communication is popular in embedded development due to its characteristics of convenience, flexibility and understandability. In serial communication programming, communication software is a vital core part, and the communication software is required to have low communication error rate, not overtime and the capability of monitoring the communication state in real time, and other functions are increased on the basis. The serial port communication protocol can make different protocol formats aiming at different application scenes.

Therefore, the serial communication interface is used as a main interface for data interaction between a computer and a single chip microcomputer, and the main important points of the serial communication interface are communication reliability and low fault-tolerant capability in a communication process. That is, the communication protocol is a contract that both parties need to communicate, and it provides a unified rule for problems including data format, synchronization method, transmission speed, transmission procedure, error detection and correction method, and control character definition, and must be observed in both parties' communication. In an actual application system, if a strict, reasonable and normative serial communication protocol is lacked, the correctness of data transmission and the reliability of communication cannot be ensured.

Disclosure of Invention

In order to overcome the defects, the invention aims to provide a data communication module of a basic serial port, which improves the correctness of data transmission and the reliability of communication.

In order to achieve the above purposes, the invention adopts the technical scheme that: the utility model provides a data communication module of basic serial ports, sets up on household electrical appliances, includes main control board chip and the communication chip through universal asynchronous receiving and dispatching transmitter and main control board chip communication connection, main control board chip send for the communication chip with wait to pair the end and carry out the pairing instruction of pairing, the communication chip gets into the pairing state to in the pairing process, the communication chip successively sends the pairing state instruction towards main control board chip and pairs the result and confirm the order, and when main control board chip takes place the state change, main control board chip sends the state change instruction to the communication chip, when waiting to pair the end and taking place the state change, wait to pair the end and send the state change instruction to main control board chip through the communication chip.

Further, the main control board chip and the communication chip perform information interaction through data frames.

Further, the data frame includes a header of 1 byte, a web page of 1 byte, an update flag of 2 bytes, data of 16 bytes, and a check of 1 byte.

The main control board chip and the communication chip are respectively connected with an external crystal oscillator and a reset circuit which are correspondingly arranged, and the communication chip is further connected with an antenna circuit which is used for being in communication connection with the end to be paired.

Further, the end to be paired comprises a remote controller and a router.

The invention has the beneficial effects that: the main control board chip drives the communication chip to realize data interaction with the household appliance, and serial port data interaction is realized more efficiently. And the data frame is set to ensure the correctness of data transmission and the reliability of communication.

The invention also provides a data communication method of the basic serial port, and a new serial port protocol is adopted, so that the correctness of data transmission and the reliability of communication are improved.

In order to achieve the above purposes, the invention adopts the technical scheme that: when a to-be-paired end and a communication chip are paired, firstly, a main control board chip sends a pairing instruction for pairing with the to-be-paired end to the communication chip, and the communication chip enters a pairing state; and in the pairing process, the communication chip returns a pairing state instruction to the main control board chip and then sends a pairing result confirmation command.

Further, after the paired end and the communication chip are paired, when the state of the main control board chip is changed, the main control board chip sends a state change instruction to the communication chip; and when the state of the end to be paired is changed, the end to be paired sends a state change instruction to the main control board chip through the communication chip.

Further, the main control board chip and the communication chip perform information interaction through a data frame, and the data frame comprises a frame header of 1 byte, a webpage of 1 byte, an update identifier of 2 bytes, data of 16 bytes and check of 1 byte.

The invention has the beneficial effects that: the main control board chip drives the communication chip to realize data interaction with the household appliance, and serial port data interaction is realized more efficiently. And the data frame is set to ensure the correctness of data transmission and the reliability of communication.

Drawings

FIG. 1 is a system block diagram of a data communication module according to the present invention;

FIG. 2 is a flow chart of a data interaction method according to the present invention.

In the figure:

1. a main control board chip; 2. and a communication chip.

Detailed Description

The following detailed description of the preferred embodiments of the present invention, taken in conjunction with the accompanying drawings, will make the advantages and features of the invention easier to understand by those skilled in the art, and thus will clearly and clearly define the scope of the invention.

Referring to fig. 1-2, the invention aims to provide a data communication module of a basic serial port, which improves the correctness of data transmission and the reliability of communication. The device is arranged on household appliances and comprises a main control board chip 1 and a communication chip 2 which is in communication connection with the main control board chip 1 through a universal asynchronous receiving and transmitting transmitter. The type of the main control board chip is GD32F 103. The main control board chip sends a pairing instruction for pairing with the to-be-paired end to the communication chip, and the communication chip enters a pairing state. And in the pairing process, the communication chip sends a pairing state instruction and a pairing result confirmation command to the main control board chip in sequence.

When the state of the main control board chip 1 is changed, the main control board chip 1 sends a state change instruction to the communication chip 2, and when the state of the to-be-paired end is changed, the to-be-paired end sends the state change instruction to the main control board chip through the communication chip.

The end to be paired comprises a remote controller and a router. Namely, (1) router pairing: when the pairing router and the communication chip are paired, the main control board chip sends a pairing command to the communication chip, and the communication chip enters a pairing state. And the communication chip returns the entering state confirmation and the pairing result confirmation command in the pairing process. (2) Remote controller pairing: when the pairing remote controller and the communication chip are paired, the main control board chip sends a pairing command to the communication chip, and the communication chip enters a pairing state. And the communication chip returns the entering state confirmation and the pairing result confirmation command in the pairing process. (3) Updating the state change of the main control board chip: when the state of the main control board chip changes, the main control board chip sends a state change instruction to the communication chip. (4) Updating the state change of the communication chip: and when the communication chip receives a command with the opposite terminal, the communication chip sends a state change instruction to the main control board chip.

The communication speed between the main control board chip and the communication chip is 115200bps, and the main control board chip and the communication chip perform information interaction through data frames. The data frame comprises a 1-byte frame header, a 1-byte webpage, a 2-byte update identifier, 16-byte data and a 1-byte check. The specific composition of the data frame is shown in the following table 1

Frame header Command Page Updating an identity Data of Checksum
0xFA 1 byte 1 byte 2 bytes 16 bytes 1 byte

Wherein the meaning of each part of the data frame is as follows:

frame head: 1 byte, fixed to 0 xFA.

Command: 1 byte

0x01, the main control board chip sends to the communication chip and enters into the matching state with the router;

0x02, the communication chip sends to the main control board chip to confirm entering the matching state with the router;

0x03, the communication chip sends the main control board chip to inform the end of the matching state with the router, and the matching is successful;

0x04, the communication chip sends the main control board chip to inform the end of the matching state with the router, and the matching fails;

0x05, the main control board sends to the communication chip and enters into the state of matching with the remote controller;

0x06, the communication chip sends to the main control board chip to confirm the entering and remote controller matching state;

0x07, the communication chip sends the information to the main control board chip to inform the end of the pairing with the remote controller, and the pairing is successful;

0x08, the communication chip sends the main control board chip to inform the end of the pairing state with the remote controller, and the pairing fails;

0x0 b-the main control board sends to the communication chip, informing the data update;

0x0 c-the communication chip sends to the main control board chip, informing the data update.

0x0 d-update data receiving confirmation, and after the mainboard chip and the communication chip update data, sending confirmation data to the other side.

0xf 0-main control board sends transparent transmission data to communication chip

0xf 1-communication chip sends transparent transmission data to main control board chip

The remote control code can be transmitted in a mode of transmitting the code

0xE 0-communication chip sends network-off state information to main control board chip

0xE 1-communication chip sends state information of network connection to main control board

Page: 1 byte 0-256

Updating the identifier: 2 bytes

Each bit indicates the presence or absence of an update in the following byte amount, 1 indicates an update, and 0 indicates no update.

For example: the analog update is identified as 00001001B, indicating that the 7 th and lower 4 states have changed.

Data: 16 bytes

Each 2 bytes represents a register, REG7, REG6.. REG0 in turn. The first byte of each register is the low byte and the 2 nd byte is the high byte.

And (4) checking the sum: 1 byte

And (4) inverting the result after all bytes are added from the frame head.

The communication module further comprises a power circuit for supplying power to the main control board chip and the communication chip, the main control board chip and the communication chip are further respectively connected with an external crystal oscillator and a reset circuit which are correspondingly arranged, and the communication chip is further connected with an antenna circuit which is used for being in communication connection with the terminal to be paired.

The GD32F103 is used as a main control board chip, the communication chip is driven to realize data interaction with the household appliance, and serial port data interaction is realized more efficiently. And the data frame is set to ensure the correctness of data transmission and the reliability of communication.

The invention also provides a data communication method of the basic serial port, and a new serial port protocol is adopted, so that the correctness of data transmission and the reliability of communication are improved. When the to-be-paired end is paired with the communication chip, firstly, a pairing instruction for pairing with the to-be-paired end is sent towards the communication chip through the main control board chip, and the communication chip enters a pairing state; and in the pairing process, the communication chip returns a pairing state instruction to the main control board chip and then sends a pairing result confirmation command.

Namely, (1) router pairing: when the pairing router and the communication chip are paired, the main control board chip sends a pairing command to the communication chip, and the communication chip enters a pairing state. And the communication chip returns the entering state confirmation and the pairing result confirmation command in the pairing process. (2) Remote controller pairing: when the pairing remote controller and the communication chip are paired, the main control board chip sends a pairing command to the communication chip, and the communication chip enters a pairing state. And the communication chip returns the entering state confirmation and the pairing result confirmation command in the pairing process. (3) Updating the state change of the main control board chip: when the state of the main control board chip changes, the main control board chip sends a state change instruction to the communication chip. (4) Updating the state change of the communication chip: and when the communication chip receives a command with the opposite terminal, the communication chip sends a state change instruction to the main control board chip.

After the pairing of the paired end and the communication chip is completed, when the state of the main control board chip is changed, the main control board chip sends a state change instruction to the communication chip; and when the state of the end to be paired is changed, the end to be paired sends a state change instruction to the main control board chip through the communication chip. The communication speed between the main control board chip and the communication chip is 115200bps, information interaction is carried out between the main control board chip and the communication chip through a data frame, and the data frame comprises a frame header of 1 byte, a webpage of 1 byte, an updating mark of 2 bytes, data of 16 bytes and check of 1 byte.

The above embodiments are merely illustrative of the technical concept and features of the present invention, and the present invention is not limited thereto, and any equivalent changes or modifications made according to the spirit of the present invention should be included in the scope of the present invention.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种双工通讯信息传递方法、系统及应用

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!