WO2012062219A1 - 一种波特率自适应的modbus中继器和波特率自适应系统及方法 - Google Patents

一种波特率自适应的modbus中继器和波特率自适应系统及方法 Download PDF

Info

Publication number
WO2012062219A1
WO2012062219A1 PCT/CN2011/082092 CN2011082092W WO2012062219A1 WO 2012062219 A1 WO2012062219 A1 WO 2012062219A1 CN 2011082092 W CN2011082092 W CN 2011082092W WO 2012062219 A1 WO2012062219 A1 WO 2012062219A1
Authority
WO
WIPO (PCT)
Prior art keywords
baud rate
data
count value
falling edge
threshold
Prior art date
Application number
PCT/CN2011/082092
Other languages
English (en)
French (fr)
Inventor
陈磊
Original Assignee
施耐德电器工业公司
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 施耐德电器工业公司 filed Critical 施耐德电器工业公司
Priority to US13/884,877 priority Critical patent/US8929425B2/en
Priority to EP11839438.6A priority patent/EP2639704B1/en
Publication of WO2012062219A1 publication Critical patent/WO2012062219A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B3/00Line transmission systems
    • H04B3/02Details
    • H04B3/36Repeater circuits
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices

Definitions

  • the present invention relates to a baud rate adaptive system and method and a Modbus repeater, and more particularly to a baud rate adaptive Modbus repeater implementation. Background technique
  • Modbus is a fieldbus standard first proposed by the US M0DIC0N company.
  • the existing MODBUS repeater uses a rotary encoder to manually set the baud rate and encoding format of the MODBUS communication, which cannot meet the remote control needs of the customer, and cannot realize the remote automatic detection function, and the manual operation is inconvenient.
  • This design uses Complex Programmable Logic Device (CPLD) and external crystal oscillator to control the relay of MODBUS communication. It can automatically detect the baud rate and encoding format of MODBUS data frame, and it has flexibility and scalability. Good character and high stability.
  • CPLD Complex Programmable Logic Device
  • Application range of the invention Suitable for relaying and isolating MODBUS communication signals.
  • This design is a CPLD implementation of a MODBUS repeater. This approach increases the isolation characteristics of MODBUS communications.
  • This design uses a CPLD programmable device to detect the baud rate and encoding format of the MODBUS data frame. The parameters of the baud rate generator and the counter are used to control the enable signal of the RS485 transceiver.
  • the invention discloses a baud rate adaptation method, comprising the steps of: a) receiving first and second data; b) determining whether a falling edge of a synchronization code start bit of the first and second data is detected; c) if the falling edge is not detected, then return to step b; if the falling edge is detected, based on the reference clock, the first count starts from the rising edge after the start bit, and stops at the next falling edge to the first count Counting and getting the first count value; starting from the falling of the falling edge of the first count, stopping to the next rising edge Stopping the second count and obtaining the second count value; d) obtaining the baud rate according to the relationship between the first and second count values and the first threshold.
  • the invention also discloses a baud rate adaptive system, comprising: a first digital filter receiving first data from a first transceiver; a second digital filter receiving second data from a second transceiver; a frequency divider, outputting a reference clock to the first counter and the second counter according to the external crystal oscillator; the first counter, counting the first data and the second data based on the reference clock, and obtaining the first count value and the second count value; a baud rate detecting unit, receiving first data and second data from the first digital filter and the second digital filter, when detecting a falling edge of a start bit of the synchronization code of the first data and the second data The rising edge after the start bit starts to control the first counter to start the first counting, stops the first counting to the next falling edge, and obtains the first counting value; controls the first counter to start the second counting from the falling of the falling edge of the first counting.
  • the present invention also provides a baud rate adaptive Modbus repeater comprising the above described baud rate adaptive system.
  • the invention uses the CPLD technology because the logic operation of the CPLD is completed by hardware, which is much faster than the MCU, and the communication delay is small, and has good flexibility.
  • the baud rate and the encoding format of the MODBUS data frame are remotely detected by the CPLD, and the manual setting of the baud rate and the encoding format is not required locally.
  • the invention can realize the remote automatic detection function of the baud rate and the encoding format. Eliminate the material and assembly costs of rotary encoders. DRAWINGS
  • Figure 1 schematically shows an application environment of a Modbus repeater
  • FIGS. 2 and 3 are schematic diagrams showing a method of extracting a code stream rate and an encoding method from a synchronization frame; 4 is a flow chart showing a baud rate adaptive method according to an embodiment of the present invention; FIG. 5 is a block diagram showing an implementation of a baud rate adaptive system according to an embodiment of the present invention; A flowchart of the operation of the baud rate generator according to an embodiment of the present invention; and FIG. 7 schematically shows a baud rate adaptive system (ie, a Modbus repeater) according to an embodiment of the present invention. A physical map of the chip implementation. detailed description
  • the present invention is characterized in that a synchronization frame is used to implement an automatic detection function of a baud rate and an encoding format.
  • This design uses an external crystal oscillator OSC as the reference clock input. This reference clock is used for the counter input to further control the automatic detection of the baud rate.
  • the MODBUS master initially sends a sync frame, and the CPLD 102 detects its start bit and baud rate to determine the output of the baud rate generator.
  • the baud rate generator controls the enable signals of the RS485 transceivers 101 and 103 through the output of the other counter.
  • the design has a short detection time, high efficiency and good stability.
  • Figure 1 schematically shows the application environment of a Modbus repeater.
  • data DO and D1 from RS485 networks 1 and 2 are input to RS485 transceivers 101 and 103, respectively.
  • Data input 1 and data input 2 are MODBUS communication signals from RS485 transceivers 101 and 103.
  • the Modbus repeater 102 generates the enable signal 1 and the enable signal 2 based on the data input 1 and the data input 2 from the RS485 transceivers 101 and 103, and outputs them to the RS485 transceivers 101 and 103, respectively, to control them. That is, data input 1 and data input 2 input to Modbus repeater 102 are used to generate an enable signal.
  • the data input 1 from the RS485 transceiver 101 and the data input 2 from the RS485 transceiver 103 are also input to the RS485 transceiver 103 and the RS485 transceiver 101, respectively, for providing an actual data path.
  • FIGS. 2 and 3 schematically show schematic diagrams of a method of extracting a code stream rate and encoding method from a sync frame.
  • Tc is the time of one bit.
  • T1 is the time of the high level bit.
  • T2 is a low level bit.
  • Tl + T2 ⁇ 6 bits can be set to improve the accuracy of the baud rate detection.
  • Tl + T2 6 bits are set.
  • T1 + T2 is not limited to the 6 bits shown here.
  • the baud rate is determined according to the value of T1+T2.
  • the specific method is as follows:
  • the count period is C1 from the rising edge and the Tosc period from the rising edge.
  • the count value is C2;
  • C1+C2 is linear with the value of T1+T2
  • the value of C1-C2 is linear with the value of T1-T2
  • Tosc is the period of the basic clock signal (from the crystal oscillator OSC).
  • the threshold Cth By calculating the ratio of the different baud rates of the MODBUS input data from the RS485 transceivers 101 and 103 to the Tosc (basic clock signal), the threshold Cth can be obtained.
  • Cth reflects the ratio of different baud rates to Tosc, different waves. The rate corresponds to a different Cth value.
  • a known correspondence table of baud rates and thresholds according to the prior art can be employed by those skilled in the art. Considering that there is actually a certain error, this ratio can be fixed in the register of the CPLD.
  • the baud rate of the data can be determined by comparing the relationship between C1+C2 and Cth.
  • C1-C2 reflects the specific coding method:
  • Cenc is the default value corresponding to the specific coding method, that is, the last column in Table 1.
  • FIG. 4 is a flow chart showing a baud rate adaptation method in accordance with an embodiment of the present invention.
  • data input 1 and data input 2 from RS485 network 1 and RS485 network 2 are filtered in steps 401 and 402, respectively.
  • step 403 the filtered data input 1 and the data input 2 are ANDed.
  • step 404 it is determined whether the data outputted by step 403 is a falling edge, that is, it is determined in step 404 whether it is the falling edge of the start bit of the data synchronization code transmitted by the system. If not, proceed to step 403 to make a decision on the falling edge. If it is judged to be a falling edge, the process proceeds to step 405, and the first count is started at the rising edge after the start bit until the next falling edge occurs, the counting is stopped, and the count result Cl is obtained. At step 406, the second count is started from the falling edge of the count stop described above, until the next rising edge occurs, the count is stopped, and the count result C2 is obtained.
  • step 407 the relationship between C1+C2 and the threshold Cth is compared. And in step 408, the corresponding baud rate is obtained by the conditional selection statement.
  • the baud rate values corresponding to the relationship between C1+C2 and the threshold Cth are known and can be defined by the user.
  • step 409 the relationship between C1-C2 and Cenc is compared. And in step 410, the corresponding encoding mode is obtained by the conditional selection statement.
  • the coding mode corresponding to the relationship between C1-C2 and the threshold Cenc is known and can be defined by the user himself.
  • CI - C2 Cenc. Therefore, in combination with FIG. 3, step 409 and step 410, the coding method can be obtained by using the prior art. Therefore, the correspondence between them will not be described here.
  • FIG. 5 is a schematic block diagram showing an implementation of a baud rate adaptive system in accordance with an embodiment of the present invention.
  • the baud rate adaptive system of the embodiment of the present invention corresponds to the Modbus repeater 102 of FIG.
  • the baud rate adaptive system includes: digital filters 501 and 502, a frequency divider 503, a baud rate detecting unit 504, a baud rate generator 505, a counter 1 506, a counter 2 507, and an output. Control unit 508.
  • the accuracy of the code stream rate detection is ensured, and the MODBUS data input 1 from the RS485 transceiver 101 and the MODBUS data input 2 from the RS485 transceiver 103 are respectively digital. Filter processing.
  • several basic clock signal delays may be introduced without affecting system performance.
  • Digital filters 501 and 502 perform digital filtering processing on MODBUS data input 1 from RS485 transceiver 101 and MODBUS data input 2 from RS485 transceiver 103, respectively.
  • the baud rate detection unit 504 receives the filtered data 1 and data 2 from the digital filters 501 and 502. When the falling edge of the sync code start bit of data 1 and data 2 is detected, the baud rate detecting unit 504 controls the counter 1 506 to start counting from the rising edge after the start bit, and stops to the next falling edge of the data.
  • Cec gets the baud rate and encoding.
  • the detected baud rate and encoding mode are controlled from the start bit of each character of the MODBUS signal (data input 1 and data input 2) from the RS485 transceiver (ie, the start bit of the actual data sent by the system).
  • the output control unit 508 outputs an enable signal, and then counts by the counter 2, and the count value corresponds to the ratio of the time of one character corresponding to the baud rate and the encoding mode obtained by the baud rate detecting unit 504 to the basic clock Tosc. After the threshold value Cth2, the enable signal output of the output control unit 508 is turned off, thereby controlling the data output of the RS485 transceiver, thereby realizing the purpose of data relay.
  • the output control unit 508 When it is judged that the falling edge of the start counter 2 507 count comes from the first data, the output control unit 508 activates only the enable signal 1; when it is judged that the falling edge of the start counter 2 507 count comes from the second data, the output control unit 508 only activates Can signal 2. The output control unit disables the enable signal based on the comparison of the count value from the counter 2 507 with the threshold value Cth2.
  • Figure 6 is a flow chart showing the operation of the baud rate generator in accordance with an embodiment of the present invention.
  • steps 601 and 602 data input 1 and data input 2 from RS485 network 1 and RS485 network 2 are filtered, respectively.
  • step 603 the filtered data input 1 and the data input 2 are ANDed.
  • step 604 it is judged whether the data outputted in step 603 is a falling edge. That is, it is determined in step 604 whether it is the falling edge of the start bit of the actual data transmitted by the system. If not, proceed to step 604 to make a decision on the falling edge. If it is judged to be a falling edge, then step 605 is entered to start counter 2 507 for counting, and if the falling edge is from data input 1, the enable signal 1 is enabled; if the falling edge is from data input 2, the enable signal 2 is enabled.
  • step 606 after the count value of the counter 2 reaches the threshold value Cth2 corresponding to the baud rate detected by the baud rate detecting unit 504, the enable signals 1 and 2 are turned off.
  • the baud rate obtained by the baud rate detecting unit 504 and the ratio of the time of one character corresponding to the encoding mode and the basic clock Tosc can be regarded as Threshold Cth2.
  • the enable signal 1 and the enable signal 2 are mutually exclusive relationships for controlling the data output of the RS485 transceiver.
  • Figure 7 is a schematic illustration of a physical map of a baud rate adaptive system (i.e., Modbus repeater) chip implementation in accordance with an embodiment of the present invention.
  • baud rate adaptive system i.e., Modbus repeater
  • the invention uses the CPLD technology because the logic operation of the CPLD is completed by hardware, which is much faster than the MCU, and the communication delay is small, and has good flexibility.

