1009 RPi0 DRS485 EN

来自Mcuzone Wiki
Mcuadm留言 | 贡献2025年4月7日 (一) 17:35的版本

Keywords

Raspberry Pi, Raspberry Pi Zero, Zero W, Zero WH, Zero 2W, USB2.0-A, Ethernet, Expansion Board, Dual RS485

I. Introduction

This expansion board is based on the Raspberry Pi Zero series development board. Utilizing the USB and power contacts on the reverse side of the Zero, it connects to the Zero via gold-plated pogo pins, expanding two RS485 interfaces, one 100M Ethernet port, and one USB 2.0 port. The expansion board acts as a USB hub, using the Zero's native USB port as a host. Thus, the Raspberry Pi Zero's built-in USB port cannot support additional external devices. The entire system is powered via USB-C, requiring no additional power for the Raspberry Pi Zero, and without occupying the 40-pin GPIO port of the Zero.

The expansion board supports the full range of Raspberry Pi Zero series development boards, including the Zero, Zero W, Zero WH, and Zero 2W.

The RS845 module is industrial-grade with power isolation, supporting speeds up to 600Kbps and 64 nodes.

II. Hardware Spec

1. 2*gold-plated pogo pins are used for power supply and USB communication on the expansion board, respectively.

2. 1*USB-C power supply interface is provided, which can be used to power the system (in this case, the Raspberry Pi Zero's Micro USB power port doesn't need additional power supply). Alternatively, you can use the Micro USB power port on the Zero for power supply (choose one power supply method).

3. 1*100M Ethernet port.

4. 1*USB 2.0 Type-A port.

5. 1*RS485 module, industrial grade, with power isolation

6. 尺寸:69*55mm;

7. PCB板材通过UL和ROHS认证,防火等级94V-0;

注意1:连接了此扩展板后Zero上的MicroUSB将不可使用。

注意2:部分系统下需要禁用OTG功能并将USB模式设置为Host模式。

1009_RPi0_DRS485_17.jpg

1009_RPi0_DRS485_18.jpg

1009_RPi0_DRS485_19.jpg

三、树莓派OS的使用

硬件平台:树莓派Zero 2W+扩展板;

软件平台:树莓派OS的版本为2024-07-04-raspios-bookworm-arm64.img.xz,树莓派OS下载地址:

https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit

(若使用树莓派Zero一代系列,只支持32位系统,请注意下载版本。)

3.1 查看硬件设备

3.1.1 查看USB设备

扩展板上的USB-A口接了无线键鼠,打开树莓派OS的终端,输入命令lsusb,如下图所示:

1009_RPi0_DRS485_01.jpg

Device 006:百兆以太网;

Device 005/004:两路USB转RS485串口;

Device 003:USB2.0-A接口(接无线键鼠);

Device 002:外挂USB Hub。

注意,如果USB口不接设备,那lsusb里是不会出现相应的设备编号的。

如果系统卡在树莓派logo处无法启动:

0007_Zero_4G_Cat1_58.jpg

或者启动后键盘鼠标等无法使用,请仔细观察顶针是否对准了镀金触点,并请在PC端打开TF卡系统分区根目录下的config.txt检查USB的初始化脚本:

0007_Zero_4G_Cat1_41.jpg

需要确认下图中的三处红框的位置是否都配置成完全,如果没有,请手动添加完整并保存文件:

# otg_mode=1(建议按此注释掉)

dtoverlay=dwc2,dr_mode=host(两处必须确保加上)

0007_Zero_4G_Cat1_57.jpg

3.1.2 查看网络设备

打开树莓派OS的终端,输入命令ifconfig -a,如下图所示:

1009_RPi0_DRS485_02.jpg

3.2 测试网络设备

3.2.1 ping包测试

可以用-I参数指定从哪个网卡开始ping包,如下所示:

ping www.mcuzone.com -I eth0

ping www.mcuzone.com -I wlan0

1009_RPi0_DRS485_03.jpg

我们也可以通过关闭某个网卡,达到强制指定通过另一个网络进行通讯,如需关闭eth0,可执行下面的命令:

sudo ifconfig eth0 down

以及通过执行下面的命令来开启eth0:

sudo ifconfig eth0 up

3.2.3 iperf3测速

Windows版iperf3下载:

http://www.mcuzone.com/down/Software.asp?ID=10000634

Linux下iperf3安装:

sudo apt-get install iperf3

百兆以太网测速结果,client模式92Mbps左右:

1009_RPi0_DRS485_04.jpg

server模式95Mbps左右:

1009_RPi0_DRS485_05.jpg

注意:USB转百兆有线网速受Zero 2W性能和USB Hub带宽占用影响,请以实际测速为准,本测速结果仅供参考。

3.3 双RS485串口测试

测试需要安装串口软件CuteCom,安装命令为:

sudo apt install cutecom

安装完毕后,点击桌面左上角的树莓派图标,在“System Tools”有CuteCom的快捷方式:

0012_MPUUART_MP4232_01.jpg

如果在使用过程中有权限不足的问题,请打开树莓派OS终端,输入:

sudo cutecom

来启动CuteCom。两个RS485接口,如下图:

3.3.1 RS485和PC数据收发测试

1009_RPi0_DRS485_21.jpg

测试ttyUSB0与PC之间的数据收发:

在PC端插上一个USB转485的转换器,与扩展板上的RS485接口(ttyUSB0)相连,各自打开串口软件进行收发,结果如下:

树莓派OS端/Windows端:

1009_RPi0_DRS485_07.jpg

经过实测,波特率最高可达到550kbps(以传输数据不发生乱码、缺失为准)。

测试ttyUSB1与PC之间的数据收发:

在PC端插上一个USB转485的转换器,与扩展板上的RS485接口(ttyUSB1)相连,各自打开串口软件进行收发,结果如下:

树莓派OS端/Windows端:

1009_RPi0_DRS485_08.jpg

经过实测,波特率最高可达到600kbps(以传输数据不发生乱码、缺失为准)。

3.2.2 两路RS485间数据收发测试

1009_RPi0_DRS485_20.jpg

扩展板上的两个RS485接口(ttyUSB0与ttyUSB1)相连,各自打开串口软件进行收发,结果如下:

ttyUSB0的树莓派OS端/ttyUSB1的树莓派OS端:

1009_RPi0_DRS485_09.jpg

经过实测,波特率最高可达到2.5Mbps(以传输数据不发生乱码、缺失为准)。

四、扩展板选型表

1006_RPi0_4G_MiniPCIe_64.jpg

联系我们

4f7e81daf8791971.jpg 79c020da7ad0af9b.jpg 2851e01a0549e6f7.gif 0003_bb.jpg 0005_qq.jpg QQ:8204136

邮件:mcuzone@vip.qq.com

电话:13957118045

如本页面有任何疏漏、错误或者侵权,请通过上述途径联系我们,谢谢!

Copyright 2004-2025 野芯科技

T