Connecting the microcontroller to a remote computer via rs485 to the usb port.  Connecting the microcontroller to a remote computer via rs485 to the usb port Number of combined devices

Connecting the microcontroller to a remote computer via rs485 to the usb port. Connecting the microcontroller to a remote computer via rs485 to the usb port Number of combined devices

In modern technology, the exchange of information between various devices is becoming increasingly important. And for this, it is required to transmit data both over short distances and over significant ones, on the order of kilometers. One of these types of data transmission is communication between devices via the RS-485 interface.

Where it is necessary to transfer data via RS 485.

One of the most common examples of using devices for data exchange is. Electricity meters, united into a single network, are dispersed among cabinets, cells switchgears and even substations located at a considerable distance from each other. In this case, the interface is used to send data from one or more metering devices.

The system "one meter - one modem" is being actively implemented to transfer data to the services of energy sales companies from metering centers of private houses, small enterprises.

Another example: receiving data from microprocessor relay protection terminals in real time, as well as centralized access to them for the purpose of making changes. For this, the terminals are tied through the communication interface in the same way, and the data from it goes to the computer installed by the dispatcher. In the event of a protection actuation, the operating personnel have the opportunity to immediately receive information about the place of action and the nature of the damage to the power circuits.

But the most difficult task solved by communication interfaces is the systems of centralized control of complex production processes - APCS. The operator of an industrial installation has a computer on his desk, on the display of which he sees the current state of the process: temperatures, productivity, units turned on and off, their operating mode. And it has the ability to manage all this with a light click of the mouse.

The computer, on the other hand, exchanges data with controllers - devices that convert commands from sensors into a language understandable by a machine, and the reverse transformation: from the language of a machine into control commands. Communication with the controller, as well as between different controllers, is carried out via communication interfaces.


The RS-232 interface is the little brother of RS 485.

One cannot at least briefly mention the RS-232 interface, which is also called serial. Some laptops have a connector for the corresponding port, and some digital devices (the same relay protection terminals) are equipped with outputs for communication using RS-232.

In order to exchange information, you need to be able to transmit and receive it. For this we have a transmitter and a signal receiver. They are included in every device. Moreover, the output of the transmitter of one device (TX) is connected to the input of the receiver of another device (RX). And, accordingly, the signal moves in the opposite direction along the other conductor in a similar way.

This provides a half-duplex communication mode, that is, the receiver and transmitter can work simultaneously. Data on the RS-232 cable can move in one direction and the other at the same time.

The disadvantage of this interface is its low noise immunity. This is due to the fact that the signal to the connecting cable for both reception and transmission is formed relative to the common wire - ground. Any interference, even in a shielded cable, can lead to communication failure, loss of individual bits of information. And this is unacceptable when managing complex and expensive mechanisms, where any mistake is an accident, and a loss of communication is a long downtime.

Therefore, it is mainly used for small temporary connections of a laptop to a digital device, for example, for setting up an initial configuration or correcting errors.


Organization of the RS-485 interface.

The main difference between RS-458 and RS-232 is that all receivers and transmitters operate on one pair of wires, which is a communication line. In this case, the ground wire is not used, and the signal in the line is formed by a differential method. It is transmitted simultaneously over two wires ("A" and "B") in reverse form.

If the output of the transmitter is a logical "0", then a zero potential is given to the conductor "A". On the "B" conductor, a "not 0" signal is generated, that is - "1". If the transmitter broadcasts "1", the opposite is true.

As a result, we get a change in the signal voltage between the two wires, which are twisted pair. Any interference entering the cable changes the voltage relative to ground equally on both wires of the pair. But the voltage of the useful signal is formed between the wires, and therefore does not suffer at all from the potentials on them.

The order of data exchange between devices via RS-485.

All devices connected by the RS-485 interface have only two terminals: "A" and "B". For connection to a common network, these terminals are connected in a parallel circuit. For this, a chain of cables is laid from one device to another.

In this case, it becomes necessary to streamline the exchange of data between devices, setting the sequence of transmission and reception, as well as the format of the transmitted data. This is done with a special instruction called a protocol.

There are many RS-485 communication protocols, the most commonly used one is Modbas. Let's briefly consider how the simplest protocol works, and what other problems have to be solved with its help.