Description

一种波特率自适应的 Modbus中继器和波特率自适应系统及方法 技术领域
本发明涉及一种波特率自适应系统及方法和 Modbus 中继器, 更具体地 说, 涉及一种波特率自适应的 Modbus中继器实现。 背景技术
Modbus是由美国 M0DIC0N公司最早提出的一种现场总线标准。 现有的 MODBUS 中继器采用旋转编码器来手工设置 MODBUS通信的波特率和编码 格式, 不能满足客户的远程控制需要, 不能实现远程自动检测功能, 且手工 操作不方便。
针对现有技术中存在的上述问题, 提出了本发明。 发明内容
本发明的另外方面和优点部分将在后面的描述中阐述, 还有部分可从描 述中明显地看出, 或者可以在本发明的实践中得到。
本设计方案使用复杂可编程逻辑器件 (Complex Programmable Logic Device, CPLD ) 和外部晶振来控制 MODBUS通信的中继, 能够自动检测 MODBUS数据帧的波特率和编码格式, 而且具有灵活性好, 可扩展性好, 稳 定性高等特点。
本发明的技术范围: MODBUS通信。
本发明的应用范围: 适用于 MODBUS通信信号的中继和隔离。
本设计方案为一种 MODBUS 中继器的 CPLD 实现方法。 该方法增加了 MODBUS通信的隔离特性。 本设计使用 CPLD可编程器件检测 MODBUS数 据帧的波特率和编码格式, 通过调整波特率发生器的参数和计数器来控制 RS485收发器的使能信号。
本发明公开了一种波特率自适应方法, 包括步骤: a)接收第一和第二数 据; b)判断是否检测到所述第一和第二数据的同步码起始位的下降沿; c)如 果未检测到所述下降沿, 则返回步骤 b; 如果检测到所述下降沿, 则基于基准 时钟, 从起始位后的上升沿开始第一计数, 到下一下降沿停止第一计数, 并 得到第一计数值; 从停止第一计数的下降沿开始第二计数, 到下一上升沿停 止第二计数, 并得到第二计数值; d)根据第一和第二计数值与第一阔值的关 系得到波特率。
本发明还公开了一种波特率自适应系统, 包括: 第一数字滤波器, 接收 来自第一收发器的第一数据; 第二数字滤波器, 接收来自第二收发器的第二 数据; 分频器, 根据外部晶振向第一计数器和第二计数器输出基准时钟; 第 一计数器, 基于基准时钟, 对第一数据和第二数据进行计数, 并得到第一计 数值和第二计数值; 波特率检测单元, 从第一数字滤波器和第二数字滤波器 接收第一数据和第二数据, 当检测到第一数据和第二数据的同步码起始位的 下降沿时, 从起始位后的上升沿开始控制第一计数器开始第一计数, 到下一 下降沿停止第一计数, 并得到第一计数值; 从停止第一计数的下降沿开始控 制第一计数器开始第二计数, 到下一上升沿为止, 并得到第二计数值; 根据 第一计数值和第二计数值与第一阔值的关系得到波特率; 第二计数器, 基于 基准时钟, 对第一数据和第二数据进行第三计数, 并得到第三计数值; 波特 率发生器, 根据波特率检测单元检测的波特率和编码方式以及第一和第二数 据, 对输出控制单元和第二计数器进行控制; 输出控制单元, 根据第二计数 器和波特率发生器的控制, 输出第一使能信号和第二使能信号。
本发明还提供一种波特率自适应的 Modbus中继器, 包括上述的波特率自 适应系统。
本发明使用 CPLD技术, 是因为 CPLD的逻辑运算是通过硬件完成的, 远比 MCU的速度快, 带来的通讯延时很小, 具有很好的灵活性。
根据本发明的采用 CPLD远程检测 MODBUS数据帧的波特率和编码格 式, 不需要在本地进行波特率和编码格式的手工设置。
本发明能够实现波特率和编码格式的远程自动检测功能。 省去旋转编码 器的材料和装配成本。 附图说明
通过结合附图对本发明的优选实施例进行详细描述, 本发明的上述和其 他目的、 特性和优点将会变得更加清楚, 其中相同的标号指定相同结构的单 元, 并且在其中:
图 1示意性地示出了 Modbus中继器的应用环境;
图 2和图 3示意性地示出了从同步帧中提取码流速率和编码方式的方法的 示意图; 图 4示出了才艮据本发明实施例的波特率自适应方法的流程图; 图 5示意性地示出了根据本发明实施例的波特率自适应系统的实现框图; 图 6示出了才艮据本发明实施例的波特率发生器的工作原理流程图; 以及 图 7 示意性地示出了根据本发明实施例的波特率自适应系统 (即, Modbus中继器) 芯片实现的实物图。 具体实施方式
下面将参照示出本发明实施例的附图充分描述本发明。 然而, 本发明可 以以许多不同的形式实现, 而不应当认为限于这里所述的实施例。 相反, 提 供这些实施例以便使本公开透彻且完整, 并且将向本领域技术人员充分表达 本发明的范围。 在附图中, 为了清楚起见放大了组件。
应当理解, 当称 "元件" "连接到" 或 "耦接" 到另一元件时, 它可以 是直接连接或耦接到另一元件或者可以存在中间元件。 相反, 当称元件 "直 接连接到" 或 "直接耦接到" 另一元件时, 不存在中间元件。 相同的附图标 记指示相同的元件。 这里使用的术语 "和 /或" 包括一个或多个相关列出的项 目的任何和所有组合。
应当理解, 尽管这里可以使用术语第一、 第二、 第三等描述各个元件、 组件和 /或部分, 但这些元件、 组件和 /或部分不受这些术语限制。 这些术语仅 仅用于将元件、 组件或部分相互区分开来。 因此, 下面讨论的第一元件、 组 件或部分在不背离本发明教学的前提下可以称为第二元件、 组件或部分。
这里使用的术语仅仅是为了描述特定实施例的目的, 而并不意图限制本 发明。 这里使用的单数形式 "一" 、 "一个" 和 "那 (这个) " 也意图包含 复数形式, 除非上下文中明确地指出不包含。 应当理解, 术语 "包括" 当用 在本说明书中时指示所述特征、 整数、 步骤、 操作、 元件和 /或组件的存在, 但并不排除一个或多个其他特征、 整数、 步骤、 操作、 元件、 组件和 /或其组 合的存在或添加。
本发明的特征在于使用同步帧来实现波特率和编码格式的自动检测功 能。
1 : 本设计采用外部晶振 OSC作为基准时钟输入。 该基准时钟用于计数器 输入, 进一步控制波特率的自动检测。
2: MODBUS主设备初始发出同步帧, CPLD 102会检测出其起始位和波 特率, 从而确定波特率发生器的输出。 3: 波特率发生器通过另一计数器的输出控制 RS485收发器 101和 103的 使能信号。
本设计能够增强现有产品(MODBUS中继器)的特性和功能。
该设计方案的检测时间短, 效率高, 具有很好的稳定性。
可以采用 VHDL或 Verilog语言仿真。 以及门级仿真。
图 1示意性地示出了 Modbus中继器的应用环境。
如图 1所示, 来自 RS485网络 1和 2的数据 DO和 D1分别输入到 RS485 收发器 101和 103。 数据输入 1和数据输入 2是来自 RS485收发器 101和 103 的 MODBUS通讯信号。 Modbus中继器 102才艮据来自 RS485收发器 101和 103的数据输入 1和数据输入 2生成使能信号 1和使能信号 2, 并分别输出到 RS485收发器 101和 103以对其进行控制。 即, 输入到 Modbus中继器 102的 数据输入 1和数据输入 2用于产生使能信号。
同时, 如图 1所示, 来自 RS485收发器 101的数据输入 1和来自 RS485 收发器 103的数据输入 2还分别输入到 RS485收发器 103和 RS485收发器 101 用于提供实际的数据通路。
图 2和图 3示意性地示出了从同步帧中提取码流速率和编码方式的方法的 示意图。
如图 2所示, Tc是一个比特位的时间。 T1是高电平比特位的时间。 以及 T2是低电平比特位的时间。
可以设置 Tl+T2≥6比特, 以提高波特率检测的准确性, 在本例中, 设置 Tl+T2=6比特。 但本领域技术人员应该理解, T1+T2并不限于此处所示的 6比 特。
在本文中, 以五种编码方式的检测为例进行说明, 而忽略了其它组合。 但本领域技术人员应该理解, 根据实际需要, 也可以取 T1和 Τ2的现有的组 合方式。
例如, 如表 1所示, 可以取 T1和 Τ2的以下五种可能的组合方式:
Tl + T2 = 6比特
Τ 代码 编码方式
形 Τ2
1
10比特: 没有校验位、 停止位
A 5比特 1比特 1000 001X
为 1比特
B 4比特 2比特 1100 001X 11 比特: 有校验位、 停止位为 1比特
11 比特: 没有校验位、 停止位 c 3比特 3比特 1110 001X
为 2比特
12比特: 有校验位、 停止位为
D 2比特 4比特 1111 001X 2 比特 (非标准 MODBUS格
式)
其它非标准格式
E 1比特 5比特 1111 101X
(禁止使能信号)
表 1
才艮据 T1+T2的值来确定波特率, 具体方法如下:
在起始位后, T1时间段内从上升沿开始以 Tosc为周期进行计数, 计数值 为 C1 ;
T2时间段内从下降沿开始以 Tosc为周期进行计数, 计数值为 C2;
其中, C1+C2的值与 T1+T2的值成线性关系; C1-C2的值与 T1-T2的值 成线性关系; 并且, Tosc是基本时钟信号的周期(来自于晶振 OSC ) 。
通过计算来自 RS485收发器 101和 103的 MODBUS输入数据的不同波特 率对应于 Tosc (基本时钟信号) 的比值可以得到阔值 Cth, Cth反映的是不同 波特率对应于 Tosc的比值, 不同波特率对应有不同的 Cth值。 本领域技术人 员可以采用根据现有技术的波特率和阔值的已知对应表。 考虑到实际存在一 定的误差, 可以把这种比值固定在 CPLD 的寄存器中。 从而, 通过比较 C1+C2与 Cth的关系就可以确定数据的波特率。
在图 3中所示的 C1+C2与 Cth的关系为: Cl+C2=6*Cth。
另外, 从表 1可以看出, C1-C2的值反映了具体的编码方式:
CI - C2 = Cenc
Cenc为具体的编码方式所对应的预设值, 即表 1中最后一列。
此处, 通过 C1+C2与 Cth的关系以及通过 C1-C2与 Cenc的关系来得到波 特率和编码方式的具体方法并非本发明的要点, 属于现有技术, 因此, 在此 将省略对其的详细描述。
图 4示出了才艮据本发明实施例的波特率自适应方法的流程图。
如图 4所示, 在步骤 401和 402分别对来自 RS485网络 1和 RS485网络 2 的数据输入 1和数据输入 2进行滤波。
在步骤 403 , 对经过滤波的数据输入 1和数据输入 2进行与运算。 在步骤 404 , 判断步骤 403输出的数据是否是下降沿, 即, 在步骤 404判 断是否是系统发送的数据同步码的起始位下降沿。 如果不是, 则继续执行步 骤 403进行下降沿的判断。 如果判断是下降沿, 则进入步骤 405 , 在起始位后 的上升沿开始执行第一计数, 直到下一个下降沿出现为止, 停止计数, 并得 到计数结果 Cl。 在步骤 406, 从上述计数停止的下降沿开始进行第二计数, 直到下一个上升沿出现为止, 停止计数, 并得到计数结果 C2。
在步骤 407 , 比较 C1+C2与阔值 Cth的关系。 并在步骤 408 , 通过条件选 择语句得到对应的波特率。 结合图 3的相关描述可知, C1+C2与阔值 Cth的关 系所对应的波特率值是已知的, 且可由用户自己定义。 在图 3 中所示的 C1+C2与 Cth的关系就是 Cl+C2=6*Cth。 因此, 结合图 3 , 步骤 407和步骤 408采用现有技术可以得到波特率。 因而, 在此对其对应关系不再赘述。
在步骤 409, 比较 C1-C2与 Cenc的关系。 并在步骤 410, 通过条件选择 语句得到对应的编码方式。 结合图 3的相关描述可知, C1-C2与阔值 Cenc的 关系所对应的编码方式是已知的, 且可由用户自己定义。 CI - C2 = Cenc。 因 此, 结合图 3 , 步骤 409和步骤 410采用现有技术可以得到编码方式。 因而, 在此对其对应关系不再赘述。
图 5示意性地示出了才艮据本发明实施例的波特率自适应系统的实现框图。 本发明实施例的波特率自适应系统对应于图 1中 Modbus中继器 102。
如图 5所示, 波特率自适应系统包括: 数字滤波器 501和 502、 分频器 503、 波特率检测单元 504、 波特率发生器 505、 计数器 1 506、 计数器 2 507、 以及输出控制单元 508。
首先, 考虑到通讯线路存在一定的干扰, 为了防止误判, 保证码流速率 检测的准确性, 分别对于来自 RS485收发器 101的 MODBUS数据输入 1以及 来自 RS485收发器 103的 MODBUS数据输入 2进行数字滤波处理。
在本例中的数字滤波, 例如可以通过基本时钟信号对数据输入 1和数据输 入 2 进行 采样 处 理 , 在 满 足 规 定 的 情 况 下 ( 例 如 , Sample l=Sample2=Sample3.. ) 才认为输入低电平有效。 此处, 可能会引入几 个基本时钟信号的延时, 但不影响系统性能。
数字滤波器 501和 502分别对于来自 RS485收发器 101的 MODBUS数据 输入 1 以及来自 RS485收发器 103的 MODBUS数据输入 2进行数字滤波处 理。 波特率检测单元 504从数字滤波器 501和 502接收经滤波的数据 1和数据 2。 当检测到数据 1 和数据 2的同步码起始位的下降沿时, 波特率检测单元 504控制计数器 1 506从起始位后的上升沿开始计数, 到所述数据的下一下降 沿停止计数, 并得到计数值 C1 ; 并控制计数器 1 506从停止计数的下降沿开 始再次计数, 到下一上升沿为止, 并得到计数值 C2; 根据计数值 C1 和计数 值 C2与阔值 Cth和阔值 Cenc的关系得到波特率和编码方式。 中检测出来的波特率和编码方式, 从来自 RS485收发器的 MODBUS信号(数 据输入 1和数据输入 2 )的每个字符起始位(即, 系统发送的实际数据的起始 位)开始控制输出控制单元 508输出使能信号, 再通过计数器 2进行计数, 在 计数值达到与波特率检测单元 504所得出的波特率和编码方式对应的一个字符 的时间和基本时钟 Tosc的比值所对应的阔值 Cth2之后, 关闭输出控制单元 508的使能信号输出, 从而控制 RS485收发器的数据输出, 实现了数据中继的 目的。
当判断启动计数器 2 507计数的下降沿来自第一数据时, 输出控制单元 508仅启动使能信号 1 ; 当判断启动计数器 2 507计数的下降沿来自第二数据 时, 输出控制单元 508仅启动使能信号 2。 输出控制单元根据来自计数器 2 507的计数值与阔值 Cth2的比较来禁止使能信号。
波特率发生器 505、 计数器 2 507以及输出控制单元 508的工作原理流程 图将参考图 6给出。
图 6示出了才艮据本发明实施例的波特率发生器的工作原理流程图。
如图 6所示, 在步骤 601和 602, 分别对来自 RS485网络 1和 RS485网络 2的数据输入 1和数据输入 2进行滤波。
在步骤 603 , 对经过滤波的数据输入 1和数据输入 2进行与运算。
在步骤 604 , 判断步骤 603输出的数据是否是下降沿。 即, 在步骤 604判 断是否是系统发送的实际数据的起始位下降沿。 如果不是, 则继续执行步骤 604进行下降沿的判断。 如果判断是下降沿, 则进入步骤 605 , 启动计数器 2 507进行计数, 并且如果下降沿来自数据输入 1 , 则启动使能信号 1 ; 如果下 降沿来自数据输入 2 , 则启动使能信号 2。
在步骤 606 , 当计数器 2的计数值达到波特率检测单元 504检测的波特率 所对应的阔值 Cth2之后, 关闭使能信号 1和 2。 波特率检测单元 504所得出 的波特率和编码方式对应的一个字符的时间和基本时钟 Tosc的比值可以视为 阈值 Cth2。 其中, 使能信号 1和使能信号 2是互斥关系, 用于控制 RS485收 发器的数据输出。
图 7 示意性地示出了根据本发明实施例的波特率自适应系统 (即, Modbus中继器) 芯片实现的实物图。
本发明使用 CPLD技术, 是因为 CPLD的逻辑运算是通过硬件完成的, 远比 MCU的速度快, 带来的通讯延时很小, 具有很好的灵活性。
虽然结合目前被认为是最实际和最优的实施例描述了本发明, 但本领域 附权利要 精神 ^和范畴之内包括的各种^羊的修改和等价结构。 '

