【问题标题】:Acquiring data from LeddarVu8 Lidar using Arduino使用 Arduino 从 LeddarVu8 激光雷达获取数据
【发布时间】:2018-01-10 23:37:13
【问题描述】:

我正在做一个与此类似的房间可视化项目(取自this video):

我使用的是 leddartech 的 LeddarVu8(见下图),arduino uno(带有 rs485shield):

我也使用了 leddartech 提供的 simple16channel (no lcd) 的代码:

            #include "C:\Program Files (x86)\Arduino\libraries\Leddar.h"
            /*
             Simple Leddar(TM) Example - Without LCD
             Language: Arduino

             This program lists the detections read on the serial port of the Arduino.
             Can be used with Arduino IDE's Serial Monitor.

             Shields used:
             * RS-485 Shield

             Created 01 Jun. 2015
             by Pier-Olivier Hamel

             This example code is in the public domain.
            */
            Leddar16 Leddar1(115200,1);
            //Baudrate = 115200
            //Modbus slave ID = 01

            void setup()
            {
                //Initialize Leddar 
                Leddar1.init();
            }
            void loop()
            {
                char result = Leddar1.getDetections();
                if (result >= 0)
                {
                    for (int i = 0; i < Leddar1.NbDet; i++)
                    {
                        Serial.print("Segment: ");
                        Serial.print(Leddar1.Detections[i].Segment);
                        Serial.print("      Distance: ");
                        Serial.print(Leddar1.Detections[i].Distance);
                        Serial.print("\n");
                    }  
                }
                else
                {
                    Serial.print("Error: "); 
                    Serial.print((int)result);
                    Serial.print("\n");
                }
                delay(50);
            }

(来自https://support.leddartech.com/downloads/files/89-leddarsdk3-2-0-pi2-tar-gz

问题是arduino的串口监视器只输出一系列?????。这是为什么呢?

【问题讨论】:

    标签: arduino-uno lidar


    【解决方案1】:

    问题是arduino的串口监视器只输出一系列?????。这是为什么呢?

    因为您已将 LIDAR 的 TX 连接到 Arduino 的 TX。串行监视器窗口“侦听”Arduino TX 引脚(通过 USB),因此串行监视器实际上是在侦听激光雷达。激光雷达串行运行在 115200,但您的串行监视器可能设置为 9600。当波特率不匹配时,您会得到垃圾字符。

    还请注意,您有两个相互连接的串行 TX 引脚。如果 Arduino 和 LIDAR 同时尝试传输,这也会损坏字符。

    您可以将 LIDAR RX 连接到 Arduino TX,并将 LIDAR TX 连接到 Arduino RX。这将允许您在串行监视器窗口中查看 Leddar 库命令。它还会导致所有Serial 打印到激光雷达(和PC)。如果 Leddar 命令包具有特殊格式,这可能没问题。这将允许 Leddar 忽略您的调试打印,因为它们的格式不正确。

    在该配置中,您必须断开 Arduino 引脚 0 才能通过 USB 上传新草图。有些人在那根电线上放了一个开关,以便于断开连接。

    【讨论】:

    • 我尝试根据您的建议更改所有内容,但仍然无法获得良好的数据。我认为它的 leddar 所需的 modbus 通信没有得到妥善处理。
    • @RamahWart,您是否将串行监视器波特率设置为 115200?你看到了什么数据?我刚刚注意到您在 RS485 模块上连接了 DE 和 RE。 RS485 要求您在发送时设置 DE HIGH,在接收时设置为 LOW(连接到 Arduino 引脚)。此外,在发送所有字符之前,DE 行必须保持高电平(比Serial.flush() 有点棘手,请检查库)。如果可以接收您发送的内容(检查库),则 RE 线可以一直为 HIGH(到 VCC)。
    • 太好了,我现在可以通过我的 leddar 与 arduino 进行通信了。通过将 RE DE 连接到 pin3 来解决问题。 (现在到我的下一个问题,在修改 modbus 代码时遇到问题,我不知道是否应该提出另一个问题或继续这个线程。
    • @RamahWart,是的,另一个问题会更好。 Modbus 软件专家会更加关注这个标题。这个主要是硬件问答。
    猜你喜欢
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    • 2021-07-15
    • 2020-11-08
    • 1970-01-01
    相关资源
    最近更新 更多