For example, let's take a look at a network in which one device collects data from multiple data sources. It can be a modem and a group of electricity meters. In order to know from which counter the data will go, each transceiver is assigned a number that is unique for the given network. The number is also assigned to the modem's transceiver.

When it's time to collect data on power consumption, the modem generates a request. First, a start pulse is transmitted, according to which all devices understand that a code word will come now - a message from a sequence of zeros and ones. In it, the first bits will correspond to the subscriber's number in the network, the rest will be data, for example, a command to transmit the required information.

All devices receive the message and compare the called subscriber number with their own. If they match, the command sent as part of the request is executed. If not, the device ignores its text and does nothing.

At the same time, in many protocols, a confirmation is sent back that the command is accepted for execution or executed. If there is no answer, the transmitting device can repeat the request a certain number of times. If there is no reaction, information about an error is generated related to a malfunction of the communication channel with the silent subscriber.

The answer may not follow, not only in the event of a breakdown. In the presence of strong interference in the communication channel, which nevertheless penetrates there, the teams may not reach their destination. They are also distorted and not recognized correctly.

Incorrect execution of the command cannot be allowed, therefore, deliberately redundant information is introduced into these parcels - a checksum. It is calculated according to a certain law prescribed in the protocol on the transmitting side. At the reception, the checksum is calculated according to the same principle and compared with the transmitted one. If they match, the reception is considered successful and the command is executed. If not, the device sends an error message to the transmitting side.

Requirements for cable connections.

Twisted-pair cables are used to connect devices with the RS-485 interface. Although one pair of wires is enough to transmit this data, cables with at least two are usually used to provide a reserve.

For better protection against interference, the cables are shielded, whereby the shields along the entire line are connected to each other. For this purpose, in addition to the “A” and “B” pins, the devices to be combined have a “COM” terminal. The line is grounded only at one point, usually at the location of the controller, modem, or computer. It is forbidden to do this at two points in order to avoid interference, which will inevitably go across the screen due to the potential difference at the ground points.

Cables are connected only in series with each other, branches cannot be made. To match the line, a 120 Ohm resistor is connected at its end (this is the characteristic impedance of the cable).

In general, the installation of interface cable lines is a simple task. It will be much more difficult to configure the equipment, which will require people with special knowledge.

For a better understanding of the operation of the RS-485 interface, we suggest you watch the following video:

RS-485 is a standard that was first adopted by the Electronics Industries Association. Today, this standard deals with the electrical characteristics of all kinds of receivers and transmitters used in various balanced digital systems.

What is he like?

Among specialists RS-485 is the name of a fairly popular interface, which is actively used in various industrial control systems to connect several controllers, as well as many other devices to each other. The main difference between this interface and the no less common RS-232 is that it provides for the combination of several types of equipment at the same time.

With the help of RS-485, high-speed information exchange between several devices is provided through a single two-wire line communication in half duplex mode. It is widely used in modern industry in the process of forming a process control system.

Range and speed

With the help of this standard, information is transmitted at a speed of up to 10 Mbit / s, while the maximum possible range will directly depend on the speed at which the data is transmitted. Thus, to ensure the maximum speed, data can be transmitted no further than 120 meters, while at a speed of 100 kbps, information is broadcast over 1200 meters.

The number of combined devices

The number of devices that the RS-485 interface can combine will directly depend on which transceivers are used in the device. Each transmitter is designed to simultaneously control 32 standard receivers, however, you need to understand that there are receivers whose input impedance is 50%, 25% or even less of the standard, and if such equipment is used, the total number of devices will increase accordingly.

Connectors and protocols

RS-485 cable does not standardize any specific format of information frames or exchange protocol. In the vast majority of cases, exactly the same frames are used that RS-232 uses, that is, data bits, stop and start bits, as well as a parity bit, if necessary.

The operation of exchange protocols in most modern systems is carried out according to the "master-slave" principle, that is, some device in the network is the master and takes the initiative in the exchange of sending requests between all slave devices that differ from each other by logical addresses. The most popular protocol today is Modbus RTU.

It is worth noting that the RS-485 cable also does not have any specific type of connectors or wiring, that is, there may be terminal connectors, DB9 and others.

Connection

Most often, using this interface, there is a local network that combines several transceivers simultaneously.

When making an RS-485 connection, you need to competently combine the signal circuits with each other, usually called A and B. In this case, the polarity reversal is not so terrible, just the connected devices will not work.