Claims

权利要求
1. 一种波特率自适应方法, 包括步骤:
a)接收第一数据和第二数据;
b)判断是否检测到所述第一数据和第二数据的同步码起始位的下降沿; c)如果未检测到所述下降沿, 则返回步骤 b; 如果检测到所述下降沿, 则 基于基准时钟, 从起始位后的上升沿开始第一计数, 到下一下降沿停止第一 计数, 并得到第一计数值; 从停止第一计数的下降沿开始第二计数, 到下一 上升沿停止第二计数, 并得到第二计数值;
d)根据第一计数值和第二计数值与第一阔值的关系得到波特率。
2. 如权利要求 1 所述的波特率自适应方法, 进一步包括步骤: 根据第一 计数值和第二计数值与第二阔值的关系得到编码方式。
3. 如权利要求 1或 2所述的波特率自适应方法, 其中, 通过比较第一计 数值和第二计数值之和与第一阔值的关系, 根据已知波特率对应表得到波特 率。
4. 如权利要求 3所述的波特率自适应方法, 其中, 通过比较第一计数值 和第二计数值之差与第二阔值的关系, 根据已知编码方式对应表得到编码方 式。
5. 如权利要求 4所述的波特率自适应方法, 进一步包括步骤 f): 判断是 否检测到所述第一数据和第二数据的实际数据起始位的下降沿; 如果未检测 到下降沿, 则返回步骤 f; 如果检测到下降沿, 则基于基准时钟, 开始第三计 数; 同时, 若下降沿来自第一数据, 则输出第一使能信号; 若下降沿来自第 二数据, 则输出第二使能信号。
6. 如权利要求 5所述的波特率自适应方法, 进一步包括步骤 g): 当第三 计数值达到第三阔值之后, 禁止第一使能信号和第二使能信号。
7. 如权利要求 6所述的波特率自适应方法, 其中, 第一使能信号控制从 第一网络接收第一数据的第一收发器; 以及第二使能信号控制从第二网络接 收第二数据的第二收发器。
8. 如权利要求 7所述的波特率自适应方法, 其中, 第一阔值是不同波特 率与基本时钟信号的比值; 第二阔值是不同具体编码方式所对应的预设值; 以及第三阈值是与波特率检测单元所得出的波特率和编码方式对应的一个字 符的时间和基本时钟的比值。
9. 一种波特率自适应系统, 包括:
第一数字滤波器, 接收来自第一收发器的第一数据;
第二数字滤波器, 接收来自第二收发器的第二数据;
分频器, 根据外部晶振向第一计数器和第二计数器输出基准时钟; 第一计数器, 基于基准时钟, 对第一数据和第二数据进行计数, 并得到 第一计数值和第二计数值;
波特率检测单元, 从第一数字滤波器和第二数字滤波器接收第一数据和 第二数据, 当检测到第一数据和第二数据的同步码起始位的下降沿时, 从起 始位后的上升沿开始控制第一计数器开始第一计数, 到下一下降沿停止第一 计数, 并得到第一计数值; 从停止第一计数的下降沿开始控制第一计数器开 始第二计数, 到下一上升沿为止, 并得到第二计数值; 根据第一计数值和第 二计数值与第一阈值的关系得到波特率;
第二计数器, 基于基准时钟, 对第一数据和第二数据进行第三计数, 并 得到第三计数值;
波特率发生器, 根据波特率检测单元检测的波特率和编码方式以及第一 和第二数据, 对输出控制单元和第二计数器进行控制;
输出控制单元, 根据第二计数器和波特率发生器的控制, 输出第一使能 信号或第二使能信号。
10.如权利要求 9所述的波特率自适应系统, 其中所述波特率检测单元根 据第一计数值和第二计数值与第二阈值的关系得到编码方式。
11. 如权利要求 9或 10所述的波特率自适应系统, 其中, 波特率检测单 元通过比较第一计数值和第二计数值之和与第一阈值的关系, 根据已知波特 率对应表得到波特率。
12. 如权利要求 11所述的波特率自适应系统, 其中, 波特率检测单元通 过比较第一计数值和第二计数值之差与第二阈值的关系, 根据已知编码方式 对应表得到编码方式。
13. 如权利要求 12所述的波特率自适应系统, 其中, 波特率发生器判断 是否检测到所述第一数据和第二数据的实际数据起始位的下降沿; 当检测到 所述下降沿时, 控制第二计数器开始所述第三计数; 当判断启动第二计数器 计数的下降沿来自第一数据时, 所述输出控制单元输出第一使能信号; 当判 断启动第二计数器计数的下降沿来自第二数据时, 所述输出控制单元输出第 二使能信号。
14. 如权利要求 13所述的波特率自适应系统, 其中, 当检测到来自第二 计数器的第三计数值达到第三阔值时, 所述输出控制单元禁止第一使能信号 和第二使能信号的输出
15. 如权利要求 14所述的波特率自适应系统, 其中, 第一使能信号控制 从第一网络接收第一数据的第一收发器; 以及第二使能信号控制从第二网络 接收第二数据的第二收发器。
16. 如权利要求 15所述的波特率自适应系统, 其中, 第一阔值是不同波 特率与基本时钟信号的比值; 第二阔值是不同具体编码方式所对应的预设 值; 以及第三阔值是与波特率检测单元所得出的波特率和编码方式对应的一 个字符的时间和基本时钟的比值。
17. 一种波特率自适应的 Modbus中继器, 包括如权利要求 9-16的任何 一个所述的波特率自适应系统。
PCT/CN2011/082092 2010-11-12 2011-11-11 一种波特率自适应的modbus中继器和波特率自适应系统及方法 WO2012062219A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US13/884,877 US8929425B2 (en) 2010-11-12 2011-11-11 Modbus repeater with self-adaptive baud rate and self-adaptive baud rate system and method
EP11839438.6A EP2639704B1 (en) 2010-11-12 2011-11-11 Modbus repeater with self-adaptive baud rate and self-adaptive baud rate system and method

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201010541710.7 2010-11-12
CN201010541710.7A CN102467477B (zh) 2010-11-12 2010-11-12 一种波特率自适应的Modbus中继器和波特率自适应系统及方法

