Power line carrier use record

1. Description of use

1. Comparison of common communication buses

Power line carrier, as the name implies, is a way of data transmission using power lines . We usually do some small experiments related to single-chip communication, such as using UART, IIC, SPI and other communication methods for communication. The basic communication requirements can be met. But once the distance goes up, it will not work.

Regarding the communication distance, here I directly borrow the summary of a big guy from Zhihu. I don’t know if it has been optimized now, but I feel that it is not too different.

bus type Number of lines communication type Master and slave cable length
UART 2 asynchronous not support <1.5m
SPI 3 Synchronize support <3m
IIC 2 Synchronize support <3m

Original text link: UART, SPI, I2C three communication methods

Therefore, some other communication methods will be used for long-distance communication, such as the more commonly used RS485 bus. The characteristics of the 485 bus are as follows

  • 1. The interface level is low , so it is not easy to damage the chip. Electrical characteristics of RS485: logic "1" is represented by the voltage difference between the two lines as +(2-6); logic "0" is represented by the voltage difference between the two lines as -(2~6)V. The signal level of the interface is lower than that of RS232, which is not easy to damage the chip of the interface circuit, and the level is compatible with the TTL level, which can be easily connected with the TTL circuit.
  • 2. High transmission rate ,At 10 meters, the maximum data transmission rate of RS485 can reach 35Mbps, and at 1200m, the transmission speed can reach 100Kbps.
  • 3. Strong anti-interference ability . The RS485 interface adopts a combination of a balanced driver and a differential receiver, which enhances the ability to resist common-mode interference, that is, it has good anti-noise interference.
  • 4. The transmission distance is long and there are many supporting nodes. The longest RS485 bus can transmit over 1200m (rate ≤100Kbps) and generally supports a maximum of 32 nodes. If a special 485 chip is used, it can reach 128 or 256 nodes, and the maximum can support 400 nodes.

So why can RS485 communication maintain such long-distance communication?

Because the resistance of the line becomes a non-negligible factor during long-distance communication, so there will be a voltage drop, such as a 100m special cable, assuming that the cable resistance is only 2 ohms, then when the current reaches 5a A voltage drop of 10V will be generated, which will cause interference to the signal. For example, in common serial communication, it is judged whether it is 0 or 1 according to the level of the TX and RX lines to the ground line. At this time, the power of these three lines is actually Pingdu is already in a state of relative change, so there is not much reference value.

In addition, long-distance transmission will also have various noise interference problems, etc., which cannot be ignored, and will cause interference to the communication process.

MCU uses 485 for communication

Commonly used single-chip microcomputers for RS485 communication are generally carried out through TTL to 485. The general 485 communication chips do not have automatic transceivers, and the functions need to be realized by changing pins. For example, the SP3485 module of punctual atom, when RS485RE When it is low level, it is the receiving mode; when RS485RE is high level, it is the sending mode.
insert image description here
Of course, you can also directly use the hardware for automatic transceiver design, which is basically equivalent to using a serial port!

2. Introduction of Power Line Carrier

The above introduces the use of RS485, which is a bit off topic. It happens that some 485-related designs have been done recently, so I will record it by the way. Let’s start recording the power line carrier. The following is a picture of the power line carrier module I am looking for. Here The general use is to use two at a time, one receiving end and one sending end. Of course, there is no difference in itself, because it is two-way communication.
insert image description here
In addition, there is an open source underwater robot connection diagram that I saw before. The connection diagram of the power line carrier is also clearly marked in the figure. Therefore, the power line carrier module can be used for data transmission during network communication. For example
insert image description here
, Municipal drainage pipeline inspection, underwater robots and other fields can be used, because this place requires long-distance communication, and the network cannot reach it, and wireless control cannot be performed. The parameters of a power line carrier module I am looking for can be seen below
insert image description here
. The communication distance can already reach 300m, and the distance should be able to meet the requirements.

2. Raspberry Pi network configuration

The basic module introduction has been introduced above, let’s see how to use it, here I still use the Raspberry Pi for testing, here we no longer use the Raspberry Pi automatic configuration network to connect to the Raspberry Pi, but directly through To connect the Raspberry Pi with a network cable, here are a few things to pay attention to:

First of all, here is the Raspberry Pi. If there is a network, you can see that this light will be on. It may not be there just after plugging it in, but it will be available after a while. The network options
insert image description here
here are as follows. Check the network adapter
insert image description here
and open it to see our network connection
insert image description here
The next step is to right-click and select sharing. Here, open the sharing and
insert image description here
set it to automatic mode
insert image description here
. The same is true for Ethernet, which needs to be set to automatic mode (the above steps may be redundant, but it does not affect the use)
insert image description here
After this setting, we can see the network connection status. Move the mouse close to the wifi side to see the connection.
insert image description here
Or we can enter the command to view the ip on the command line. Enter

ifconfig

You can see the ip address, because my classmate said that the ip address should not be shown to others casually, saying that there is some risk, but this ip is assigned by the router, so the following content is coded, and you should pay attention to what you see , don’t share the IP address casually.
insert image description here
Before connecting, you can also test the connectivity. We can ping him to know the situation of Unicom.
insert image description here
Then use SSH to connect, so that you can see the successful connection
insert image description here

3. Connection test

The following is the connection of the carrier module. The carrier module is a transparent transmission interface, so there is no need for any special connection, just connect it directly, connect one side to the computer, and the other side to the Raspberry Pi. After the connection, we will test the China
insert image description here
Unicom It can be seen that the connectivity is also normal. Here,
insert image description here
the power supply voltage is 12V. I use an adjustable power supply, which is more convenient . UDP record-image transmission system , if necessary, you can go to check it, here first obtain the local IP, the obtained local IP is as follows: after that, change the target IP of the socket socket to our local IP address. , after running, you can see that the transmission signal light starts to flicker, indicating that data has already been transmitted. Let's test it, and the effect is also very good!
insert image description here

insert image description here

insert image description here

insert image description here

4. Add a connection problem

Our previous ip address is achieved by checking the ip on the raspberry pie, which is inconvenient, so if we are not in the same wifi as the raspberry pie, it will not work. This problem is still very serious, so here is a special supplement Next solution.

Here I use static ip to solve it, as follows:

First of all, transfer to the network connection here: (this page can be found by searching in the computer search box)
insert image description here
Pay attention to the Ethernet in this place, this is the network interface connected with the Raspberry Pi, set a separate ip for him below
insert image description here
Then choose as follows:
insert image description here
Set up according to your own situation
insert image description here
, and then you can see the ip we modified
insert image description here
Enter:

sudo nano /etc/dhcpcd.conf

Add the following to the end:

interface eth0
static ip_address=192.168.2.1/24 # 这里24表示子网掩码255 255 255 0
static routers=192.168.2.2
static domain_name_servers=114.114.114.114

Then check your own ip
insert image description here
and try to ping it on the computer:
insert image description here

Guess you like

Origin blog.csdn.net/m0_51220742/article/details/124571402