RB-Dfr-12 DFRobot URM04 v2.0 Ultrasonic Sensor

Similar documents
URM04 V2.0 (SKU:SEN0002)

RS485 Sensor Node V1.0 (SKU:DFR0233)

URM06 UART Ultrasonic SKU:SEN0150

SDB V2.2 Users Manual

DFRduino GPS Shield LEA 6H (SKU:TEL0044)

ARDUINO. By Kiran Tiwari BCT 2072 CoTS.

This tutorial will show you how to take temperature readings using the Freetronics temperature sensor and an Arduino Uno.

Name: Serial MP3 Player A manual

JMY505G User's Manual

OS3DM SUBMINIATURE 3D ORIENTATION SENSOR. Interface Control Document Rev. 1.8

Application Note. Title: Incorporating HMT050CC-C as a Digital Scale Display by: A.S. Date:

OS3D MINIATURE 3D ORIENTATION SENSOR. Interface Control Document Rev. 1.14

RFT(Robotous Force/Torque Sensor) Series

Page 1 MRK-D-0011, V1.1 Aeroqual SM50 User Guide

Grove - CO2 Sensor. Introduction

Grove - I2C Thermocouple Amplifier (MCP9600)

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

Arduino EEPROM module 512K for Sensor Shield

NXShield Interface Specifications

XNUCLEO-F030R8, Improved STM32 NUCLEO Board

Dynamixel Shield for Arduino Mega2560

OS3D-FG MINIATURE 3D ORIENTATION SENSOR

I2C/TWI LCD1602 Module (Gadgeteer Compatible) (SKU: DFR0063)

MODBUS RTU I/O Expansion Modules - Models C267, C277, and C287. Installation and Operations Manual Section 50

Arduino Smart Robot Car Kit User Guide

HMC1022 Digital Compass

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

Handson Technology. HC-SR04 Ultrasonic Sensor Module. 1

Keyes Player Mini MP3 Module. (Red & Environmental-protection)

Introduction to Arduino. Wilson Wingston Sharon

DRF1605H Zigbee Module 1.6km Transfer CC2530 Wireless Module UART to Zigbee

Logosol Joystick Node LS-731

Arduino MP3 Çalar - Arduino MP3 Modülü - Mini SD Kart Girişli. Pin Map

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

KCD-HP. KCD-HP200x, 300X. [Figures] Top : 1% Sensor probe Bottom left : 10% / 20% Sensor probe Bottom right : Holding bracket(optional) Measurement

EEG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

keyestudio Keyestudio MEGA 2560 R3 Board

Arduino Dock 2. The Hardware

Grove - Fingerprint Sensor

JMY504M User's Manual

ARDUINO MEGA ADK REV3 Code: A000069

Card Dispensing/Collecting Machine

Intel Galileo gen 2 Board

FireBeetle ESP8266 IOT Microcontroller SKU: DFR0489

Arduino Uno. Arduino Uno R3 Front. Arduino Uno R2 Front

SRF08 Ultra sonic range finder Technical Specification

L298N Dual H-Bridge Motor Driver

EVShield Interface Specifications

KNJN I2C bus development boards

Z-0001 ZigBee Module Manual

Micro RWD Quad-Tag Reader

KT403A Datasheet(Part)

DIO16 8 Channel digital input and 8 Channel digital output board. V1.0 August CANBUS-DIO16 Rev B v1.0

ZX Distance and Gesture Sensor SMD Hookup Guide

Arduino Prof. Dr. Magdy M. Abdelhameed

Rev 1.3, Air-Farm User Manual. CO2 / Temperature / Humidity Transmitter

ARDUINO LEONARDO ETH Code: A000022

Trueyes Inc. Carbon Dioxide (CO2) Module

Manual 601: : USB/RS232. Specifications. Contents. Options

This is the Arduino Uno: This is the Arduino motor shield: Digital pins (0-13) Ground Rail

C628 Enhanced JPEG Module. User Manual

Create your own wireless motion sensor with

Timer1 Capture Mode:

0.2-60M/ M. Dcc no: EG-QS-T-PM-ST-0115 Form no: EG-QR-T-QA-0003 Date:140915

Product Model Distance Transfer. LDK : Laser Distance Kit. M2:Model2 30 :30M 60 :60M 100:100M. RS: RS-232 BT: Bluetooth

I2C interface Tutorial

SC1602LCPro-YG ( Yellow Green Backlight ) SC1602LCPro-B ( Blue Backlight ) Large Character Size ( 4.88x9.66 mm )

Memo on development of the car-rangefinder device/data logger for crosswalk study

Arduino ADK Rev.3 Board A000069

ARDUINO MEGA 2560 REV3 Code: A000067

PF2100 MODBUS LOGGER CARD SYSTEM SPECIFICATION. v1.0 DRAFT Revised Dec 4, 2014 Last Revised by Alex Messner

3.The circuit board is composed of 4 sets which are 16x2 LCD Shield, 3 pieces of Switch, 2

ADC to I 2 C. Data Sheet. 10 Channel Analog to Digital Converter. with output via I 2 C

ARDUINO INDUSTRIAL 1 01 Code: A000126

Arduino C++ Introduction to programming Antony Watts M0IFA

Input Shield For Arduino SKU: DFR0008

ARDUINO MICRO WITHOUT HEADERS Code: A000093

ARDUINO M0 PRO Code: A000111

Omega MP. Multi-Programming Shield for Atmel Microcontrollers. User Manual

ARDUINO LEONARDO WITH HEADERS Code: A000057

SC2004MBS 20x4 Characters MODBUS RTU Slave LCD

Introduction to Arduino Programming. Sistemi Real-Time Prof. Davide Brugali Università degli Studi di Bergamo

ARDUINO UNO REV3 SMD Code: A The board everybody gets started with, based on the ATmega328 (SMD).

PIC-I/O Multifunction I/O Controller

Seeeduino Stalker. Overview. Basic features: License

Programmable Device Interface PDI-1 A Versatile Hardware Controller with USB interface

S125 Multi-Purpose 125 KHz RFID Reader USER MANUAL. 9V/24V DC Operating Voltage, AC (optional) KHz RFID EM4100/2 Cards & Tags

Bolt 18F2550 System Hardware Manual

Color 7 click. PID: MIKROE 3062 Weight: 19 g

Dual PT100 RTD to CAN-Bus Converter. v1.0 August 2018

Make your own secret locking mechanism to keep unwanted guests out of your space!

BLE Wireless Gamepad V2 SKU: DFR0304

Strain Gage Measuring Amplifier GSV-3

Grove - 3 Axis Digital Accelerometer±16g Ultra-low Power (BMA400)

SAINT2. System Analysis Interface Tool 2. Emulation User Guide. Version 2.5. May 27, Copyright Delphi Automotive Systems Corporation 2009, 2010

MF1-RW-TTL-PCB Mhz Mifare ISO14443A reader/writer module with TTL interface CONTENT 1. MAIN FEATURES...,, PINNING INFORMATION...

USER MANUAL ARDUINO I/O EXPANSION SHIELD

Appendix) Specifications of Monitor & Control Rev. 4.0 July 13, 2016

X Board V2 (SKU:DFR0162)

IO Expansion Shield User Manual

Transcription:

RB-Dfr-12 DFRobot URM04 v2.0 Ultrasonic Sensor URM04 is developed based upon our popular URM37 ultrasonic sensor. The RS485 interface allows a number of sensors working together. Up to 32 URM04 may be connected together in a network. Specifications Power: +5V Current: <20mA Working temperature: -10 ~+70 Detecting range: 4cm-500cm Resolution: 1cm Frequency: 40KHz Interface: RS485 Units: Range reported in cm Temperature sensor: 12 bits reading from serial port Size: 34mm 51 mm Weight: 30g Default Address:0x11 Default Baudrate:19200

URM04 Beam Width 60 degree Dimension and Pin definition URM4 V2 front view and dimension URM4 V2 Back view

RS485 Interface: Two connectors, + : +5V DC Power +5V - : GND Ground A : A RS485 A(+) B : B RS485 B(-) ISP Pin:For factory firmware uploading Communication LED: As the device is powered up, this LED will flash four times which indicates that the sensor is working properly. This LED will also flash when it is communcating with other devices. Jumper A:Not in use Jumper B:When the sensor is working under a network, only the Jumper B for the first Device and the last Device need to be bridged. Communication Protocols The device is fixed at 19200 bps Baud Rate,8/N/1. Note:The previous version has 115200 bps Baud Rate,8/N/1. Set Device Address Command: Header Address Length Cmd Set Address SUM 55 aa AB 1 55 ADD SUM Return Value: Header Address Length Cmd Flag SUM 55 aa ADD 1 55 S SUM PS: The address of each device can be changed when multiple devices are connected. The new Address must be between 0x11 and 0x80. If the address is set sucessfully, the flag will be set to 0x01 in the return data. If unsucessful, there is no return data. (The default address for the sensor is 0x12) Note:The previous default address is 0x11. Example: Command: 0x55 0xaa 0x11 0x01 0x55 0x12 0x79 (Set Address to 0x12) Return: 0x55 0xaa 0x12 0x01 0x55 0x01 0x69 (Address set sucessfully) Read tempeature Command: Header Address Length Cmd SUM 55 aa ADD 0 03 SUM Header Address Length Cmd High Byte Low Byte SUM 55 aa ADD 2 03 H L SUM