Publications (1)

Publication Number Publication Date
WO2012062219A1 true WO2012062219A1 (zh) 2012-05-18

Family

ID=46050415

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/082092 WO2012062219A1 (zh) 2010-11-12 2011-11-11 一种波特率自适应的modbus中继器和波特率自适应系统及方法

Country Status (4)

Country Link
US (1) US8929425B2 (zh)
EP (1) EP2639704B1 (zh)
CN (1) CN102467477B (zh)
WO (1) WO2012062219A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954211A (zh) * 2014-03-27 2015-09-30 江西飞尚科技有限公司 基于rs485工业总线的接入设备智能识别系统

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103036823B (zh) * 2012-12-14 2015-06-17 中船重工(武汉)凌久电子有限责任公司 基于fpga的波特率快速自适应方法、处理器及接收端
JP6456649B2 (ja) * 2014-10-10 2019-01-23 日本電産サンキョー株式会社 電子機器装置、及びシリアル通信速度調整方法
CN104714920B (zh) * 2015-02-13 2017-08-08 暨南大学 一种自适应波特率的信号接收方法
CN105959093B (zh) * 2016-04-25 2019-02-12 成都大学 一种串行通信波特率实时自适应方法
CN106326156B (zh) * 2016-08-30 2024-04-05 西安翔腾微电子科技有限公司 基于自适应波特率的单端口通信处理电路和方法
CN107996021B (zh) * 2016-10-18 2020-11-17 深圳配天智能技术研究院有限公司 一种数据处理方法及基站设备
CN108255767B (zh) * 2016-12-29 2020-05-15 广州立功科技股份有限公司 射频读卡器与主机的串行通信方法和系统
US10271381B2 (en) 2017-05-22 2019-04-23 Honeywell International Inc. Legacy Modbus communication devices
CN108170630B (zh) * 2017-12-28 2021-02-02 杭州万高科技股份有限公司 一种串口通信波特率自适应方法、系统及设备
WO2020024199A1 (en) * 2018-08-02 2020-02-06 Texas Instruments Incorporated High speed flexled digital interface
US11561534B2 (en) 2018-08-06 2023-01-24 Siemens Aktiengesellschaft Adaptive repeater for industrial communication
WO2020029023A1 (zh) * 2018-08-06 2020-02-13 深圳市汇顶科技股份有限公司 波特率校准电路及串口芯片
WO2020066207A1 (ja) * 2018-09-27 2020-04-02 日本電産株式会社 信号送受信方法
CN110413558A (zh) * 2019-07-15 2019-11-05 广芯微电子(广州)股份有限公司 一种实现低功耗串口模块动态分频方法
CN112039635B (zh) * 2020-08-28 2023-06-20 杭州万高科技股份有限公司 一种基于rc振荡器的uart波特率自适应方法、装置
CN112255553B (zh) * 2020-09-18 2024-03-05 北京汽车股份有限公司 用于检测电池分子衰变的芯片、电池活性保护系统及方法
CN112165525B (zh) * 2020-09-28 2023-12-08 北京视界恒通科技有限公司 一种串行数据透传方法及装置
CN113820971B (zh) * 2021-08-17 2023-06-06 广东智科电子股份有限公司 一种隔离中继器及其控制方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030202572A1 (en) * 2002-04-30 2003-10-30 Ads Dsl Systems, Inc. Determining speed of a digital signal in a serial transmission line
US7340023B1 (en) * 2002-10-31 2008-03-04 Zilog, Inc. Auto baud system and method and single pin communication interface
CN101399635A (zh) * 2008-09-28 2009-04-01 中兴通讯股份有限公司 通讯波特率自适应方法、装置以及主机
CN101551786A (zh) * 2009-05-05 2009-10-07 大连理工大学 波特率自适应串行通信中继器的制作方法
CN101626288A (zh) * 2009-08-10 2010-01-13 中国航空工业集团公司洛阳电光设备研究所 带有波特率检测设置功能的uart装置及其检测设置方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030202572A1 (en) * 2002-04-30 2003-10-30 Ads Dsl Systems, Inc. Determining speed of a digital signal in a serial transmission line
US7340023B1 (en) * 2002-10-31 2008-03-04 Zilog, Inc. Auto baud system and method and single pin communication interface
CN101399635A (zh) * 2008-09-28 2009-04-01 中兴通讯股份有限公司 通讯波特率自适应方法、装置以及主机
CN101551786A (zh) * 2009-05-05 2009-10-07 大连理工大学 波特率自适应串行通信中继器的制作方法
CN101626288A (zh) * 2009-08-10 2010-01-13 中国航空工业集团公司洛阳电光设备研究所 带有波特率检测设置功能的uart装置及其检测设置方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954211A (zh) * 2014-03-27 2015-09-30 江西飞尚科技有限公司 基于rs485工业总线的接入设备智能识别系统

