




免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
树莓派如何采集RS485数据1、 RS485介绍RS485是有线传输串行数据的标,支持同时传输485总线上的多点数据。传输速率为10Mbps,传输距离可达50英尺。传输速率为100Kbps时,传输距离可达4000英尺。RS485总线通常为4芯或2芯,现在普遍采用2芯总线。一条总线最多支持32个设备。总线之间还可以串接,从而支持成百以上的节点。RS485主要技术规格如下:RS485 specification overviewAttributeSpecificationCablingMulti-dropNumber of devices32 transmitters32 receiversCommunications modeshalf duplexMaximum distance4000 feet 100 kbpsMaximum data rate10 Mbps 50 feetSignallingBalancedMark (data = 1)condition1.5 V to 5 V (B greater than A)Space (data = 0)condition1.5 V to 5 V (A greater than BDriver output current capability250 mA2、 RS485和树莓派的连接目前有一种RS485 Shield的设备,可以直接连接到树莓派上。硬件连接图如下:3、 配置 Update source list$ sudo apt-get update Install python-pip$ sudo apt-get install python-pipUse pip to install WiringPi (WiringPi is designed for raspberry pi to behave similarly to that of the wiring library under Arduino. After this library is installed,c or shell or python can use the function to configure and control GPIOs directly. :$ sudo pip install wiringpi Installed theassociated library files of serial ports :$ sudo apt-get install python-serial.Test whether the GPIO library and the serial library is installed or not:$ python$ import RPi.GPIO$ import serialIf there is no error , then the two libraries are installed correctly. We need to configure file /boot/cmdline.txt to remove the kernel booting information and debug message:$ sudo nano / boot / cmdline.txtYou can see the following information:dwc_otg.lpm_enable = 0 console = ttyAMA0, 115200 kgdboc = ttyAMA0, 115200 console = tty1 root = / dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwaitRemove “console = ttyAMA0, 115200 kgdboc = ttyAMA0, 115200 so that the information becomes:dwc_otg.lpm_enable = 0 console = tty1 root = / dev/mmcblk0p2 rootfstype = ext4 elevator = deadline rootwait Disable log in from the serial port:$ sudo nano / etc / inittaband comment out ” T0: 23: respawn :/ sbin / getty-L ttyAMA0 115200 vt100 Restart Raspberry Pi:$ sudo rebootNow you can use / dev/ttyAMA0 like the regular COM port.4、 测试代码Test code(serial_test.py):12345678910111213141516171819202122232425import serialport = ”/dev/ttyAMA0usart = serial.Serial(port,9600)usart.flushInput()print (“serial test: BaudRate = 9600)usart.write(“please enter the character:r”)while True:if( usart.inWaiting()0 ) :receive = usart.read(1)print ”receive: ”,receiveusart.write(“ send: ”)usart.write(receive)usart.write(“r”)5、 1 x RaspberryPi6、 1 x RS485shieldfor Raspberry Pi7、8、 3 x Male to male jumper wires9、 1 x RS232-RS485 converter10、 1 x 9DB male of serial-to-USB cable:11、12、 Wiring:13、 RS485 Shield A- RS232-RS485 converter T/R + 14、 RS485 Shield B- RS232-RS485 converter T/R- 15、 RS485 Shield GND - RS232-RS485 converter GND 16、17、6、基于RS232转RS485的测试例程硬件连接方式:硬件管脚对应关系:RS485 Shield A- RS232-RS485 converter T/R + RS485 Shield B- RS232-RS485 converter T/R- RS485 Shield GND - RS232-RS485 converter GND After the wiring is done, launch a serial terminal. We use X-CTU in our case, and set the baud rate to 9600After running serial_test.py, enter the characters in the X-CTU:18、 After the wiring is don
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 空间隔离影响分析-洞察及研究
- 声学指纹识别技术-洞察及研究
- 卷积神经网络赋能图像超分辨率重建:算法解析与多元应用
- 卡培他滨增敏联合后程加速超分割放疗:食管癌治疗的疗效解析与展望
- 2025贵州黔南人力资源开发有限责任公司招聘劳务派遣制专职民兵教练员5人笔试备考试题及答案解析
- 2025甘肃庆阳市庆城县县直事业单位选调10人考试备考题库及答案解析
- 2025广东云浮市新兴县政协办公室招募见习岗位人员2人笔试备考试题及答案解析
- 2025福建漳州市交发工贸集团有限公司诏安分公司招聘7人笔试备考题库及答案解析
- 2025安徽六安金寨县医疗保障社会监督员25人笔试备考题库及答案解析
- 2025福建左海科技有限公司选聘中层干部1人笔试参考题库附答案解析
- 迷彩九月+启航青春+课件-2025-2026学年高一上学期开学军训动员主题班会
- 2025年暑期教师研修心得-研修蓄力笃行致远
- 2024年陕西事业单位联考A类综合应用能力试题及答案
- 公共基础知识试题(附答案)
- 人教版物理九年级全一册16.1《电压》听评课记录
- 2025年湖北省中考语文真题(含答案)
- (2025年标准)被迫堕胎补偿协议书
- TCCEAS001-2022建设项目工程总承包计价规范
- 大学普通化学-课件文档
- 挡土墙计算书(共19页)
- 供配电技术实验指导书(09318)
评论
0/150
提交评论