CN111882852B - Access detection circuit, method, master device and storage medium - Google Patents

Access detection circuit, method, master device and storage medium Download PDF

Info

Publication number
CN111882852B
CN111882852B CN202010678754.8A CN202010678754A CN111882852B CN 111882852 B CN111882852 B CN 111882852B CN 202010678754 A CN202010678754 A CN 202010678754A CN 111882852 B CN111882852 B CN 111882852B
Authority
CN
China
Prior art keywords
communication chip
signal
electronic switch
level signal
switch
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010678754.8A
Other languages
Chinese (zh)
Other versions
CN111882852A (en
Inventor
李晃忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Sundray Technologies Co ltd
Original Assignee
Shenzhen Sundray Technologies Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Sundray Technologies Co ltd filed Critical Shenzhen Sundray Technologies Co ltd
Priority to CN202010678754.8A priority Critical patent/CN111882852B/en
Publication of CN111882852A publication Critical patent/CN111882852A/en
Application granted granted Critical
Publication of CN111882852B publication Critical patent/CN111882852B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G08SIGNALLING
    • G08CTRANSMISSION SYSTEMS FOR MEASURED VALUES, CONTROL OR SIMILAR SIGNALS
    • G08C25/00Arrangements for preventing or correcting errors; Monitoring arrangements
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01DMEASURING NOT SPECIALLY ADAPTED FOR A SPECIFIC VARIABLE; ARRANGEMENTS FOR MEASURING TWO OR MORE VARIABLES NOT COVERED IN A SINGLE OTHER SUBCLASS; TARIFF METERING APPARATUS; MEASURING OR TESTING NOT OTHERWISE PROVIDED FOR
    • G01D21/00Measuring or testing not otherwise provided for
    • G01D21/02Measuring two or more variables by means not covered by a single other subclass
    • GPHYSICS
    • G08SIGNALLING
    • G08CTRANSMISSION SYSTEMS FOR MEASURED VALUES, CONTROL OR SIMILAR SIGNALS
    • G08C19/00Electric signal transmission systems

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Arrangements For Transmission Of Measured Signals (AREA)

Abstract

The invention discloses an access detection circuit, a method, a main device and a storage medium of a device, wherein the access detection circuit comprises: a microcontroller; the output end of the RS485 communication chip is connected with the microcontroller; two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch; the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the voltage difference obtained by detection, and the microcontroller judges whether the slave equipment is connected to the master equipment or not according to the received level signal. According to the invention, whether the slave equipment is connected with the master equipment or not is judged by outputting the corresponding level signal through the output end of the RS485 communication chip, and the access detection of the slave equipment is simpler and more accurate.

Description

Access detection circuit, method, master device and storage medium
Technical Field
The present invention relates to the field of access detection technologies, and in particular, to an access detection circuit, method, host device, and storage medium for a device.
Background
The acquisition host computer is generally connected with slave devices such as a temperature and humidity sensor through an RS485 communication interface so as to acquire data detected by the slave devices. When the slave device accesses, the acquisition host needs to know whether the slave device has accessed or not, and enables communication software after determining that the slave device accesses.
When detecting whether the slave device is accessed, usually, a sampling resistor is connected in series in an RS485 power supply circuit of the acquisition host, and after the slave device is accessed, sampling voltages are generated at two ends of the sampling resistor, and whether the slave device is accessed is determined by detecting the sampling voltages. However, the detection of the sampling resistor needs to be performed by an Analog-to-Digital Converter (ADC) in the acquisition host, which occupies a large amount of ADC resources.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide an access detection circuit, an access detection method, a master device and a storage medium of a device, and aims to output a corresponding level signal through an output end of an RS485 communication chip to judge whether a slave device is accessed to the master device.
In order to achieve the above object, the present invention provides an access detection circuit applied to a master device, the access detection circuit including:
a microcontroller;
the output end of the RS485 communication chip is connected with the microcontroller;
two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch;
the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the voltage difference obtained by detection, and the microcontroller judges whether the slave equipment is connected to the master equipment or not according to the received level signal.
Optionally, the output end of the RS485 communication chip is further connected to a fixed voltage through a pull-up resistor;
the two ends of the electronic switch at least comprise an output end and an input end, the output end of the electronic switch is connected to the first signal end of the RS485 communication chip and the grounding end of the main device, and the input end of the electronic switch is connected to the second signal end of the RS485 communication chip;
when the slave device is connected to the master device, the ground terminal of the slave device is connected to the input terminal of the electronic switch, the voltage corresponding to the ground terminal of the slave device is greater than the voltage corresponding to the ground terminal of the master device, the voltage difference between the two ends of the electronic switch is greater than the on-state voltage of the electronic switch, the RS485 communication chip outputs a low level signal to the microcontroller, and the microcontroller determines that the slave device is connected to the master device according to the low level signal.
Optionally, the output end of the RS485 communication chip is further connected to the ground end of the master device through a pull-down resistor;
the two ends of the electronic switch at least comprise an output end and an input end, the output end of the electronic switch is connected to the second signal end of the RS485 communication chip and the grounding end of the main device, and the input end of the electronic switch is connected to the first signal end of the RS485 communication chip;
when the slave device is connected to the master device, the ground terminal of the slave device is connected to the input terminal of the electronic switch, the voltage corresponding to the ground terminal of the slave device is greater than the voltage corresponding to the ground terminal of the master device, the voltage difference between the two ends of the electronic switch is greater than the on-state voltage of the electronic switch, the RS485 communication chip outputs a high-level signal to the microcontroller, and the microcontroller determines that the slave device is connected to the master device according to the high-level signal.
Optionally, the electronic switch is a diode, an anode of the diode is an input terminal of the electronic switch, and a cathode of the diode is an output terminal of the electronic switch.
Optionally, the access detection circuit further includes:
the RS485 communication chip is connected with the switch module, the switch module comprises a first connection state and a second connection state, when the switch module is in the first connection state, a first signal end of the RS485 communication chip is connected to the output end of the electronic switch through the switch module, and a second signal end of the RS485 communication chip is connected to the input end of the electronic switch through the switch module; when the switch module is in a second connection state, the first signal end of the RS485 communication chip is connected to a third signal end in the RS485 interface of the master device, the second signal end of the RS485 communication chip is connected to a fourth signal end in the RS485 interface of the master device, and the RS485 interface is used for connecting the slave device;
after the microcontroller detects that the slave device is connected to the master device, the microcontroller controls the switch module to be switched from the first connection state to the second connection state so as to be in communication connection with the slave device through the third signal end and the fourth signal end.
Optionally, the switch module includes a first single-pole double-throw switch and a second single-pole double-throw switch, a fixed end of the first single-pole double-throw switch is connected to the first signal end of the RS485 communication chip, an active end of the first single-pole double-throw switch selects to be connected to the output end of the electronic switch or the third signal end of the RS485 interface, a fixed end of the second single-pole double-throw switch is connected to the second signal end of the RS485 communication chip, and an active end of the second single-pole double-throw switch selects to be connected to the input end of the electronic switch or the fourth signal end of the RS485 interface.
In addition, to achieve the above object, the present invention further provides a master device, including the access detection circuit as described in any one of the above.
In addition, in order to achieve the above object, the present invention further provides an access detection method, where the access detection method is applied to a main device, the main device includes a microcontroller, an RS485 communication chip and an electronic switch, two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip, the RS485 communication chip is connected to the microcontroller, and the access detection method includes:
the microcontroller acquires a level signal output by the RS485 communication chip, wherein the level signal comprises a high level signal or a low level signal, and the RS485 communication chip outputs the corresponding level signal according to the detected voltage difference between two ends of the electronic switch;
and the microcontroller judges whether the slave equipment is connected to the master equipment or not according to the level signal.
Optionally, the step of judging, by the microcontroller, whether the slave device is connected to the master device according to the level signal includes:
and when the level signal is a low level signal, the microcontroller judges that the slave device is connected to the master device.
Optionally, the master device further includes a switch module, and after the step of determining, by the microcontroller, whether the slave device is connected to the master device according to the level signal, the method further includes:
when judging the slave equipment inserts when the master equipment, microcontroller control switch module switches to the second connection state from first connection state, wherein, when switch module is in first connection state, RS485 communication chip passes through switch module and is connected to electronic switch's both ends, when switch module is in the second connection state, RS485 communication chip passes through switch module and is connected to the RS485 interface of master equipment, the RS485 interface is used for connecting the slave equipment.
Optionally, after the step of determining, by the microcontroller, that the slave device accesses the master device when the level signal is a low level signal, the method further includes:
acquiring a level signal output by the RS485 communication chip;
when the level signal is a high level signal and the duration of the high level signal is longer than a preset duration, the microcontroller determines that the slave device does not access the master device and controls the switch module to switch from the second connection state to the first connection state.
In addition, to achieve the above object, the present invention further provides a storage medium having an access detection program stored thereon, wherein the access detection program, when executed by a processor, implements the steps of the access detection method as described in any one of the above.
The access detection circuit, the method, the main device and the storage medium of the device provided by the embodiment of the invention comprise: a microcontroller; the output end of the RS485 communication chip is connected with the microcontroller; two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch; the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the voltage difference obtained by detection, and the microcontroller judges whether the slave equipment is connected to the master equipment or not according to the received level signal. According to the invention, whether the slave equipment is connected with the master equipment or not is judged by outputting the corresponding level signal through the output end of the RS485 communication chip, and the access detection of the slave equipment is simpler and more accurate.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the structures shown in the drawings without creative efforts.
FIG. 1 is a circuit diagram of an access detection circuit according to an embodiment of the present invention;
FIG. 2 is a circuit diagram of another embodiment of an access detection circuit of the present invention;
FIG. 3 is a circuit diagram of an access detection circuit according to yet another embodiment of the present invention;
FIG. 4 is a circuit diagram of an access detection circuit according to another embodiment of the present invention;
FIG. 5 is a circuit diagram of an access detection circuit according to another embodiment of the present invention;
FIG. 6 is a circuit diagram of the switch module of the present invention in a first connection state;
FIG. 7 is a circuit diagram illustrating a switch module of the present invention in a second connection state;
fig. 8 is a flowchart illustrating an access detection method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that if directional indications (such as up, down, left, right, front, and back … …) are referred to in the embodiments of the present application, the directional indications are only used to explain the relative positional relationship between the components, the movement situation, and the like in a specific posture (as shown in the drawings), and if the specific posture is changed, the directional indications are changed accordingly.
In addition, if there is a description of "first", "second", etc. in the embodiments of the present application, the description of "first", "second", etc. is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present application.
RS 485: two communication lines are used, generally denoted a and B, or D + and D-. The RS485 bus standard specifies the electrical characteristic standard of the bus interface, i.e. the definition of 2 logic states: a logic "1" is represented by a voltage difference between two wires of + (2-6) V, and a logic "0" is represented by a voltage difference between two wires of- (2-6) V, which is a typical differential communication.
Differential signaling: differential transmission is a signal transmission technology, and is different from the traditional method of one signal wire and one ground wire, wherein the differential transmission transmits signals on the two wires, and the two signals have the same amplitude and opposite phases. The signals transmitted on these two wires are differential signals. The signal receiving end compares the difference value of the two voltages to judge the logic state sent by the sending end.
In an embodiment of the present application, please refer to fig. 1, the access detection circuit is applied to a host device, and the access detection circuit includes a microcontroller, an RS485 communication chip, and an electronic switch. The output end of the RS485 communication chip is connected with the microcontroller; the two ends of the electronic switch are bridged between the first signal end and the second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch, the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the detected voltage difference, and the microcontroller judges whether the slave device is connected to the master device or not according to the received level signal.
In this embodiment, the master device is generally a data acquisition host, and the slave devices are acquisition devices such as a temperature and humidity sensor, an infrared remote controller, a commercial power detection module, and an audible and visual alarm. An RS485 communication chip is arranged in the master device, and the slave device can be accessed into the master device through an RS485 interface.
Data acquisition refers to the process of automatically acquiring information from analog and digital units under test, such as sensors and other devices under test. The data acquisition host is usually used for monitoring the power environment of the machine room, and can receive the data acquired by the front-end sensor, so that the real-time monitoring and management of the environmental temperature, humidity, air conditioner, water immersion, smoke sensation, power supply and other equipment of the machine room are realized. At present, data acquisition is performed between a data acquisition host and slave devices such as a front-end sensor, and mainly adopts a wired communication mode, for example, an RS485 communication mode.
In this embodiment, the RS485 communication chip includes an output terminal R0, a first signal terminal a, and a second signal terminal B. The first signal end A and the second signal end B are used for receiving differential signals, differential transmission is a signal transmission technology, and is different from the traditional method of one signal line and one ground wire, the differential transmission transmits signals on the two lines, the amplitudes of the two signals are the same, the phases of the two signals are opposite, the signals transmitted on the two lines are the differential signals, and the signal transmission lines connected with the first signal end and the second signal end of the RS485 communication chip are usually two lines which are equal in length, equal in width, close to each other and on the same layer. The RS485 communication chip can control the output end R0 to output a corresponding level signal according to the voltage difference between the first signal end A and the second signal end B. On a circuit board, the differential traces must be two lines that are equal in length, equal in width, closely adjacent, and on the same plane. Based on the characteristic of the RS485 communication chip, the voltage difference V of the differential signalABWhen the voltage is more than 0.2V, the output end R0 outputs a high-point flat signal, and the voltage difference V of the differential signal is larger thanABWhen < -0.2V, the output end R0 outputs low level signal, so thatAnd whether the slave equipment is connected with the master equipment or not can be judged by outputting a corresponding level signal through the output end of the RS485 communication chip. It should be noted that, this differential characteristic of the RS485 communication chip itself is generally used for transmitting data, and this embodiment uses the differential characteristic for transmitting data for access detection of the slave device, so that the access detection is simpler and more accurate.
In this embodiment, when the slave device accesses the master device, the master device supplies power to the slave device through the power supply line, the electronic switch is turned on, the voltage difference between the two ends of the electronic switch changes, because the two ends of the electronic switch are bridged between the first signal end and the second signal end of the RS485 communication chip, the RS485 communication chip can detect the change of the voltage difference between the two ends of the electronic switch, and output a corresponding level signal according to the changed voltage difference, the controller judges whether the slave device accesses the master device according to the level signal, and the access detection is simpler, more convenient and more accurate without occupying ADC resources.
Referring to fig. 2, in an embodiment, the output terminal of the RS485 communication chip is connected to a fixed voltage through a pull-up resistor R1, the two terminals of the electronic switch at least include an output terminal and an input terminal, the output terminal of the electronic switch is connected to the first signal terminal a of the RS485 communication chip, the output terminal of the electronic switch is connected to the ground terminal of the host device, and the input terminal of the electronic switch is connected to the second signal terminal B of the RS485 communication chip. When no slave device is connected to the master device, the electronic switch is not turned on, the voltage difference between two ends of the electronic switch is 0, the output end R0 of the RS485 communication chip is connected with the microcontroller, the output end of the RS485 communication chip is also connected to a fixed voltage through a pull-up resistor R1, and when no slave device is connected to the master device, a level signal received by the microcontroller is a high level signal; after the slave device is connected to the master device, as shown in fig. 3, the ground terminal of the slave device is connected to the input terminal of the electronic switch, the voltage corresponding to the ground terminal of the slave device is greater than the voltage corresponding to the ground terminal of the master device, and the voltage difference between the voltage corresponding to the ground terminal of the slave device and the voltage corresponding to the ground terminal of the master device is greater than the turn-on voltage of the electronic switch, so that the voltage difference between the two ends of the electronic switch is also greater than the turn-on voltage of the electronic switch,the voltage of the first signal end A of the RS485 communication chip is smaller than that of the second signal end B of the RS485 communication chip, if the voltage difference V of the differential signal is larger than the voltage of the second signal end B of the RS485 communication chipABThe output end R0 of the RS485 communication chip outputs a low level signal, namely when no slave device is connected with the master device, the level signal received by the microcontroller is a high level signal, and after the slave device is connected with the master device, the level signal received by the microcontroller is a low level signal, so that the microcontroller can judge that the slave device is connected with the master device according to the low level signal.
As shown in fig. 4, in one embodiment, the output terminal of the RS485 communication chip is connected to the ground terminal of the main device through a pull-down resistor R1, the two terminals of the electronic switch at least include an output terminal and an input terminal, the output terminal of the electronic switch is connected to the second signal terminal B of the RS485 communication chip, the output terminal of the electronic switch is connected to the ground terminal of the main device, and the input terminal of the electronic switch is connected to the first signal terminal a of the RS485 communication chip. When no slave device is connected to the master device, the electronic switch is not turned on, the voltage difference between two ends of the electronic switch is 0, because the output end R0 of the RS485 communication chip is connected with the microcontroller and the output end of the RS485 communication chip is also connected to the grounding end of the master device through the pull-down resistor R1, when no slave device is connected to the master device, the level signal received by the microcontroller is a low level signal; after the slave device is connected to the master device, as shown in fig. 5, the ground terminal of the slave device is connected to the input terminal of the electronic switch, the voltage corresponding to the ground terminal of the slave device is greater than the voltage corresponding to the ground terminal of the master device, and the voltage difference between the voltage corresponding to the ground terminal of the slave device and the voltage corresponding to the ground terminal of the master device is greater than the turn-on voltage of the electronic switch, so that the voltage difference between the two ends of the electronic switch is also greater than the turn-on voltage of the electronic switch, the voltage of the second signal terminal B of the RS485 communication chip is less than the voltage of the first signal terminal a of the RS485 communication chip, if the voltage difference V of the differential signal is greater than the turn-on voltage of the electronic switch, the voltage difference V of the differential signal is greater than the voltage of the first signal terminal a of the RS485 communication chipABThe output end R0 of the RS485 communication chip outputs a high level signal, namely, when no slave device is connected to the master device, the level signal received by the microcontroller is a low level signal, and after the slave device is connected to the master device, the level signal received by the microcontroller is a high level signal, therefore,the microcontroller can judge that the slave device is connected to the master device according to the high-level signal.
In one embodiment, the electronic switch may be a diode, an anode of the diode is an input terminal of the electronic switch, and a cathode of the diode is an output terminal of the electronic switch, and the electronic switch is turned on when a voltage difference across the diode is greater than a turn-on voltage of the electronic switch. The diode can be a Schottky diode, the voltage difference of the Schottky diode is 0.3V to 0.9V when the Schottky diode is conducted, the voltage difference detected by the RS485 communication chip is also larger than 0.3V and larger than 0.2V, or the voltage difference detected by the RS485 communication chip is smaller than-0.3V and smaller than-0.2V. Of course, the electronic switch may also be a triode, as long as the purpose of conducting the electronic switch when the voltage difference between the two ends of the electronic switch is greater than the conducting voltage of the electronic switch can be achieved.
In one embodiment, the access detection circuit further comprises a switch module, the RS485 communication chip is connected to the switch module, and the switch module includes a first connection state and a second connection state. As shown in fig. 6, when the switch module is in the first connection state, the first signal terminal a of the RS485 communication chip is connected to the output terminal of the electronic switch through the switch module, and the second signal terminal B of the RS485 communication chip is connected to the input terminal of the electronic switch through the switch module, that is, when the switch module is in the first connection state, the voltage difference between the two terminals of the electronic switch is detected through the first signal terminal a and the second signal terminal B of the RS485 communication chip; as shown in fig. 6, when the switch module is in the second connection state, the first signal terminal a of the RS485 communication chip is connected to the third signal terminal a in the RS485 interface of the master device through the switch module, and the second signal terminal B of the RS485 communication chip is connected to the fourth signal terminal B in the RS485 interface of the master device through the switch module, that is, when the switch module is in the second connection state, the differential signal is transmitted through the first signal terminal a and the second signal terminal B of the RS485 communication chip, so that the data is transmitted between the slave device and the master device. The RS485 interface comprises a third signal end A, a fourth signal end B, a power supply end VCC and a ground wire end, the main device is connected with the slave device through the RS485 interface, power supply to the slave device is achieved, and data are transmitted between the slave device and the main device through differential signals.
The microcontroller is connected with the switch module through the input/output interface, and the enable signal is output through the input/output interface, so that the switch module is switched between the first connection state and the second connection state, wherein when the switch module is in the second connection state, the transmission of data between the slave device and the master device can change the level signal output by the output end of the RS485 communication chip, so that the access detection of the slave device is only carried out when the switch module is in the first connection state, and the misjudgment of the access detection is avoided. Specifically, after the microcontroller detects that the slave device is connected, the switch module is controlled to be switched from the first connection state to the second connection state so as to be in communication connection with the slave device through the third signal end and the fourth signal end, so that data can be transmitted between the slave device and the master device, and normal communication of RS485 is not affected; after the microcontroller detects that the slave device is disconnected, the switch module is controlled to be switched from the second connection state to the first connection state, so that whether the slave device is connected to the master device or not is detected.
In one embodiment, the switch module is an analog switch, the analog switch mainly completes the signal switching function in the signal link, and the signal link is switched off or on by adopting the switching mode of an MOS (metal oxide semiconductor) tube; because its function is similar to a switch, but is realized by the characteristics of an analog device, the switch becomes an analog switch. Analog switches function primarily as on or off signals in electronic devices. The analog switch has the characteristics of low power consumption, high speed, no mechanical contact, small volume, long service life and the like.
In one embodiment, the switch module includes a first single pole double throw switch and a second single pole double throw switch. The first single-pole double-throw switch and the second single-pole double-throw switch both comprise fixed ends and movable ends, the fixed ends of the first single-pole double-throw switches are connected to a first signal end A of an RS485 communication chip, one movable end of the first single-pole double-throw switches is connected to an output end of the electronic switch or a third signal end A of the RS485 interface, the fixed ends of the second single-pole double-throw switches are connected to a second signal end B of the RS485 communication chip, one movable end of the second single-pole double-throw switches is connected to an input end of the electronic switch or a fourth signal end B of the RS485 interface, and switching of the switch module between a first connection state and a second connection state is achieved.
To achieve the above object, the present application further provides a master device, which includes the access detection circuit as in any one of the above embodiments. In this embodiment, since the master device includes the access detection circuit as described above, the master device at least has the beneficial effect of the access detection circuit, and details are not repeated here.
Referring to fig. 8, the present application further provides an access detection method, where the access detection method is applied to a main device, the main device includes a microcontroller, an RS485 communication chip and an electronic switch, two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip, and the RS485 communication chip is connected to the microcontroller, and the access detection method includes the following steps:
step S10, a microcontroller acquires a level signal output by the RS485 communication chip, wherein the level signal comprises a high level signal or a low level signal, and the RS485 communication chip outputs the corresponding level signal according to the detected voltage difference at the two ends of the electronic switch;
and step S20, the microcontroller judges whether the slave device is connected to the master device according to the level signal.
In this embodiment, the master device includes an access detection circuit, and the access detection circuit includes a microcontroller, an RS485 communication chip, and an electronic switch. The output end of the RS485 communication chip is connected with the microcontroller; the two ends of the electronic switch are bridged between the first signal end and the second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch, the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the detected voltage difference, and the microcontroller judges whether the slave device is connected to the master device or not according to the received level signal.
In this embodiment, the master device is generally a data acquisition host, and the slave devices are acquisition devices such as a temperature and humidity sensor, an infrared remote controller, a commercial power detection module, and an audible and visual alarm. An RS485 communication chip is arranged in the master device, and the slave device can be accessed into the master device through an RS485 interface.
In this embodiment, the RS485 communication chip includes an output terminal R0, a first signal terminal a, and a second signal terminal B. The first signal end A and the second signal end B are used for receiving differential signals, differential transmission is a signal transmission technology, and is different from the traditional method of one signal line and one ground wire, the differential transmission transmits signals on the two lines, the amplitudes of the two signals are the same, the phases of the two signals are opposite, the signals transmitted on the two lines are the differential signals, and the signal transmission lines connected with the first signal end and the second signal end of the RS485 communication chip are usually two lines which are equal in length, equal in width, close to each other and on the same layer. The RS485 communication chip can control the output end R0 to output a corresponding level signal according to the voltage difference between the first signal end A and the second signal end B. On a circuit board, the differential traces must be two lines that are equal in length, equal in width, closely adjacent, and on the same plane. Based on the characteristic of the RS485 communication chip, when the voltage difference VAB of the differential signal is greater than 0.2V, the output end R0 outputs a high-level signal, and when the voltage difference VAB of the differential signal is less than-0.2V, the output end R0 outputs a low-level signal, so that whether the slave device is connected to the master device or not can be judged by outputting the corresponding level signal through the output end of the RS485 communication chip. It should be noted that, this differential characteristic of the RS485 communication chip itself is generally used for transmitting data, and this embodiment uses the differential characteristic for transmitting data for access detection of the slave device, so that the access detection is simpler and more accurate.
In one embodiment, the output end of the RS485 communication chip is connected to a fixed voltage through a pull-up resistor, the first signal end a of the RS485 communication chip is connected to the output end of the electronic switch, and the second signal end B of the RS485 communication chip is connected to the input end of the electronic switch, at this time, when the level signal acquired by the microcontroller is a low level signal, the microcontroller determines that the slave device is connected to the master device, and when the level signal acquired by the microcontroller is a high level signal, the microcontroller determines that the slave device is not connected to the master device.
In one embodiment, the main device further comprises a switch module, the RS485 communication chip is connected with the switch module, the switch module comprises a first connection state and a second connection state, when the switch module is in the first connection state, a first signal end of the RS485 communication chip is connected to an output end of the electronic switch through the switch module, and a second signal end of the RS485 communication chip is connected to an input end of the electronic switch through the switch module; when the switch module is in the second connection state, the first signal end of the RS485 communication chip is connected to the third signal end in the RS485 interface of the master device, the second signal end of the RS485 communication chip is connected to the fourth signal end in the RS485 interface of the master device, and the RS485 interface is used for connecting the slave device. Because the transmission of data between the slave device and the master device can also change the level signal output by the output end of the RS485 communication chip when the switch module is in the second connection state, the access detection of the slave device is only carried out when the switch module is in the first connection state, and the misjudgment of the access detection is avoided. When the microcontroller judges that the slave equipment is connected with the master equipment according to the level signal, the microcontroller controls the switch module to be switched from the first connection state to the second connection state so as to be in communication connection with the slave equipment through the third signal end and the fourth signal end, at the moment, the slave equipment and the master equipment can transmit differential signals through the first signal end and the second signal end, data transmission is achieved, and the normal communication function of the RS485 cannot be influenced by access detection of the slave equipment.
In an embodiment, when the level signal is a low level signal, after the step of determining that the slave device accesses the master device, the microcontroller may further continue to acquire the level signal output by the output end of the RS485 communication chip, and if it is detected that the level signal is a high level signal and the duration of the high level signal is greater than a preset duration, it indicates that the high level signal is caused by a pull-up resistor connected to the output end of the RS485 communication chip, the slave device has been disconnected from the master device, the microcontroller determines that the slave device does not access the master device, and controls the switch module to switch from the second connection state to the first connection state, so as to perform access detection on the slave device.
In the technical scheme disclosed in this embodiment, whether the slave device is connected to the master device is judged by outputting the corresponding level signal through the output end of the RS485 communication chip, the connection detection of the slave device is more convenient and accurate, and the ADC resource does not need to be occupied.
In addition, an embodiment of the present invention further provides a storage medium, where an access detection program is stored on the storage medium, and the access detection program, when executed by a processor, implements the steps of the access detection method according to the above embodiments.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (7)

1. An access detection circuit, applied to a master device, the access detection circuit comprising:
a microcontroller;
the output end of the RS485 communication chip is connected with the microcontroller;
two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip so as to detect the voltage difference between the two ends of the electronic switch;
the RS485 communication chip controls the output end of the RS485 communication chip to output a corresponding level signal according to the detected voltage difference, and the microcontroller judges whether the slave equipment is connected to the master equipment or not according to the received level signal;
the output end of the RS485 communication chip is also connected to a fixed voltage through a pull-up resistor;
the two ends of the electronic switch at least comprise an output end and an input end, the output end of the electronic switch is connected to the first signal end of the RS485 communication chip and the grounding end of the main device, and the input end of the electronic switch is connected to the second signal end of the RS485 communication chip;
when the slave device is connected to the master device, the ground terminal of the slave device is connected to the input terminal of the electronic switch, the voltage corresponding to the ground terminal of the slave device is greater than the voltage corresponding to the ground terminal of the master device, the voltage difference between the two ends of the electronic switch is greater than the on-state voltage of the electronic switch, the RS485 communication chip outputs a low-level signal to the microcontroller, and the microcontroller determines that the slave device is connected to the master device according to the low-level signal;
the access detection circuit further comprises:
the RS485 communication chip is connected with the switch module, the switch module comprises a first connection state and a second connection state, when the switch module is in the first connection state, a first signal end of the RS485 communication chip is connected to the output end of the electronic switch through the switch module, and a second signal end of the RS485 communication chip is connected to the input end of the electronic switch through the switch module; when the switch module is in a second connection state, the first signal end of the RS485 communication chip is connected to a third signal end in the RS485 interface of the master device, the second signal end of the RS485 communication chip is connected to a fourth signal end in the RS485 interface of the master device, and the RS485 interface is used for connecting the slave device;
after the microcontroller detects that the slave device is connected to the master device, the microcontroller controls the switch module to be switched from the first connection state to the second connection state so as to be in communication connection with the slave device through the third signal end and the fourth signal end.
2. The access detection circuit of claim 1, wherein the electronic switch is a diode, an anode of the diode is an input of the electronic switch, and a cathode of the diode is an output of the electronic switch.
3. The access detection circuit of claim 1, wherein the switch module comprises a first single-pole double-throw switch and a second single-pole double-throw switch, a fixed end of the first single-pole double-throw switch is connected to the first signal terminal of the RS485 communication chip, an active end of the first single-pole double-throw switch is alternatively connected to the output terminal of the electronic switch or the third signal terminal of the RS485 interface, a fixed end of the second single-pole double-throw switch is connected to the second signal terminal of the RS485 communication chip, and an active end of the second single-pole double-throw switch is alternatively connected to the input terminal of the electronic switch or the fourth signal terminal of the RS485 interface.
4. A master device, characterized in that it comprises an access detection circuit according to any one of claims 1 to 3.
5. An access detection method is characterized in that the access detection method is applied to a main device, the main device comprises a microcontroller, an RS485 communication chip and an electronic switch, two ends of the electronic switch are bridged between a first signal end and a second signal end of the RS485 communication chip, the RS485 communication chip is connected with the microcontroller, the main device further comprises a switch module, and the access detection method comprises the following steps:
the microcontroller acquires a level signal output by the RS485 communication chip, wherein the level signal comprises a high level signal or a low level signal, and the RS485 communication chip outputs the corresponding level signal according to the detected voltage difference between two ends of the electronic switch;
when the level signal is a low level signal, the microcontroller judges that the slave equipment is connected to the master equipment;
when judging the slave equipment inserts when the master equipment, microcontroller control switch module switches to the second connection state from first connection state, wherein, when switch module is in first connection state, RS485 communication chip passes through switch module and is connected to electronic switch's both ends, when switch module is in the second connection state, RS485 communication chip passes through switch module and is connected to the RS485 interface of master equipment, the RS485 interface is used for connecting the slave equipment.
6. The access detection method of claim 5, wherein after the step of the microcontroller determining that the slave device accesses the master device when the level signal is a low level signal, further comprising:
acquiring a level signal output by the RS485 communication chip;
when the level signal is a high level signal and the duration of the high level signal is longer than a preset duration, the microcontroller determines that the slave device does not access the master device and controls the switch module to switch from the second connection state to the first connection state.
7. A storage medium, characterized in that the storage medium has stored thereon an access detection program which, when executed by a processor, carries out the steps of the access detection method according to claim 5 or 6.
CN202010678754.8A 2020-07-14 2020-07-14 Access detection circuit, method, master device and storage medium Active CN111882852B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010678754.8A CN111882852B (en) 2020-07-14 2020-07-14 Access detection circuit, method, master device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010678754.8A CN111882852B (en) 2020-07-14 2020-07-14 Access detection circuit, method, master device and storage medium

Publications (2)

Publication Number Publication Date
CN111882852A CN111882852A (en) 2020-11-03
CN111882852B true CN111882852B (en) 2021-10-22

Family

ID=73150281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010678754.8A Active CN111882852B (en) 2020-07-14 2020-07-14 Access detection circuit, method, master device and storage medium

Country Status (1)

Country Link
CN (1) CN111882852B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113641611B (en) * 2021-06-30 2022-07-15 荣耀终端有限公司 I2C interface circuit, control method thereof and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101266587A (en) * 2008-04-22 2008-09-17 惠州市德赛汽车电子有限公司 USB equipment detection circuit
CN103200062A (en) * 2013-03-29 2013-07-10 北京经纬恒润科技有限公司 Controller area network (CAN) bus data transceiver
CN106411360A (en) * 2016-09-20 2017-02-15 天地融科技股份有限公司 Communication equipment and communication system
CN106445863A (en) * 2016-09-28 2017-02-22 广州视睿电子科技有限公司 Interface circuit
CN110932712A (en) * 2018-09-19 2020-03-27 青岛海信移动通信技术股份有限公司 Interface circuit of connector and electronic device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101266587A (en) * 2008-04-22 2008-09-17 惠州市德赛汽车电子有限公司 USB equipment detection circuit
CN103200062A (en) * 2013-03-29 2013-07-10 北京经纬恒润科技有限公司 Controller area network (CAN) bus data transceiver
CN106411360A (en) * 2016-09-20 2017-02-15 天地融科技股份有限公司 Communication equipment and communication system
CN106445863A (en) * 2016-09-28 2017-02-22 广州视睿电子科技有限公司 Interface circuit
CN110932712A (en) * 2018-09-19 2020-03-27 青岛海信移动通信技术股份有限公司 Interface circuit of connector and electronic device

Also Published As

Publication number Publication date
CN111882852A (en) 2020-11-03

Similar Documents

Publication Publication Date Title
US8954628B2 (en) Portable device and peripheral extension dock
US7587541B2 (en) Master-slave device communication circuit
US20130179603A1 (en) Apparatus and method of identifying a usb or an mhl device
CN211062036U (en) Interface level conversion circuit
JP2004288141A (en) General-purpose micro memory card
EP3683688B1 (en) Corrosion protection circuit for serial bus connector
CN111882852B (en) Access detection circuit, method, master device and storage medium
CN103176885A (en) Network card stoppage prompting system
EP3518201A1 (en) Detector, isolator, warning system and control method
CN104459287A (en) Integrated circuit with protection function and operating system
WO2014192834A1 (en) Battery pack and portable electronic apparatus
CN110797985B (en) Coil switching method and device, storage medium and electronic equipment
CN111586472A (en) Signal control method of cable and electronic equipment
CN103443736B (en) The starter gear of electronic equipment, method and user&#39;s recognition system
CN109542017B (en) Communication circuit switching method and communication circuit switching circuit
CN214544305U (en) Network transmission device and network transmission equipment
CN211149270U (en) Debugging circuit
CN110244681B (en) Self-checking control method and control device for electric control board, water dispenser and electric control board thereof
US9332501B2 (en) System and method for antenna-receiver communication
CN211236201U (en) RS232 interface state detection circuit
US20120056611A1 (en) Connection detection circuit
CN109151160B (en) Communication method, communication device, mobile terminal and storage medium
WO2016174428A1 (en) Bus network terminator
KR101472696B1 (en) A method and device, digital input apparatus and control unit for sensing a binary signal
CN111339013A (en) USB and UART line switching method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant