树莓派RS485调试指南

上传人:oq****t 文档编号:1698774 上传时间:2017-07-08 格式:DOC 页数:4 大小:239.50KB
返回 下载 相关 举报
树莓派RS485调试指南_第1页
第1页 / 共4页
树莓派RS485调试指南_第2页
第2页 / 共4页
树莓派RS485调试指南_第3页
第3页 / 共4页
树莓派RS485调试指南_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《树莓派RS485调试指南》由会员分享,可在线阅读,更多相关《树莓派RS485调试指南(4页珍藏版)》请在金锄头文库上搜索。

1、树莓派 RS485 调试指南QQ 9230562891、硬件准备2、操作系统环境设置We need to modify two files: /boot/cmdline.txt and /etc/inittab. Modify /boot/cmdline.txt: Replace the original content: dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline root

2、wait With: dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait Modify /etc/inittab: Comment out the last line of /etc/inittab. To comment out, it simply addess a #. $ sudo vi /etc/inittab 1. T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 Save the chang

3、es, and reboot. We will get an UART with baud rate of 115200. 3、驱动及相关软件设置Sudo apt-get install python-pipSudo apt-get install serial-python$ pythonimport RPi.GPIOimport serialIf there is no error , then the two libraries are installed correctly.退出:ctrl+d或 exit()如果在执行 import 时不报错,则认为这两个库已经正确安装。4、RS485

4、 测试连线图如下:RS485-RS232 的转换器有 3 个接口,A 、B 、接地。其中 A 口是 TR+,B 口是 TR-。管脚定义如下:转换器的 A 口连 RS485 shield 的 A 口。转换器的 B 口连 RS485 shield 的 B 口。我们测试的方法是:PC 机通过 USB 转 232 连 232 模块, 232 模块通过转换后接入到RS485 shield。PC 机上启动超级终端,输入字符,在树莓派上能看到,就说明 RS485 Shield 能正确处理输入信号。启动超级终端,设置波特率为 9600,控制流无、数据位 8、停止位 1、奇偶校验位无。在树莓派上运行 pytho

5、n 程序。源代码及运行方法如下:piraspberrypi:$ cat *.pyimport serialport=/dev/ttyAMA0usart=serial.Serial(port,9600)usart.flushInput()print(serial test Baudrae = 9600)usart.write(please enter the character:r)while True:if (usart.inWaiting()0):receive = usart.read()print ( receive:),receiveusart.write(r)usart.write( send:)usart.write(r)usart.write(receive)usart.write(r)运行该程序:Sudo ./serial_test.py运行结果如下:在超级终端中输入的字符全部在树莓派上显示了。说明 RS485 shield 能够收到信号,并正确识别。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号