Also Published As

Publication number Publication date
EP2639704A1 (en) 2013-09-18
US20130259095A1 (en) 2013-10-03
US8929425B2 (en) 2015-01-06
CN102467477B (zh) 2014-10-15
EP2639704B1 (en) 2018-08-29
CN102467477A (zh) 2012-05-23
EP2639704A4 (en) 2017-01-18

Similar Documents

Publication Publication Date Title
WO2012062219A1 (zh) 一种波特率自适应的modbus中继器和波特率自适应系统及方法
CN103165169A (zh) 至 rf 通信装置的自适应等时usb 音频
EP2573975B1 (en) Method and device for selecting sampling clock signal
EP3309647B1 (en) Control device and communication device
KR20020028802A (ko) 상호접속된 서브-네트워크들간의 사이클 동기화
CN103116322B (zh) 微调可调振荡器以匹配can总线的方法及can总线通信控制器
CN106464559A (zh) 用于分布式控制系统的高速嵌入式协议
CN100538683C (zh) 用于控制总线系统的方法和设备以及相应的总线系统
CN105340223A (zh) 确定can总线连接单元的内部延迟时间的设备和测量方法
US10965442B2 (en) Low-power, low-latency time-to-digital-converter-based serial link
WO2021042100A1 (en) Interface for improved media access, and related systems, methods, and devices
KR20160146786A (ko) 멀티 심볼 워드들을 위한 동기화 방법
US8229038B2 (en) Transceiver apparatus, receiver and power saving method thereof
KR0147471B1 (ko) 데이터 전송속도 감지기능을 가진 이서네트
CN203722758U (zh) 一种用于分布式视频系统的同步装置
Hartwich Bit time requirements for can FD
JPH08221108A (ja) Plcのリモートi/oシステム
WO2018076682A1 (zh) 一种并行接口时序控制方法和装置
US20230281142A1 (en) Processing system, related integrated circuit, system and method
Wang et al. An FPGA based slave communication controller for Industrial Ethernet
KR20050033138A (ko) 캔 통신노드의 통신속도 설정방법
JP3690069B2 (ja) 光リピータ
JP2019176207A (ja) ネットワーク機器
CN116049072A (zh) 一种提高集成电路内置音频总线从机稳定性的装置及方法
KR100261574B1 (ko) 이더넷 통신장치

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11839438

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2011839438

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 13884877

Country of ref document: US