When using the RS-485 interface, you should consider several features of its operation:

  • The most optimal signal transmission medium is twisted pair cable.
  • The ends of the cable must be drowned out using specialized terminal resistors.
  • A network that uses standard or USB RS-485 must be laid without any branching
  • Devices should be connected to the shortest possible length.

Agreement

Using terminal resistors, standard or USB RS-485 provides full matching of the open end of the cable with the subsequent line, completely eliminating the possibility of signal reflection.

The nominal resistance of the resistors corresponds to the characteristic impedance of the cable and for those cables that are based on twisted pair, in the majority of cases it is approximately 100-120 ohms. For example, the UTP-5 cable, which is quite popular today, which is actively used in the process of laying Ethernet, has a characteristic impedance of 100 Ohm. For other cable options, some other rating may be used.

Resistors, if necessary, can be soldered on the contacts of the cable connectors already in the final devices. Rarely, resistors are installed in the device itself, as a result of which jumpers have to be installed to connect the resistor. In this case, if the device is disconnected, the line is completely mismatched. And in order to ensure the normal operation of the rest of the system, you need to connect a matching plug.

Signal levels

The RS-485 port uses a balanced data transmission scheme, that is, the voltage levels on signal circuits A and B will change in antiphase.

The sensor should provide a signal level of 1.5 V at full load, and no more than 6 V if the device is idling. The voltage level is measured differentially, each signal wire relative to the other.

Where the receiver is located, the minimum level of the received signal in any case must be at least 200 mV.

Bias

In the event that there is no signal on the signal circuits, a slight offset occurs, which protects the receiver from false alarms.

Experts recommend an offset of slightly more than 200 mV, since this value corresponds to the unreliability zone of the input signal according to the standard. In this case, circuit A is pulled up to the positive pole of the source, while circuit B is pulled up to common.

Example

In accordance with the required bias and voltage of the power supply, the calculation is carried out.For example, if you want to obtain an offset of 250 mV when using terminal resistors RT = 120 Ohm, given that the source has a voltage of 12V. Considering that in this case two resistors are connected in parallel each other without taking into account the load from the receiver at all, the bias current is 0.0042 A, while the total resistance of the bias circuit is 2857 ohms. R cm in this case will be approximately 1400 ohms, so you need to choose some closest value.

As an example, we will use a 1.5k bias resistor and an external 12 volt resistor. In addition, our system has an isolated output from the controller's power supply, which is the leading link in its segment of the circuit.

Of course, there are a lot of other options for implementing bias, in which an RS-485 converter and other elements are used, but in any case, when placing bias circuits, you need to take into account that the node that will provide it will periodically turn off or even eventually can be completely removed from the network.

If bias is present, then the fully idle potential of circuit A is positive with respect to circuit B, which is a guideline if a new device will be connected to a cable without wire markings.

Incorrect wiring and distortion

The implementation of the above recommendations allows you to achieve normal transmission of electrical signals to various points in the network, if the RS-485 protocol is used as a basis. If at least some of the requirements are not met, signal distortions will occur. The most noticeable distortions begin to appear when the data exchange rate exceeds 1 Mbit / s, but in fact, even in the case of lower speeds, it is highly discouraged to disregard these recommendations, even if the network is “working normally”.

How to program?

There are several important points to keep in mind when programming various applications that work with devices using an RS-485 splitter and other devices with this interface. Let's list them:

  • Before the delivery of the parcel begins, it is imperative to activate the transmitter. Despite the fact that, according to information from certain sources, the issuance can be carried out immediately after switching on, some experts recommend initially holding a pause, which in time will be equal to the transmission rate of one frame. In this case, the correct reception program will have time to fully determine the errors of the transient process, carry out the normalization procedure and prepare for the subsequent data reception.
  • After the last byte of data has been issued, it is also recommended to pause before disconnecting the RS-485 device. In particular, this is due to the fact that in the serial port controller there are often two registers simultaneously, the first of which is a parallel input and is intended for receiving data, while the second is a shift output and is used for serial output. Any interrupts on transmission by the controller are generated in the event of an empty input register, when information has already been provided to the shift register, but has not yet been issued. It is for this reason that after the broadcast is interrupted, you need to maintain a certain pause before turning off the transmitter, which should be approximately 0.5 bits longer than the frame in time. For more accurate calculations, it is recommended to study in detail the technical documentation of the used serial port controller.
  • Since the transmitter, receiver and, possibly, the RS-485 converter are connected to a single line, the own receiver will also perceive the transmission made by its own transmitter. It is not uncommon for systems with random access to the line to use this feature to check that there is no collision between two transmitters. In standard systems operating according to the master-slave principle, it is recommended that interrupts from the receiver be completely closed during transmission.

Bus format configuration

This interface provides for the possibility of combining devices in the "bus" format, when all devices are connected using a single pair of wires. In this case, the communication line must be matched by the end-of-line resistors of the two ends.

To ensure matching, in this case, resistors with a resistance of 620 ohms are installed. They are always installed on the first and last device connected to the line. In the majority of modern devices, there is also a built-in matching resistance, which, if necessary, can be included in the line by installing a special jumper on the device board.

Since the jumpers are initially installed in the delivery state, you must first remove them from all devices, respectively, except for the first and last connected to the line. In the S2000-PI model repeater converters for each individual output, the matching resistance is switched on using a switch, while the S2000-KS and S2000-K devices are characterized by a built-in matching resistance, as a result of which there is no jumper required to connect it.

In order to provide a longer communication line, it is recommended to use dedicated repeater-repeaters, fully equipped automatic switching transmission directions.

Star configuration

Any taps on the RS-485 line are undesirable, because in this case there is a fairly strong signal distortion, but from a practical point of view, they can be tolerated if there is a short tap length. In this case, it is not necessary to install terminating resistors on separate branches.

In an RS-485 distribution system, which is controlled from the console, if the latter and the devices are connected to the same line, but powered from different sources, it will be necessary to combine the 0 V circuits of all devices and the console in order to ensure their potential equalization. If this requirement is not met, then the remote control may have an unstable connection with devices. If a cable with several twisted pairs of wires is to be used, then a completely free pair can be used for the potential equalization circuit if necessary. Among other things, it is also possible to use a shielded twisted pair if the shield is not grounded.

What should be considered?

In the overwhelming majority, the current that passes through the potential equalization wire is quite small, however, if 0 V of devices or the power supplies themselves are connected to several local ground buses, the potential difference between different 0 V circuits can be several units, and in some cases even tens of volts, while the current flowing through the potential equalization circuit can be quite significant. This is a common reason that there is an unstable connection between the remote control and devices, as a result of which they may even fail.

It is for this reason that it is necessary to exclude the possibility of grounding the 0 V circuit, or, as a maximum, to ground this circuit at a certain point. You also need to consider the possibility of interconnection between 0 V and the protective earth circuit, which is present in the equipment that is used in the alarm system.

At objects, which are characterized by a rather severe electromagnetic environment, it is possible to connect this network through a "shielded twisted pair" cable. In this case, a shorter range may be present as the cable capacitance is higher.

Installation features

Network communication is wired with a twisted pair cable of the fifth category. The controllers are interconnected according to the bus topology, i.e. sequentially one after another.

Correct network operation (especially when using long cables) is only possible if there is only one line between all transceiver devices (“bus topology”).

A line can include up to 32 devices (for a standard load unit or more for - ¼ load), located as desired along its entire length. Devices should be connected to the line with very short cables (no longer than 30 cm) in order to avoid Y-splitting.

In practice, however, this length can be increased to several meters. In most cases, complex configuration problems can be solved by using interface repeaters.

Signal lines should be at least 50 cm away from power supply cables, especially load cables. Moreover, they should not be laid in the same braid with these cables or cables through which large currents flow, because this can lead to intrusion and errors.

The intersection of the lines of force must be at an angle of 90 degrees. Splicing of twisted pairs and the use of "twists" are prohibited. For cabling, it is recommended to use cables with two to four twisted pairs in order to:

  • use additional wires as drainage;
  • be able to use these lines with other equipment;
  • working, for example, using the RS-422 protocol;
  • have a reserve if there is an open or short circuit on the main pair.

The RS485 standard ensures the operation of devices on a line up to 1.2 km long. This value is the maximum. In practice, however, it is recommended to use lines no longer than 500 m. When constructing systems with long lines, special care should be taken when choosing a cable that must have a suitable cross-section.

The cable used must be capable of at least 0.2 V at the far-end 120 Ohm terminator when the transmitter output is 2 V. It is not recommended to use cables less than 22 AWG.

For remote control objects or monitoring the parameters of sensors from the control room are now widely used personal computers. In industry, for these purposes, the RS485 interface is used, which allows up to 32 transceivers to be connected via twisted pair over a distance of 1200 meters at a speed of up to 10 Mbit / s. You can read more about this interface in Everything is fine, but computers are not equipped with such interfaces. The RS232 interface and that on modern computers can be found quite rarely. But the USB port is available on almost any.

The author gives a practical diagram of the virtual adapter USB port to RS485. And also RS485 in serial port USART, which is found in the PIC18F8720 and many other microcontrollers. Fig. 1. The beauty of a virtual USB port is that software on the computer you can write as for the RS232 port. This means that you can control the port using a control such as MSComm. In this article, the control program of the computer is not considered, therefore we will send data from the computer using the COMPump terminal. Detailed description working with this terminal was considered in the article Virtual USB / RS-232 port, installation of drivers was also considered in the article. From a software point of view, it is no different from USB / RS485, although RS232 is a full duplex transceiver, and RS485 is half duplex.

So the USB / RS485 driver differs from USB / RS232 by replacing the DD2 fig1 chip in the ADM213EARS article with the D103 chip of the SN75176 fig1 type of this article. This microcircuit is a complete half-duplex RS485 transceiver, the output driver is designed for + -60mA current. The microcircuit has a built-in overheating protection device at the level of 150g. C. Minimum input impedance 12kΩ, input sensitivity 200mV. and an input hysteresis of 50mV. The operation algorithm of the receiver and transmitter is shown in Tables 1, 2. The D101 virtual driver microcircuit (FT232BM) allows you to connect the SN75176 microcircuit without modifying the software interface and work with the RS485 port in half-duplex mode. The only nuance that should be taken into account when developing a program on a computer is that during the transfer of a byte over the interface, you will receive the transmitted byte in the receiver, the so-called echo. The RS485 interface is designed to connect transceivers using a twisted pair cable at a distance of up to 1200 meters, however, in conditions of strong interference, the wire should be placed in the shield.

Table 1. transmitter

D DE A B
1 1 1 0
0 1 0 1
Z 0 Z Z

Table 2. receiver

A-B Inv.RE R
Vid> = 0.2v 0 1
-0.2v 0 ?
Vid<=-0,2в 0 0
X 1 Z
Open 0 ?

FIG 1

In place of the control device, it is also necessary to install the D3 transceiver microcircuit (SN75176). Since we write the driver for the microcontroller ourselves, we switch from reception to transmission using leg 39 of the PORTJ4 port. In the diagram of Fig. 1, the D2 microcircuit acts as a 10-bit analog-to-digital converter. The program in HEX format is shown in Table 3.

The algorithm of its work is as follows. Program every 21 μs. reads data from the ADC input and writes to the internal buffer consisting of 79 bytes. After about 1.7ms. The buffer fills up completely and the process repeats. In this case, to read this buffer from the computer, it is necessary to send the address of this device. In our case, this is 0x0A. After receiving the address, the microcontroller will transfer 79 bytes to the computer. Addressing is necessary if more than one control object will be connected to the RS485 line.

The entire device was made on a breadboard, except for the microcontroller. For it, you need to make a printed circuit board so that you can solder the leads to it. Since this microcontroller has a 12x12mm TQFP80 package and has 80 pins. The printed circuit board shown in Fig. 2 is made of one-sided fiberglass with a thickness of 0.5 mm and dimensions of 35x35mm. It is desirable to solder this microcircuit with an air soldering station.

The RS-485 standard was first adopted by the Electronics Industry Association. Today he reviews the electrical characteristics of various receivers and transmitters that are used in balanced digital systems.


What is this standard?

RS-485 is the name of a well-known interface that is actively used in all kinds of industrial control systems for the purpose of connecting certain controllers and many other devices to each other. The main difference between this interface and RS-232 is that it involves the combination of several types of equipment at the same time. When using RS-485, high-speed data exchange between several devices is guaranteed by using a single two-wire communication line in half-duplex mode. He is involved in modern industry in the creation of process control systems.

Range and speed

