Pages: [1]   Go Down
Author Topic: question about URM37 V3.2  (Read 1108 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm testing URM37 v3.2 recently. below is the test result from the serial monitoring:

Distance=24098
Distance=24098
Distance=23842
Distance=24098

may anyone pls tell me how to convert the measurement unit ?i have tried using 'microsecondsToInches' and 'microsecondsToInches', but it seem like not valid. can anyone help me ?


* Untitled.png (20.58 KB, 414x448 - viewed 25 times.)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Can you post the code you have sofar?

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have changed the sensor position and output value decrease accordingly. but the value i get is so confuse.
24098 is about 1.5m from the object.

Code:
/* Ultrasound Sensor
*------------------
* URM V3.2 ultrasonic sensor TTL connection with Arduino
* Reads values (0-300) from an ultrasound sensor (3m sensor)
* and writes the values to the serialport.
* Pin12 (Arduino)-> Pin 1 VCC (URM V3.2)
* GND (Arduino) -> Pin 2 GND (URM V3.2)
* Pin11 (Arduino) -> Pin 7 (URM V3.2)
* Pin 0 (Arduino) -> Pin 9 (URM V3.2)
* Pin 1 (Arduino) -> Pin 8 (URM V3.2)
* www.yerobot.com
* Last modified 20/04/2009
*/

int UREnable = 11; // Ultrasound enable pin
int URPower = 12; // Ultrasound power pin
int val = 0;
int USValue = 0;
int timecount = 0; // Echo counter
int ledPin = 13; // LED connected to digital pin 13
boolean flag=true;
uint8_t DMcmd[4] = { 0x22, 0x00, 0x00, 0x22}; //distance measure command

void setup() {
  Serial.begin(9600);                  // Sets the baud rate to 9600
  pinMode(ledPin, OUTPUT);            // Sets the digital pin as output
   pinMode(UREnable, OUTPUT);
   digitalWrite(UREnable, HIGH); // Set to High
    pinMode(URPower, OUTPUT);
   digitalWrite(URPower, HIGH); // Set to High

delay(200); //Give sensor some time to start up --Added By crystal  from Singapo, Thanks Crystal.
}

void loop()
{
 
  flag=true;
  //Sending distance measure command :  0x22, 0x00, 0x00, 0x22 ;

  for(int i=0;i<4;i++)
  {
    Serial.print(DMcmd[i],BYTE);
  }
 
  delay(75); //delay for 75 ms
 
while(flag)
{
    if(Serial.available()>0)
    {
        int header=Serial.read(); //0x22
        int highbyte=Serial.read();
        int lowbyte=Serial.read();
        int sum=Serial.read();//sum
      
        if(highbyte==255)
        {
          USValue=65525;  //if highbyte =255 , the reading is invalid.
        }
        else
        {
          USValue = highbyte*255+lowbyte;
        }
  
       Serial.print("Distance=");
       Serial.print(USValue);
      
       flag=false;
     }
}
  delay(50);
}

« Last Edit: April 14, 2012, 01:44:21 am by fuiyo » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anyone hv the solution or any ideal share wif me ?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please use code tags when you post code.  It is the # button in the editor (if you modify your post and select the code and press # it will be done automatically)

try to replace:

Code:
  for(int i=0;i<4;i++)
  {
    Serial.print(DMcmd,BYTE);
  }

with

  for(int i=0;i<4;i++)
  {
    Serial.write(DMcmd);
  }


Then you write

Code:
if(Serial.available()>0)
    {
        int header=Serial.read(); //0x22
        int highbyte=Serial.read();
        int lowbyte=Serial.read();
        int sum=Serial.read();//sum

You try to read 4 bytes, but you only know there are more than 0. So change this into

Code:
if(Serial.available()>=4)
    {
        int header=Serial.read(); //0x22
        int highbyte=Serial.read();
        int lowbyte=Serial.read();
        int sum=Serial.read();//sum

optionally print all 4 bytes here for debug

should get you a step closer now
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thx very much. nw i get the value in cm after changed the code to according to yr advice. But hw to set the max range. now the max range is 70 cm even the range is 1.5 m. The user guide stated that is can support up to 0.35cm to 3m (5m depend on the situation).

Code:
for(int i=0;i<4;i++)
  {
    Serial.write((byte)DMcmd[i]);
    //Serial.write(DMcmd);
  }

and

Code:
if(Serial.available()>=4)
      {
          int header=Serial.read(); //0x22
          int highbyte=Serial.read();
          int lowbyte=Serial.read();
          int sum=Serial.read();//sum


* IMG_0181.JPG (820.01 KB, 2048x1536 - viewed 19 times.)

* IMG_0182.JPG (842.43 KB, 2048x1536 - viewed 19 times.)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But hw to set the max range.

You have the user guide.
What does it tell about the max range?
What does it state about the reflective surfaces needed?

Quote
now the max range is 70 cm even the range is 1.5 m.
Maybe your code divides by 2 where it is not needed?  THe soundpulse does the distance twice?

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What does it tell about the max range?
What does it state about the reflective surfaces needed?

According to http://www.dfrobot.com/wiki/index.php?title=URM37_V3.2_Ultrasonic_Sensor_(SKU:SEN0001) there is no surfaces requirement.I think my room space is enough for the Beam Width. I will go through more materiel over internet but the information is limited. Anyway thanks for the advise.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you get the temperature from the URM37? If so: how?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Another idea, maybe you are getting the distances in inches?  That is also approx a factor 2 ...

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: