< >
Home » TK1入门教程硬件篇 » TK1入门教程硬件篇-连接Arduino

TK1入门教程硬件篇-连接Arduino

TK1入门教程硬件篇-连接Arduino

说明:

  • 介绍如何使用TK1连接Arduino

FTDI内核模块:

  • 连接Arduino的USB端口,使用FTDI serial-to-USB转换:
$ lsusb
Bus 002 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
  • 默认TK1不支持FTDI转换设备,检测是否支持:
$ zcat /proc/config.gz | grep FTDI
# CONFIG_USB_SERIAL_FTDI_SIO is not set
# CONFIG_USB_FTDI_ELAN is not set

编译FTDI kernel 模块:

(1)下载L4T内核源码:

  • 内核地址:https://developer.nvidia.com/linux-tegra-rel-19,不同版本使用不同链接
  • 下载后,放到TK1的~/kernel目录
  • 解压:
tar xvjf kernel_src.tar.bz2
  • 复制现有内核配置到新内核:
zcat /proc/config.gz > ~/kernel/.config
  • 配置:
sudo apt-get install ncurses-bin libncurses5-dev
make menuconfig
  • 找到Device Drivers -> USB Support -> USB Serial Converter Support
  • 设置USB FTDI Single Port Serial Driver为M类型
  • 验证:
$ cat .config | grep FTDI
CONFIG_USB_SERIAL_FTDI_SIO=m
# CONFIG_USB_FTDI_ELAN is not set
  • 编译内核:
make prepare
make modules_prepare

make M=drivers/usb/serial/
  Building modules, stage 2.
  MODPOST 2 modules
  CC      drivers/usb/serial/baseband_usb_chr.mod.o
  LD [M]  drivers/usb/serial/baseband_usb_chr.ko
  CC      drivers/usb/serial/ftdi_sio.mod.o
  LD [M]  drivers/usb/serial/ftdi_sio.ko
  • 安装模块:
sudo cp drivers/usb/serial/ftdi_sio.ko /lib/modules/$(uname -r)/kernel
sudo depmod -a
  • 验证安装:
$ dmesg | grep usb

[   57.385970] usb 2-1.5: new full-speed USB device number 5 using tegra-ehci
[   57.407931] usb 2-1.5: New USB device found, idVendor=0403, idProduct=6001
[   57.407950] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   57.407964] usb 2-1.5: Product: FT232R USB UART
[   57.407976] usb 2-1.5: Manufacturer: FTDI
[   57.407987] usb 2-1.5: SerialNumber: A601NG2B
[   57.479238] ftdi_sio: version magic '3.10.24 SMP preempt mod_unload ARMv7 p2v8 ' should be '3.10.24-gf455cd4 SMP preempt mod_unload ARMv7 p2v8 '
[   57.504885] usbcore: registered new interface driver ftdi_sio
[   57.507384] usbserial: USB Serial support registered for FTDI USB Serial Device
[   57.508073] ftdi_sio 2-1.5:1.0: FTDI USB Serial Device converter detected
[   57.508917] usb 2-1.5: Detected FT232RL
[   57.508934] usb 2-1.5: Number of endpoints 2
[   57.508948] usb 2-1.5: Endpoint 1 MaxPacketSize 64
[   57.508960] usb 2-1.5: Endpoint 2 MaxPacketSize 64
[   57.508971] usb 2-1.5: Setting MaxPacketSize 64
[   57.511143] usb 2-1.5: FTDI USB Serial Device converter now attached to ttyUSB0
  • FTDI分配到/dev/ttyUSB0

使用Arduino IDE

  • 安装IDE:
sudo apt-get install arduino arduino-core
  • 图示:

请输入图片描述

测试:

  • 连上Arduino板子,打开IDE,选择对应的板子,及端口号
  • 上传点亮程序到Arduino板子。

ROS与Arduino通信的实验:

  • 运行命令:rosrun rosserial_python serial_node.py /dev/ttyACM0
  • 出现错误:(Unable to sync with device; possible link problem or )
  • 解决方法:在#include <ros.h>前加入#define USE_USBCON
  • 原因:在“Arduinohardware.h”的第54行,做了判断。
  • 我们可以自己根据硬件设备,指定对应的连接类型。

参考:

  • http://blog.csdn.net/sinat_31135199/article/details/52691011?locationNum=10
  • http://answers.ros.org/question/164191/rosserial-arduino-cant-connect-arduino-micro/
  • http://www.elinux.org/Jetson/Tutorials/Communicate_To_Arduino
  • http://www.elinux.org/Jetson/Tutorials/Program_An_Arduino

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: tk1入门教程硬件篇