With the help of the presented standard, it is possible to achieve transmission of information at a speed of up to 10 Mbit / s. It should be noted that in this case, the maximum possible range directly depends on the speed of data transmission. It should be noted that in order to ensure the maximum speed, information can be transmitted no further than 120 meters. At the same time, at a speed of 100 kbps, data is transmitted over 1200 meters.

The number of combined devices

The number of devices that the RS-485 interface can combine in itself directly depends on which transceivers are involved in them. Each transmitter allows specific control of 32 standard receivers. True, you should be aware that there are receivers with an input impedance that differs from the standard by 50%, 25% or less. If you use this equipment, the total number of devices increases accordingly.

Connectors and protocols

The RS-485 cord is not capable of standardizing any particular data frame format or communication protocol. As a rule, the same frames used by RS-232 are used for broadcasting. In other words, the data bits, stop and start bits, and the parity bit, if necessary. As for the operation of the exchange protocols, in most modern systems it is performed according to the "master-slave" principle. This means that a certain device in the network acts as a master and initiates the exchange of sending requests between slave devices, which differ among themselves by logical addresses. The most famous protocol currently is Modbus RTU. It should be noted that the RS-485 cable does not have a specific type of connector or wiring. In other words, there are terminal connectors, DB9 and others.

Connection

Often, using the presented interface, a local network is encountered, which simultaneously combines several types of transceivers. When making an RS-485 connection, it is necessary to correctly interconnect the signal circuits. As a rule, they are called A and B. Thus, the polarity reversal is not a big deal, just the connected devices stop working.

When using the RS-485 interface, it is necessary to take into account certain features of its operation. Thus, the recommendations are as follows:

1. The optimal medium for signal transmission is a twisted pair cable.
2. The ends of the cord must be terminated using specialized terminal resistors.
3. The network, where standard or USB RS-485 is used, must be laid without branches according to the bus topology.
4. Devices should be connected to the cable using the shortest possible cable length.

Agreement

With the help of terminal resistors, standard or USB RS-485 guarantees complete matching of the open end of the cord with the subsequent line. This completely eliminates the possibility of signal reflection. The nominal impedance of the resistors associated with the characteristic impedance of twisted-pair cable and wires is typically around 100-120 ohms. For example, the currently known UTP-5 cable, which is often used in the process of laying Ethernet, has a characteristic impedance of 100 ohms.

For other cable options, other ratings can be applied. Resistors can be soldered to the pins of cable connectors in end devices, if necessary. It is not often that resistors are installed in the equipment itself, as a result of which jumpers must be installed to connect the resistor. In this case, when the device is connected, the line is mismatched. To guarantee the normal functioning of the rest of the system, you will need to connect a termination plug.

Signal levels

The RS-485 port adopts a balanced communication scheme. In other words, the voltage levels on signal circuits A and B change in antiphase. The sensor provides a signal level of 1.5 V, taking into account the load limit. In addition, a maximum of 6 V is provided when the device is idling. The voltage level is measured differentially. At the location of the receiver, the minimum level of the received signal must be at least 200 mV.

Bias

When there is no signal on the signal circuits, a small offset is applied. It provides protection to the receiver in the event of a false alarm. Experts advise doing an offset of slightly more than 200 mV, because this value is considered to correspond to the invalid zone of the input signal according to the standard. In such a situation, circuit A approaches the positive pole of the source, and circuit B is pulled up to the common one.

Example

Resistor values ​​are calculated based on the required bias and power supply voltage. For example, if you want to get an offset of 250 mV with terminal resistors, RT = 120 ohms. It is worth noting that the source has a voltage of 12 V. Taking into account the fact that in this case two resistors are connected in parallel to each other and do not take into account the load from the receiver at all, the bias current reaches 0.0042. At the same time, the total bias resistance is 2857 ohms. In this case Rcm will be about 1400 Ohm. Thus, you will need to select the nearest denomination. An example would be a 1.5 kΩ resistor. It is required for offset. In addition, an external 12 volt resistor is used.

It should also be noted that the system has an isolated output from the controller's power supply, which is the main link in its own circuit segment. True, there are other options for performing the bias, where the RS-485 converter and other elements are involved, but you should still take into account that the node providing the bias will sometimes be disabled or ultimately completely removed from the network. When bias exists, the fully idle potential of circuit A is considered positive with respect to circuit B. This acts as a guide when connecting new equipment to the cable without using wire markers.

