树莓派如何采集RS数据Word文档下载推荐.docx
- 文档编号:1501810
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:6
- 大小:394.39KB
树莓派如何采集RS数据Word文档下载推荐.docx
《树莓派如何采集RS数据Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《树莓派如何采集RS数据Word文档下载推荐.docx(6页珍藏版)》请在冰点文库上搜索。
32transmitters
32receivers
Communicationsmodes
halfduplex
Maximumdistance
4000feet@100kbps
Maximumdatarate
10Mbps@50feet
Signalling
Balanced
Mark(data=1)
condition
1.5Vto5V(BgreaterthanA)
Space(data=0)
1.5Vto5V(AgreaterthanB>
Driveroutputcurrentcapability
250mA
2、RS485和树莓派的连接
目前有一种RS485Shield的设备,可以直接连接到树莓派上。
硬件连接图如下:
3、配置
Updatesourcelist
$sudoapt-getupdate
Installpython-pip
$sudoapt-getinstallpython-pip
UsepiptoinstallWiringPi(WiringPiisdesignedforraspberrypitobehavesimilarlytothatofthewiringlibraryunderArduino.
Afterthislibraryis
installed,c
orshellorpythoncanusethe
functiontoconfigureandcontrolGPIOsdirectly.
:
$sudopipinstallwiringpi
Installedthe
associatedlibraryfilesofserialports:
$sudoapt-getinstallpython-serial
.TestwhethertheGPIOlibraryandtheseriallibraryisinstalledornot:
$python
$importRPi.GPIO
$importserial
Ifthereisnoerror,thenthetwolibrariesareinstalledcorrectly.
Weneedtoconfigure
file‘/boot/cmdline.txt’toremovethekernelbootinginformationanddebugmessage:
$sudonano/boot/cmdline.txt
Youcanseethefollowinginformation:
dwc_otg.lpm_enable=0console=ttyAMA0,115200kgdboc=ttyAMA0,115200console=tty1root=/dev/mmcblk0p2rootfstype=ext4elevator=deadlinerootwait
Remove“console=ttyAMA0,115200kgdboc=ttyAMA0,115200″sothattheinformationbecomes:
dwc_otg.lpm_enable=0console=tty1root=/dev/mmcblk0p2rootfstype=ext4elevator=deadlinerootwait
Disableloginfromtheserialport:
$sudonano/etc/inittab
andcommentout”T0:
23:
respawn:
/sbin/getty-LttyAMA0115200vt100″
RestartRaspberryPi:
$sudoreboot
Nowyoucanuse/dev/ttyAMA0liketheregularCOMport.
4、测试代码
Testcode(serial_test.py)
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
importserial
port=”/dev/ttyAMA0″
usart=serial.Serial(port,9600)
usart.flushInput()
print(“serialtest:
BaudRate=9600″)
usart.write(“pleaseenterthecharacter:
\r”)
whileTrue:
if(usart.inWaiting()>
0):
receive=usart.read
(1)
print”receive:
”,receive
usart.write(“
send:
’”)
usart.write(receive)
usart.write(“‘\r”)
5、1xRaspberry
Pi
6、1xRS485
shield
forRaspberryPi
7、
8、3xMaletomalejumperwires
9、1x
RS232-RS485converter
10、
1x
9DBmaleofserial-to-USBcable:
11、
12、Wiring:
13、RS485Shield‘A’->
RS232-RS485converter‘T/R+‘
14、RS485Shield‘B’->
RS232-RS485converter‘T/R-‘
15、RS485Shield‘GND’->
RS232-RS485converter’GND‘
16、
17、
6、基于RS232转RS485的测试例程
硬件连接方式:
硬件管脚对应关系:
RS485Shield‘A’->
RS485Shield‘B’->
RS485Shield‘GND’->
Afterthewiringisdone,launchaserialterminal.WeuseX-CTUinourcase,andsetthebaudrate
to9600
Afterrunningserial_test.py,enterthecharactersintheX-CTU:
18、Afterthewiringisdone,launchaserialterminal.WeuseX-CTUinourcase,andsetthebaudrate
to9600:
19、
20、Afterrunningserial_test.py,enterthecharactersintheX-CTU:
21、
22、
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 树莓派 如何 采集 RS 数据