概述
RS01毫米波雷达测距传感器是基于60GHz微波脉冲相干雷达(PCR)技术的测距传感器,该传感器把脉冲雷达低功耗的优势与高精度相干雷达相结合,能以超低功耗实现毫米级精度的距离测量。RS01传感器不受例如噪声、灰尘、颜色、直射或散射光线等任何自然干扰源的影响,能够一次完成5个检测目标的距离识别,量程高达6米。
相比于传统的微波传感器需要复杂的参数配置,RS01传感器设计可使用PC软件灵活的实现可视化参数配置,用户可以快速完成复杂的传感器参数配置。此外,传感器采用标准Modbus-RTU协议的RS485接口,可以直接连接到各种标准工控主机上使用。
产品参数
- 工作电压:6~12V DC
- 工作温度:-40℃~85℃
- 测量量程:200-6000 mm
- 通信接口:RS485
- 通信协议:Modbus-RTU
- 电缆长度:1.5m
- 接口类型:剥口镀锡线
| 线序 |颜色 | 功能 |
| :---- | :---- | :---- |
| 1 | 黄色 | 比较值输出,开漏模式,低电平有效 |
| 2 | 绿色 | RS485-B |
| 3 | 白色 | RS485-A |
| 4 | 黑色 | 电源负 |
| 5 | 红色 | 电源正 |
寄存器说明
地址 | 名称 | 读写 | 数据范围 | 默认值 | 描述 |
---|---|---|---|---|---|
0x00 | PID寄存器 | R | 0x0000-0xFFFF | 0x01E9 | 产品的PID值(型号验证) |
0x01 | VID寄存器 | R | 0x0000-0xFFFF | 0x3343 | 产品的VID值(厂商验证) |
0x02 | 设备地址寄存器 | R/W | 0x0001-0x00F7 | 0x000E | 模块的设备地址(1~247)[传感器地址未知时,可通过广播地址0x00做写入寄存器操作,此时传感器不会有数据输出] 断电保存,立即生效 |
0x03 | 串口参数控制寄存器1 | R/W | 0x0000-0xFFFF | 0x0008 | 模块波特率 0x0001---2400 0x0003---9600 0x0004---14400 0x0005---19200 0x0006---38400 0x0007---57600 0x0008---115200 0x0009---1000000 Other----115200 断电保存,重启后生效 |
0x04 | 串口参数控制寄存器2 | R/W | 0x0000-0xFFFF | 0x0001 | 模块校验位H 停止位L 0x00--无 0x00--1Byte 0x01--Even 0x01--1Byte 0x02--Odd 0x02--1Byte Other--无 0x03--2Byte Other--1Byte 断电保存,重启后生效 |
0x05 | VERSION | R | 0x0000-0xFFFF | 0x1000 | 固件版本号:0x1000代表V1.0.0.0 |
0x06 | 检测目标数 | R | 0x0000-0x0005 | 0x0000 | 当前检测到的目标数量 |
0x07 | 目标1的距离 | R | 0x0000~0x19C8 | 0x0000 | 目标1的距离(单位mm) |
0x08 | 目标1的强度 | R | 0x0000~0x2710 | 0x0000 | 目标1的强度值 |
0x09 | 目标2的距离 | R | 0x0000~0x19C8 | 0x0000 | 目标2的距离(单位mm) |
0x0A | 目标2的强度 | R | 0x0000~0x2710 | 0x0000 | 目标2的强度值 |
0x0B | 目标3的距离 | R | 0x0000~0x19C8 | 0x0000 | 目标3的距离(单位mm) |
0x0C | 目标3的强度 | R | 0x0000~0x2710 | 0x0000 | 目标3的强度值 |
0x0D | 目标4的距离 | R | 0x0000~0x19C8 | 0x0000 | 目标4的距离(单位mm) |
0x0E | 目标4的强度 | R | 0x0000~0x2710 | 0x0000 | 目标4的强度值 |
0x0F | 目标5的距离 | R | 0x0000~0x19C8 | 0x0000 | 目标5的距离(单位mm) |
0x10 | 目标5的强度 | R | 0x0000~0x2710 | 0x0000 | 目标5的强度值 |
0x11 | 测量起始位置 | R/W | 0x0046~0x19C8 | 0x00C8 | 测量起始位置(单位mm) 断电保存,立即生效 |
0x12 | 测量结束位置 | R/W | 0x0046~0x19C8 | 0x1770 | 测量结束位置(单位mm) 断电保存,立即生效 |
0x13 | 起始阈值 | R/W | 0x0064~0x2710 | 0x0190 | 起始阈值与结束阈值组成阈值线,当测量目标的反射强度超过阈值线即被识别为有效目标 断电保存,立即生效 |
0x14 | 结束阈值 | R/W | 0x0064~0x2710 | 0x0190 | 结束阈值 断电保存,立即生效 |
0x15 | 模块灵敏度 | R/W | 0x0000~0x0004 | 0x0002 | 该寄存器用于调节传感器的测量灵敏度 断电保存,立即生效 |
0x16 | 比较偏移值 | R/W | 0x0000~0xFFFF | 0x0000 | “比较偏移值”是相对于阈值线的偏移量(该寄存器值为有符号数),当传感器视角内目标强度超过比较值线,则传感器OUT端口输出低电平 断电保存,立即生效 |
0x17 | 恢复出厂设置 | R/W | 0x0000~0x0000 | 0x0000 | 任意值写入该寄存器可将所有寄存器恢复到出厂默认值 |
使用教程
准备
- 硬件
- 1 x [RS01毫米波雷达模块]
- 1 x USB/RS232/RS485/TTL 协议转换器
- 1 x USB数据线
- 软件
- 1 x DFRobot_Radar.exe
-在IDE中打开Library Manager(Ctrl+Shift+I),搜索并安装RS01及DFRobot_RTU库
- 1 x DFRobot_Radar.exe
- 传感器与USB/RS232/RS485/TTL 协议转换器接线示意图
上位机软件[DFRobot_Radar.exe]读取距离
- 使用说明
- 正确连线后,打开DFRobot_Radar.exe上位机。
- 选择正确的串口,默认地址为14,默认波特率为115200,默认数据位为8,无校验位,停止位为1。
- 点"连接设备"后,选"启动测量"即可。
连接示意图
传感器与DFRobot Leonardo和TTL转RS485扩展板接线示意图
传感器与DFRduino UNO R3 和TTL转RS485扩展板接线示意图
传感器与DFRduino Mega1280控制器和TTL转RS485扩展板接线示意图
使用Arduino库读取测量数据示例代码
/*!
* @file getModuleInfo.ino
* @brief Read all the register data from the sensor
* @details Experimental phenomenon: serial print sensor basic information, measurement parameters and measured data
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [qsjhyy](yihuan.huang@dfrobot.com)
* @version V1.0
* @date 2021-07-06
* @url https://github.com/DFRobot/DFRobot_RS01
*/
#include <DFRobot_RS01.h>
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
#include <SoftwareSerial.h>
#endif
#define DEFAULT_DEVICE_ADDRESS 0x000E
/**
* DFRobot_RS01 constructor
* addr: modbus slave address(range1~247)or broadcast address(0x00)
* If it's configured a broadcast address, send a broadcast packet, and all slaves on bus will process it but not respond
*/
DFRobot_RS01 sensor(/*addr =*/DEFAULT_DEVICE_ADDRESS);
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
#endif
/* Print measured data */
void print_measure_data(int number, uint16_t distance, uint16_t intensity)
{
Serial.print("target ");
Serial.print((number + 1) / 2);
Serial.print(" distance: ");
Serial.print(distance);
Serial.print(" ");
for(uint16_t i=distance/10; i>0; i--)
Serial.print("-");
Serial.println();
Serial.print("target ");
Serial.print((number + 1) / 2);
Serial.print(" intensity: ");
Serial.print(intensity);
Serial.print(" ");
for(uint16_t i=intensity/10; i>0; i--)
Serial.print("+");
Serial.println();
}
void setup(void)
{
Serial.begin(115200);
Stream *_serial;
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
mySerial.begin(115200); // Excessive baud rate of UNO soft serial port will makes communication unstable, 9600 is recommended
_serial = &mySerial;
#elif defined(ESP32)
Serial1.begin(115200, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
_serial = &Serial1;
#else
Serial1.begin(115200);
_serial = &Serial1;
#endif
/**
* Init function
* _serial Serial ports for communication, supporting hard and soft serial ports
* returning 0 means reading succeeds
*/
while( NO_ERROR != sensor.begin(/*s =*/_serial) ){
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
Serial.println("Begin ok!");
Serial.println();
}
void loop()
{
Serial.println("-----------------read module basic information---------------------");
/**
* retrieve the basic information from the sensor and buffer it into the basicInfo structure that stores information:
* basicInfo structure members:
* PID: module PID
* VID: module VID
* modbusAddr: module communication address
* baudrate: module baud rate
* checkbit: check bit
* stopbit: stop bit
* versions: firmware version number
* returning 0 means reading succeeds
*/
if(0 == sensor.refreshBasicInfo()){
/* Module PID, the default value is 0x01E9 (The highest two of 16-bit data are used to determine SKU type: 00: SEN, 01: DFR, 10: TEL, the next 14 are numbers.)(SEN0489) */
Serial.print("PID: 0x");
Serial.println(sensor.basicInfo.PID, HEX);
/* Module VID, the default value is 0x3343(represent manufacturer is DFRobot) */
Serial.print("VID: 0x");
Serial.println(sensor.basicInfo.VID, HEX);
/* Module communication address, the default value is 0x000E, module device address(1~247) */
Serial.print("mailing address: ");
Serial.println(sensor.basicInfo.modbusAddr);
/* Module baud rate, the default value is 0x0009:
* 0x0001---2400 0x0002---4800 0x0003---9600 0x0004---14400 0x0005---19200
* 0x0006---38400 0x0007---57600 0x0008---115200 0x0009---1000000 */
Serial.print("baudrate: 0x");
Serial.println(sensor.basicInfo.baudrate, HEX);
/* Module check bit and stop bit, the default value is 0x0001
* check bit: 0 is none; 1 is even; 2 is odd
* stop bit: 1bit; 2bit */
Serial.print("check bit: ");
Serial.println(sensor.basicInfo.checkbit);
Serial.print("stop bit: ");
Serial.println(((sensor.basicInfo.stopbit & 0x00FF) + 1)/2);
/* Firmware version number: 0x1000 represents V1.0.0.0 */
Serial.print("versions: 0x");
Serial.println(sensor.basicInfo.versions, HEX);
}else{
Serial.println("Failed to read basic information!!!");
}
Serial.println();
Serial.println("-----------------read module measurement config--------------------");
/**
* Retrieve the currently configured parameters from the sensor and buffer it into the structure measurementConfig that stores information:
* measurementConfig structure members:
* startPosition: current measurement start position set value
* stopPosition: current measurement stop position set value
* initialThreshold: current initial threshold set value
* endThreshold: current end threshold set value
* moduleSensitivity: current module sensitivity set value
* comparisonOffset: current comparison offset set value
* returning 0 means reading succeeds
*/
if(0 == sensor.refreshMeasurementConfig()){
/* current measurement start position set value, 0x0046~0x19C8, can't be greater than the stop position set value */
Serial.print("start position : ");
Serial.println(sensor.measurementConfig.startPosition);
/* current measurement stop position set value, 0x0046~0x19C8, can't be less than the start position set value */
Serial.print("stop position : ");
Serial.println(sensor.measurementConfig.stopPosition);
/* current initial threshold set value */
Serial.print("initial threshold : ");
Serial.println(sensor.measurementConfig.initialThreshold);
/* current end threshold set value */
Serial.print("end threshold : ");
Serial.println(sensor.measurementConfig.endThreshold);
/* current module sensitivity set value */
Serial.print("module sensitivity : ");
Serial.println(sensor.measurementConfig.moduleSensitivity);
/* current comparison offset set value */
Serial.print("comparison offset : ");
Serial.println(sensor.measurementConfig.comparisonOffset);
}else{
Serial.println("Failed to read measurement config!!!");
}
Serial.println();
Serial.println("------------------Read module measurement data---------------------");
/**
* re-read the measured data from the sensor and buffer it into the array dataBuf[11] that stores information:
* dataBuf[0]: the number of objects currently detected
* dataBuf[1]: measured distance to the first object; dataBuf[2]: measured intensity of the first object
* dataBuf[3]: measured distance to the second object; dataBuf[4]: measured intensity of the second object
* dataBuf[5]: measured distance to the third object; dataBuf[6]: measured intensity of the third object
* dataBuf[7]: measured distance to the fourth object; dataBuf[8]: measured intensity of the fourth object
* dataBuf[9]: measured distance to the fifth object; dataBuf[10]: measured intensity of the fifth object
* returning 0 means reading succeeds
*/
if(0 == sensor.refreshMeasurementData()){
/*the number of objects currently detected*/
Serial.print("target amount: ");
Serial.println(sensor.dataBuf[0]);
Serial.println();
/*measured data*/
for(int i=1; i<11; i+=2){
print_measure_data(i, sensor.dataBuf[i], sensor.dataBuf[i+1]);
}
}else{
Serial.println("Failed to read measurement data!!!");
}
Serial.println("\n");
delay(3000);
}
使用DFRobot_RTU库读取传感器寄存器
恢复寄存器为出厂设置样例代码
#include "DFRobot_RTU.h"
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
#include <SoftwareSerial.h>
#endif
#define SLAVE_ADDR_DEFAULT ((uint16_t)0x0E)
#define SLAVE_BAUDRATE_DEFAULT ((uint32_t)115200)
typedef enum{
ePid,
eVid,
eAddr,
eComCtlL,
eComCtlH,
eVersion,
eNbTargets,
eDist1,
eSignalIntensity1,
eDist2,
eSignalIntensity2,
eDist3,
eSignalIntensity3,
eDist4,
eSignalIntensity4,
eDist5,
eSignalIntensity5,
eDetectionStartPos,
eDetectionStopPos,
eStartThreshold,
eStopThreshold,
eSensitivity,
eComparisonOffset,
eRestoreFactorySetting,
eNbOfReg
}eRegIndex_t;//Sensor register index
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_RTU modbus(/*s =*/&mySerial);
#else
DFRobot_RTU modbus(/*s =*/&Serial1);
#endif
volatile uint16_t cr = 0;
void setup() {
Serial.begin(9600);
while(!Serial){ //Waiting for USB Serial COM port to open.
}
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
mySerial.begin(SLAVE_BAUDRATE_DEFAULT);
#elif defined(ESP32)
Serial1.begin(SLAVE_BAUDRATE_DEFAULT, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
Serial1.begin(SLAVE_BAUDRATE_DEFAULT);
#endif
modbus.setTimeoutTimeMs(500);
delay(1000);
}
uint16_t ret;
void loop() {
ret = modbus.writeHoldingRegister(/*id =*/SLAVE_ADDR_DEFAULT, /*reg =*/ eRestoreFactorySetting, /*val =*/0x00);//Write 0 to the register to restore factory Settings
if(ret == 0){
Serial.println("The factory Settings are restored successfully!");
}else{
Serial.print("Failed to restore factory Settings. The error code is:");
Serial.println(ret);
}
delay(1000);
}
!
读取测量数据样例代码
#include "DFRobot_RTU.h"
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
#include <SoftwareSerial.h>
#endif
#define SLAVE_ADDR_DEFAULT ((uint16_t)0x0E)
#define SLAVE_BAUDRATE_DEFAULT ((uint32_t)115200)
typedef enum{
ePid,
eVid,
eAddr,
eComCtlL,
eComCtlH,
eVersion,
eNbTargets,
eDist1,
eSignalIntensity1,
eDist2,
eSignalIntensity2,
eDist3,
eSignalIntensity3,
eDist4,
eSignalIntensity4,
eDist5,
eSignalIntensity5,
eDetectionStartPos,
eDetectionStopPos,
eStartThreshold,
eStopThreshold,
eSensitivity,
eComparisonOffset,
eRestoreFactorySetting,
eNbOfReg
}eRegIndex_t;//Sensor register index
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_RTU modbus(/*s =*/&mySerial);
#else
DFRobot_RTU modbus(/*s =*/&Serial1);
#endif
uint16_t cr = 0,ret,rcvbuf[eNbOfReg];
void setup() {
Serial.begin(9600);
while(!Serial){ //Waiting for USB Serial COM port to open.
}
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
mySerial.begin(SLAVE_BAUDRATE_DEFAULT);
#elif defined(ESP32)
Serial1.begin(SLAVE_BAUDRATE_DEFAULT, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
Serial1.begin(SLAVE_BAUDRATE_DEFAULT);
#endif
modbus.setTimeoutTimeMs(500);
ret = modbus.readHoldingRegister(SLAVE_ADDR_DEFAULT,ePid,rcvbuf,eNbOfReg);
if(ret == 0){
Serial.println("-----------------read module basic information---------------------");
/* module PID, the default value is 0x01E9 (the highest two values are used as class to judge 00: SEN、01: DFR、10: TEL, the next 14 numbers as num)(SEN0489) */
Serial.print("PID: 0x");
Serial.println(rcvbuf[ePid], HEX);
/* module VID, the default value is 0x3343(representative manufacturer is DFRobot) */
Serial.print("VID: 0x");
Serial.println(rcvbuf[eVid], HEX);
/* firmware revision number: 0x1000 represents V1.0.0.0 */
Serial.print("versions: 0x");
Serial.println(rcvbuf[eVersion], HEX);
Serial.println("-----------------read module measurement config--------------------");
/* current set value at measurement start position, 0x0046~0x19C8, the value can't be greater than the set value at stop position */
Serial.print("start position :0x");
Serial.println(rcvbuf[eDetectionStartPos],HEX);
/* current set value at measurement stop position, 0x0046~0x19C8, the value can't be less than the set value at start position */
Serial.print("stop position :0x");
Serial.println(rcvbuf[eDetectionStopPos],HEX);
/* current initial threshold set value */
Serial.print("initial threshold :0x");
Serial.println(rcvbuf[eStartThreshold],HEX);
/* current end threshold set value */
Serial.print("end threshold :0x");
Serial.println(rcvbuf[eStopThreshold],HEX);
/* current module sensitivity set value */
Serial.print("module sensitivity :0x");
Serial.println(rcvbuf[eSensitivity],HEX);
/* current comparison offset set value */
Serial.print("comparison offset :0x");
Serial.println(rcvbuf[eComparisonOffset],HEX);
}else{
Serial.print("Failed to restore factory Settings. The error code is:");
Serial.println(ret);
}
delay(1000);
}
void loop() {
ret = modbus.readHoldingRegister(SLAVE_ADDR_DEFAULT,eNbTargets,rcvbuf + eNbTargets,11);
if(0 == ret){
Serial.println("----------------------Read data successfully----------------------");
Serial.print("target amount: ");
Serial.println(rcvbuf[eNbTargets]);
for(int i = 1; i <= rcvbuf[eNbTargets];i++){
Serial.print("target:");
Serial.print(i);
Serial.print(" ");
Serial.print("distance: ");
Serial.print( rcvbuf[eNbTargets + 2*i -1]);
Serial.print(" ");
Serial.print("intensity: ");
Serial.println( rcvbuf[eNbTargets + 2*i]);
}
Serial.println("------------------------------------------------------------------");
}else{
Serial.println("Failed to read measurement data!!!");
}
delay(3000);
}