Incorrect wiring and distortion

Implementation of the recommendations indicated above makes it possible to achieve correct transmission of electrical signals to different points of the network, when the RS-485 protocol is used as a basis. If at least one of the requirements is not met, signal distortion occurs. The most noticeable distortions appear when the data exchange rate is higher than 1 Mbps. True, even at lower speeds, it is not recommended to neglect these tips. This rule also applies during normal network operation.

How to program?

When programming various applications that work with devices used by an RS-485 splitter and other devices with the presented interface, several important points should be taken into account.

Before the delivery of the parcel begins, it is imperative to activate the transmitter. It is worth noting that, according to some sources, the issuance can be carried out immediately after activation. Despite this, some experts advise first to pause, equal in time to the broadcast speed of one frame. In this case, the correct reception program can fully identify the errors of the transient process, which is able to carry out the normalization procedure and prepare for the next data reception.

When the last data byte has been issued, you must also pause before disconnecting the RS-485 device. This is in some sense due to the fact that there are often two registers at the same time in the serial port controller. The first is a parallel input, it is designed to receive information. The second is considered a shift output, it is used for the purpose of serial output.

When the controller transfers data, any interrupts are generated when the input register is empty. This occurs when information has already been supplied to the shift register, but has not yet been issued. This is also the reason that after the termination of the broadcast, it is necessary to maintain a certain pause before turning off the transmitter. It should be about 0.5 bits longer than the frame in time. When performing more accurate calculations, it is advised to study in more detail the technical documentation of the serial port controller that is used.

It is possible that the RS-485 transmitter, receiver and converter are connected to a common line. Thus, the own receiver will also begin to perceive the transmission made by the own transmitter. It often happens that when in systems that are characterized by random access to the line, this feature is used to check that there is no collision between two transmitters.

Bus format configuration

The presented interface has the ability to combine devices in the "bus" format, when all equipment is connected using one pair of wires. This provides that the communication line must be matched by the end-of-line resistors of the two ends. To ensure this, it is necessary to install resistors that are characterized by a resistance of 620 ohms. They are always mounted on the first and last device connected to the line.

As a rule, modern devices have a built-in matching resistor. If the need arises, it can be connected to the line by installing a special jumper on the device board. It is worth noting that the delivery status of the jumpers is first installed, so you need to remove them from all devices except the first and the last. It should also be noted that in the S2000-PI model repeater converters for a separate output, the matching resistance is activated using a switch. As for the S2000-KS and S2000-K devices, which are characterized by a built-in matching resistance, there is no jumper required to connect it. To provide a long communication line, it is advisable to use specialized repeater-repeaters, which are pre-equipped with fully automatic transmission direction switches.

Star configuration

All taps on the RS-485 line are considered unwanted, as this would result in excessive signal distortion. Although, from the point of view of practice, it is possible to admit this when there is a small length of the branch. In this case, there is no need to install terminating resistors on separate branches.

In an RS-485 system, where control is provided by using a remote control, when resistors and devices are connected to the same line, but powered from different sources, it is necessary to combine the 0 V circuits of all devices and the remote control in order to achieve their potential equalization. When this requirement is not met, the remote is capable of intermittent communication with devices. When using wires with several twisted pairs, a completely free pair can be used for the potential equalization circuit, if necessary. In addition, it is possible to use the shielded twisted pair if the shield is not grounded.

What should be considered?

In most cases, the current flowing through the equipotential bonding wire is considered to be quite small. If 0 V devices or the power supplies themselves are connected to several local ground buses, then the potential difference between different 0 V circuits can reach several units. Sometimes this value is at around tens of volts, and the current that flows through the potential equalization circuit is quite significant. This is often the reason why there is an unstable connection between the remote control and the devices. As a result, they are even capable of failing.

Therefore, it is necessary to exclude the possibility of grounding the 0 V circuit, or to ground this circuit at a specific point. In addition, consideration should be given to the possibility of an interconnection between 0 V and the protective earth circuit, which is present in the equipment used in the alarm system. It should be noted that at sites where a relatively severe electromagnetic environment is characteristic, it is possible to connect to this network by using a "shielded twisted pair" cable. It remains to emphasize that in this situation, there may be a shorter limiting range, because the capacitance of the wire is considered to be higher.