PS: The command will return the temperature reading. The return temperature reading is using Celsius scale. If the temperature is above 0 Celsius, the first four bits of High will be all 0. If the temperature is below 0 Celsius, the first four bits of High will be all 1. The last 4 bits of High together with the Low bits stands for 12bits temperature. The resolution is 0.1. When the reading is invalid, it returns 0xFF 0xFF Example: Command: 0x55 0xaa 0x11 0x00 0x03 0x13(SUM) Return: 0x55 0xaa 0x11 0x02 0x03 0xF0 0x0A 0x11 (+1 Celsius Degree) 0x55 0xaa 0x11 0x02 0x03 0x00 0x0A 0x20 (-1 Celsius Degree) 0x55 0xaa 0x11 0x02 0x03 0xFF 0xFF 0x20 (Out of Range) Function to calculate the temperature: IF(HightByte>=0xF0) { Temperature= ((HightByte-0xF0)*256-LowByte)/10 Else { Temperature= ((HightByte)*256-LowByte)/10 Sensor Connection Diagram As the sensor uses RS485 interface which can not be connected directly to the MCU, a MAX485 chip will bridge the TTL interface to RS485. For PC users, either a USB-RS485 or RS232-RS485 converter will bridge the gap. Connect Sensor to MCU via MAX485

Connect Sensor to PC via USB-RS485 converter Connect Sensor to PC via RS232-RS485 Converter Connect Sensor to Arduino Via MAX485 IC

Sensor Networking Upto 32 URM04 sensors are able to join a network. Simply serially connect the sensors uses twisted pair cables. A diagram is illustrated: URM04 Networking Arduino sketch for driving one URM04 sensor The sketch code: /* # The Sample code for driving single URM04 measuring distance function # Editor : Lauren # Date : 2012.2.8 # Ver : 0.3 # Product: URM04 Ultrasonic sensor # Specification * Detecting range: 4cm-500cm * Resolution : 1cm * Interface : RS485 * Units: Range reported in cm * Temperature sensor: 12 bits reading from serial port # Description: # finish driving single URM function # if use the IO expansion shield to drive the urm sensors, the measuring rate may be 20Hz or slower[if you want]. # The sample code is compatible with the Arduino IDE 1.0 and also the earlier version. */ #include "Urm4parser.h" void setup(){ urminit(); // Init the URM04 sensor void loop(){

static unsigned long timepoint = 0; runurm4(); // Drive URM04 Sensor and transmit the protocol to the sensor via RS485 interface // (IO Expansion shield V5 for arduino) decodeurm4(); // Read and get the distance value from the sensor if(millis() - timepoint > 100){ PrintData(); // print the data timepoint = millis(); // PrintData(); // delay(100); void PrintData(){ Serial.print("Distance value: "); for(int i = 0; i < urmaccount; i++){ Serial.print(urmData[i]); Serial.print(" "); /* for(int i = 0; i < urmaccount;i ++){ Serial.print(urmID[i],HEX); Serial.print(" "); */ Serial.println(); The library code: please place the library file Urm4parser.h in to the sketch folder. /* # The library for the URM04 sketch # Editor : Lauren # Date : 2012.2.8 # Ver : 0.3 # Product: URM04 Ultrasonic sensor # Specification * Detecting range: 4cm-500cm * Resolution : 1cm * Interface : RS485 * Units: Range reported in cm * Temperature sensor: 12 bits reading from serial port # Description:

# finish driving single URM function # if use the IO expansion shield to drive the urm sensors, the measuring rate may be 20Hz or slower[if you want]. # The sample code is compatible with the Arduino IDE 1.0 and also the earlier version. */ #if defined(arduino) && ARDUINO >= 100 #include "Arduino.h" #define printbyte(args) Serial.write(args) #else #include "WProgram.h" #define printbyte(args) Serial.print(args,BYTE) #endif #define SerialPort Serial #define urmaccount 1 // Init the account of the URM04 sensor #define CommMAXRetry 40 #define TriggerPin 2 /******************** Variables ****************/ byte startaddr = 0x11; // Init the URM04 485 Address -- URM04 default address = 0x11 byte readingstep; byte cmdst[10]; int urmid[urmaccount]; unsigned int urmdata[urmaccount]; unsigned long managertimer = 20; /******************** Functions ****************/ void urminit(); void runurm4(); void urmtrigger(int id); void urmreader(int id); void transmitcommands(); void decodeurm4(); void analyzeurmdata(byte cmd[]); /****************** Init sensor ****************/ void urminit(){ pinmode(triggerpin,output); // TTL -> RS485 chip driver pin digitalwrite(triggerpin,low);// Turn the driver pin to LOW -> Turn on reading mode for the RS485 interface // Turn the drvier pin to HIGH -> Turn on code transmitting mode for the RS485 interface readingstep = 0;

startaddr = 0x11; managertimer = millis(); for(int i = 0 ;i < urmaccount; i ++){ //Init the URM04 command receiving address urmid[i] = startaddr + i; urmdata[i] = 0; SerialPort.begin(19200); // Init the RS485 interface // Also when you are driving the URM04, you could open serial monitor to // tracing the steps and data feedback from URM04 SerialPort.println(); SerialPort.print("The URM ID: 0x"); for(int i = 0 ;i < urmaccount; i ++){ //Init the URM04 command receiving address SerialPort.print(urmID[i],HEX); SerialPort.print(" "); SerialPort.println(" "); SerialPort.println("The default baudrate: 19200"); SerialPort.println("Start drive the sensors!"); for(int i = 0 ;i < 10; i++) cmdst[i] = 0; //init the URM04 protocol cmdst[0]=0x55; cmdst[1]=0xaa; /********************* Drive URM04 and get the data code *************************/ void runurm4(){ managertimer value // You could adjust the sensor measuring rate by changing the static unsigned long timer = 0; static int num = 0; //Set the URM04 id to be drived if(millis() - timer > managertimer){ digitalwrite(triggerpin, HIGH); //Turn on transmitting mode for the RS485 interface switch(readingstep){ case 0: urmtrigger(urmid[num]); managertimer = 40; //set a interval after trigger the measuring break; case 1: urmreader(urmid[num]); managertimer = 0; break; case 2: //set a interval after transmitting the reading distance command

digitalwrite(triggerpin, LOW); //Turn on reading mode for the RS485 interface managertimer = 10; break; default: readingstep = 0; break; // Finish reading the distance and start a new measuring for the sensor if(readingstep < 2) readingstep++; //step manager else readingstep = 0; timer = millis(); /********************* Transmit Command via the RS485 interface ***************/ void urmtrigger(int id){ // The function is used to trigger the measuring cmdst[2] = id; cmdst[3] = 0x00; cmdst[4] = 0x01; transmitcommands(); // SerialPort.println("Trigger!"); void urmreader(int id){ // The function is used to read the distance cmdst[2] = id; cmdst[3]=0x00; cmdst[4]=0x02; transmitcommands(); // SerialPort.println("Ask for distance!"); void transmitcommands(){ // Send protocol via RS485 interface cmdst[5]=cmdst[0]+cmdst[1]+cmdst[2]+cmdst[3]+cmdst[4]; delay(1); for(int j = 0; j < 6; j++){ printbyte(cmdst[j]); // delaymicroseconds(10); delay(2); /********************* Receive the data and get the distance value from the RS485 interface ***************/ void decodeurm4(){

if(serialport.available()){ unsigned long timerpoint = millis(); int RetryCounter = 0; byte cmdrd[10]; for(int i = 0 ;i < 10; i++) cmdrd[i] = 0; int i=0; // SerialPort.println("OK"); boolean flag = true; boolean valid = false; byte headerno = 0; while(retrycounter < CommMAXRetry && flag) { if(serialport.available()){ cmdrd[i]= SerialPort.read(); // printbyte(cmdrd[i]); if(i > 7){ flag=false; // printbyte(0xee); // printbyte(0xff); SerialPort.flush(); break; if(cmdrd[i] == 0xAA){ headerno = i; valid = true; if(valid && i == headerno + 6){ // printbyte(0xdd); // printbyte(0xff); flag = false; break; i ++; RetryCounter = 0; else{ RetryCounter++; delaymicroseconds(15);

// printbyte(millis() - timerpoint); if(valid) analyzeurmdata(cmdrd); // else SerialPort.println("Invalid feedback"); //Get an invalid error command void analyzeurmdata(byte cmd[]){ byte sumcheck = 0; for(int h = 0;h < 7; h ++) sumcheck += cmd[h]; if(sumcheck == cmd[7] && cmd[3] == 2 && cmd[4] == 2){ byte id = cmd[2] - startaddr; urmdata[id] = cmd[5] * 256 + cmd[6]; // SerialPort.print(id); // SerialPort.print(":"); // SerialPort.println(urmData[id]); else if(cmd[3] == 2 && cmd[4] == 2){ SerialPort.print("Sum error");