background image

// # Version :  0.2 

 

// # Description: 

// # The Sketch for scanning 180 degree area 4-500cm detecting range 

 

// # Connection: 

// #       Pin 1 VCC (URM V3.2) -> VCC (Arduino) 

// #       Pin 2 GND (URM V3.2) -> GND (Arduino) 

// #       Pin 4 PWM (URM V3.2) -> Pin 3 (Arduino) 

// #       Pin 6 COMP/TRIG (URM V3.2) -> Pin 5 (Arduino) 

// # Pin mode: PWM 

// # Working Mode: PWM passive control mode. 

// # If it is your first time to use it,please make sure the two jumpers to t
he right hand 

// # side of the device are set to TTL mode. You'll also find a secondary jum
per on  

// # the left hand side, you must break this connection or you may damage you
r device.  

 

#include <Servo.h>                                  // Include Servo library 

Servo myservo;                                      // create servo object to 
control a servo  

 

int pos=0;                                          // variable to store the 
servo position 

int URPWM=3;                                        // PWM Output 0-25000us,e
very 50us represent 1cm 

int URTRIG=5;                                       // PWM trigger pin 

boolean up=true;                                    // create a boolean varia
ble 

unsigned long time;                                 // create a time variable 

unsigned long urmTimer = 0;                          // timer for managing th
e sensor reading flash rate 

 

unsigned int Distance=0; 

uint8_t EnPwmCmd[4]={0x44,0x22,0xbb,0x01};          // distance measure comma
nd 

Summary of Contents for SEN0001

Page 1: ...rvo Rotation Reference Table 5 Protocol 6 Trouble shooting 7 More Introduction URM37 V4 0 Ultrasonic Sensor uses an industrial level AVR processor as the main processing unit It comes with a temperatu...

Page 2: ...reboot Modified the algorithm so dead zone was reduced and enhance accuracy Analog voltage output voltage and the measured distance is proportional Wide voltage support 3 3V 5 0V Power reverse protect...

Page 3: ...have to set the serial port level or RS232 TTL level then we can access to the module through the serial port then set the range mode 0x02 writes data on the internal EEPROM address after that you can...

Page 4: ...off from state on release the botton Repower again he Indicator appears to flash like once long and once short present TTL level output once long and twice short flash presenting RS232 level Do not c...

Page 5: ...iagram RS232 Mode Connection Diagram Power on the sensor read the blink of the LED active to get the serial level see above wire according to the above picture After this you can use our URMV3 2HelpMa...

Page 6: ...ut the meaning of the data in EEPROM several addresses For more details can be found in the Serial control protocol part Address Meaning 0x00 larger than set distance 0x01 less than set distance 0x02...

Page 7: ...ress are unavailable 0x00 0x04 please do not try to modify the data Three Measure Modes PWM trigger mode In PWM trigger mode pin COMP TRIG produces a low level of triggered pulse signal starting dista...

Page 8: ...Arduino Pin 2 GND URM V4 0 16 Pin 3 Arduino Pin 4 ECHO URM V4 0 17 Pin 5 Arduino Pin 6 COMP TRIG URM V4 0 18 Pin A0 Arduino Pin 7 DAC URM V4 0 19 Working Mode PWM trigger pin mode 20 21 define Measure...

Page 9: ...a low pull on pin COMP TRI G triggering a sensor reading 47 48 Serial print Distance Measured 49 digitalWrite URTRIG LOW 50 digitalWrite URTRIG HIGH reading Pin PWM will output pulses 51 if Measure 52...

Page 10: ...orPin 67 if sensorValue 10 the reading is invalid 68 69 Serial print Invalid 70 71 else 72 sensorValue sensorValue 0 718 73 Serial print sensorValue 74 Serial println cm 75 76 77 result Open the IDE s...

Page 11: ...de By means of the computer software or MCU Module write 0xAA to 0x02 address to switch to automatic measurement mode Writting a 8 bit 16 binary data to 0x04 address to reverse the measure time interv...

Page 12: ...Note download first before connect the Arduino TX RX or download will failed Demo Code 1 Put your code here 2 3 Editor Zrh from DFRobot 4 Data 29 08 2014 5 Product name ultrasonic scanner 6 Product SK...

Page 13: ...25000US Every 50US represent 1cm 23 24 unsigned int Distance 0 25 uint8_t EnPwmCmd 4 0x44 0x02 0xaa 0xf0 distance measure command 26 27 void setup Serial initialization 28 Serial begin 9600 Sets the...

Page 14: ...ured 45000 the reading is invalid 47 Serial print Invalid 48 49 else 50 Distance DistanceMeasured 50 every 50us low level stan ds for 1cm 51 Serial print Distance 52 Serial print Distance 53 Serial pr...

Page 15: ...ent intervals set serial port set RS232 or TTL reboot to take effect e g 1 Read the temperature data command 0x11 0x00 0x00 0x11 2 Read the distance data command 0x22 0x00 0x00 0x22 3 Read EEPROM data...

Page 16: ...2 13 Connection 14 Vcc Arduino Pin 1 VCC URM V4 0 15 GND Arduino Pin 2 GND URM V4 0 16 Pin TX1 Arduino Pin 8 RXD URM V4 0 17 Pin RX0 Arduino Pin 9 TXD URM V4 0 18 Working Mode Serial Mode 19 20 uint8_...

Page 17: ...mpCmd i 39 40 while Serial available 0 if serial receive any data 41 42 for i 0 i 4 i 43 TempData i Serial read 44 45 TempValue TempData 1 8 46 TempValue TempValue TempData 2 47 Serial print temperatu...

Page 18: ...degrees Celsius Servo Rotation Reference Table Servo control command reference table DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEX 0 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F Degree 0 6 12 18 24 29...

Page 19: ...8 39 40 41 42 43 44 45 46 HEX 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E Degree 188 194 200 206 211 217 223 229 235 241 247 252 258 264 270 Arduino Sketch NOTE Please put the sensor jumpers to TTL m...

Page 20: ...TL mode You ll also find a secondary jum per on the left hand side you must break this connection or you may damage you r device include Servo h Include Servo library Servo myservo create servo object...

Page 21: ...erval 0 02 seconds time millis get the current time o f programme if up judge the condition if pos 0 pos 179 pos pos 1 in steps of 1 degree myservo write pos tell servo to go to po sition in variable...

Page 22: ...id PWM_Mode a low pull on pin COM P TRIG triggering a sensor reading digitalWrite URTRIG LOW digitalWrite URTRIG HIGH reading Pin PWM will output pulses unsigned long DistanceMeasured pulseIn URPWM LO...

Page 23: ...t four bits of High will be all 0 If the temperature is below 0 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 resolutio...

Page 24: ...to use it please first check the current serial port level mode it may be in TTL level while our module works in RS232 levels 2 The ultrasonic attenuation violently in the air inversely proportional t...

Page 25: ...More Arduino Library from milesburton IDE 0023 and below Old version_URM37 V3 2 Powered By DFRobot 2008 2016...

Reviews: