树莓派如何采集rs485数据

树莓派如何采集rs485数据

ID:34776760

大小:444.95 KB

页数:6页

时间:2019-03-10

树莓派如何采集rs485数据_第1页
树莓派如何采集rs485数据_第2页
树莓派如何采集rs485数据_第3页
树莓派如何采集rs485数据_第4页
树莓派如何采集rs485数据_第5页
资源描述:

《树莓派如何采集rs485数据》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、树莓派如何采集RS485数据1、RS485介绍RS485是有线传输串行数据的标,支持同时传输485总线上的多点数据。传输速率为10Mbps,传输距离可达50英尺。传输速率为100Kbps时,传输距离可达4000英尺。RS485总线通常为4芯或2芯,现在普遍采用2芯总线。一条总线最多支持32个设备。总线之间还可以串接,从而支持成百以上的节点。RS485主要技术规格如下:RS485specificationoverviewAttributeSpecificationCablingMulti-dropNumberofdevices32transmitt

2、ers32receiversCommunicationsmodeshalfduplexMaximumdistance4000feet@100kbpsMaximumdatarate10Mbps@50feetSignallingBalancedMark(data=1)condition1.5Vto5V(BgreaterthanA)Space(data=0)condition1.5Vto5V(AgreaterthanB>Driveroutputcurrentcapability250mA2、RS485和树莓派的连接目前有一种RS485Shield的设备

3、,可以直接连接到树莓派上。硬件连接图如下:1、配置Updatesourcelist$sudoapt-getupdateInstallpython-pip$sudoapt-getinstallpython-pipUsepiptoinstallWiringPi(WiringPiisdesignedforraspberrypitobehavesimilarlytothatofthewiringlibraryunderArduino. Afterthislibraryis installed,c orshellorpythoncanusethe func

4、tiontoconfigureandcontrolGPIOsdirectly. :$sudopipinstallwiringpiInstalledthe associatedlibraryfilesofserialports:$sudoapt-getinstallpython-serial.TestwhethertheGPIOlibraryandtheseriallibraryisinstalledornot:$python$importRPi.GPIO$importserialIfthereisnoerror,thenthetwolibrari

5、esareinstalledcorrectly.Weneedtoconfigure file‘/boot/cmdline.txt’toremovethekernelbootinginformationanddebugmessage:$sudonano/boot/cmdline.txtYoucanseethefollowinginformation:dwc_otg.lpm_enable=0console=ttyAMA0,115200kgdboc=ttyAMA0,115200console=tty1root=/dev/mmcblk0p2rootfst

6、ype=ext4elevator=deadlinerootwaitRemove“console=ttyAMA0,115200kgdboc=ttyAMA0,115200″sothattheinformationbecomes:dwc_otg.lpm_enable=0console=tty1root=/dev/mmcblk0p2rootfstype=ext4elevator=deadlinerootwaitDisableloginfromtheserialport:$sudonano/etc/inittabandcommentout”T0:23:re

7、spawn:/sbin/getty-LttyAMA0115200vt100″RestartRaspberryPi:$sudorebootNowyoucanuse/dev/ttyAMA0liketheregularCOMport.1、测试代码Testcode(serial_test.py) :12345678910111213importserial port=”/dev/ttyAMA0″ usart=serial.Serial(port,9600) usart.flushInput() print(“serialtest:BaudRate=960

8、0″) usart.write(“pleaseenterthecharacter:r”) whileTrue:141516171819

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。