Forum >Servo shakes when URM37 scans
Servo shakes when URM37 scans

Hi,
I am using the DFRobot Romeo all in one controller.
[url=http://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656]http://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656[/url]
Allatched I have a servo with IR (Sharp) and Ultrasonic (URM37) sensors.
When I turn the servo 180° step by step and only read the IR Sensor at every step, the servo does a smooth round.
When I do a Ultrasonic Scan at every step, the servo starts to share as to be seen here: [url=http://youtu.be/lEsOzdS8XlQ]http://youtu.be/lEsOzdS8XlQ[/url]
The shaking seems to be especially strong when the scan distance is high (eventually higher than the 3m max range).
The board as well as the servo is powered via the Motor Power (11.1V LiPo).
I am using the milesburton library for the URM37. Arduino sketch is attached.
Can someone explain what may go wrong?
Thanks,
Robert
I am using the DFRobot Romeo all in one controller.
[url=http://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656]http://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656[/url]
Allatched I have a servo with IR (Sharp) and Ultrasonic (URM37) sensors.
When I turn the servo 180° step by step and only read the IR Sensor at every step, the servo does a smooth round.
When I do a Ultrasonic Scan at every step, the servo starts to share as to be seen here: [url=http://youtu.be/lEsOzdS8XlQ]http://youtu.be/lEsOzdS8XlQ[/url]
The shaking seems to be especially strong when the scan distance is high (eventually higher than the 3m max range).
The board as well as the servo is powered via the Motor Power (11.1V LiPo).
I am using the milesburton library for the URM37. Arduino sketch is attached.
Can someone explain what may go wrong?
Thanks,
Robert
2012-06-28 23:24:20 Hi Hector,
thanks a lot for the smaples! I'll check it out later today.
Can the PWM mode also be used the same way in Mode 3 with the trigger?
Thanks
Robert
robvoi
thanks a lot for the smaples! I'll check it out later today.
Can the PWM mode also be used the same way in Mode 3 with the trigger?
Thanks
Robert

2012-06-28 23:24:20 Hi Hector,
thanks a lot for the smaples! I'll check it out later today.
Can the PWM mode also be used the same way in Mode 3 with the trigger?
Thanks
Robert
robvoi
thanks a lot for the smaples! I'll check it out later today.
Can the PWM mode also be used the same way in Mode 3 with the trigger?
Thanks
Robert

2012-06-28 23:07:58 Hi Robert,
Ok, we got the new PWM sample code working.
You will need to run 2 scripts.
First download the new [url=https://www.dfrobot.com/image/data/SEN0001/URM37%20library%20for%20Arduino%20IDE%201.0.rar]URM37 library[/url]. The file now has 2 additional sketches.
First run "AutonomousModeSE"
Make sure you wire everything up as the comments indicate.
You should only need to run this sketch once EVER! This sketch will set the URM37's PWM mode to "Autonomous" which means it will not wait for a trigger pulse to report back a distance measurement.
Open the Arduino IDE Serial terminal, and you will see some giberish along with some strings. This means it worked!
Once you have run the setup, load the "AutonomousMode" sketch.
Once again make sure you wire everything up as the comments indicate.
You can now open the serial terminal and if everything worked, you should see a distance being reported back.
Hector
Ok, we got the new PWM sample code working.
You will need to run 2 scripts.
First download the new [url=https://www.dfrobot.com/image/data/SEN0001/URM37%20library%20for%20Arduino%20IDE%201.0.rar]URM37 library[/url]. The file now has 2 additional sketches.
First run "AutonomousModeSE"
Make sure you wire everything up as the comments indicate.
You should only need to run this sketch once EVER! This sketch will set the URM37's PWM mode to "Autonomous" which means it will not wait for a trigger pulse to report back a distance measurement.
Open the Arduino IDE Serial terminal, and you will see some giberish along with some strings. This means it worked!
Once you have run the setup, load the "AutonomousMode" sketch.
Once again make sure you wire everything up as the comments indicate.
You can now open the serial terminal and if everything worked, you should see a distance being reported back.

2012-06-28 23:07:58 Hi Robert,
Ok, we got the new PWM sample code working.
You will need to run 2 scripts.
First download the new [url=https://www.dfrobot.com/image/data/SEN0001/URM37%20library%20for%20Arduino%20IDE%201.0.rar]URM37 library[/url]. The file now has 2 additional sketches.
First run "AutonomousModeSE"
Make sure you wire everything up as the comments indicate.
You should only need to run this sketch once EVER! This sketch will set the URM37's PWM mode to "Autonomous" which means it will not wait for a trigger pulse to report back a distance measurement.
Open the Arduino IDE Serial terminal, and you will see some giberish along with some strings. This means it worked!
Once you have run the setup, load the "AutonomousMode" sketch.
Once again make sure you wire everything up as the comments indicate.
You can now open the serial terminal and if everything worked, you should see a distance being reported back.
Hector
Ok, we got the new PWM sample code working.
You will need to run 2 scripts.
First download the new [url=https://www.dfrobot.com/image/data/SEN0001/URM37%20library%20for%20Arduino%20IDE%201.0.rar]URM37 library[/url]. The file now has 2 additional sketches.
First run "AutonomousModeSE"
Make sure you wire everything up as the comments indicate.
You should only need to run this sketch once EVER! This sketch will set the URM37's PWM mode to "Autonomous" which means it will not wait for a trigger pulse to report back a distance measurement.
Open the Arduino IDE Serial terminal, and you will see some giberish along with some strings. This means it worked!
Once you have run the setup, load the "AutonomousMode" sketch.
Once again make sure you wire everything up as the comments indicate.
You can now open the serial terminal and if everything worked, you should see a distance being reported back.

2012-06-25 21:26:13 Hi Hector,
thanks a lot. THat's great.
By the way - a workaround for the problem with the shaking servos is to use a digital pin which is connected to a different timer. With me, SoftwareSerial influences pin 8. Pin 9 works fine.
Nevertheless, using PWM would be nice to free a digital pin. And just in case you have more servos in use.
Regards,
Robert
robvoi
thanks a lot. THat's great.
By the way - a workaround for the problem with the shaking servos is to use a digital pin which is connected to a different timer. With me, SoftwareSerial influences pin 8. Pin 9 works fine.
Nevertheless, using PWM would be nice to free a digital pin. And just in case you have more servos in use.
Regards,
Robert

2012-06-25 21:26:13 Hi Hector,
thanks a lot. THat's great.
By the way - a workaround for the problem with the shaking servos is to use a digital pin which is connected to a different timer. With me, SoftwareSerial influences pin 8. Pin 9 works fine.
Nevertheless, using PWM would be nice to free a digital pin. And just in case you have more servos in use.
Regards,
Robert
robvoi
thanks a lot. THat's great.
By the way - a workaround for the problem with the shaking servos is to use a digital pin which is connected to a different timer. With me, SoftwareSerial influences pin 8. Pin 9 works fine.
Nevertheless, using PWM would be nice to free a digital pin. And just in case you have more servos in use.
Regards,
Robert

2012-06-25 19:33:09 Hi Robert,
We will provide a sample code in the wiki page in a few days.
I will post back here once it has been completed
Hector
We will provide a sample code in the wiki page in a few days.
I will post back here once it has been completed

2012-06-25 19:33:09 Hi Robert,
We will provide a sample code in the wiki page in a few days.
I will post back here once it has been completed
Hector
We will provide a sample code in the wiki page in a few days.
I will post back here once it has been completed

2012-06-23 02:53:51 OK. I found that the problem is most likely caused by the SoftSerial library (taking interrupts and interfering with the servo library). Because of this I would like to interface the URM37 via PWM.
There seemed to be some example code on yerobot.com . But the site is down.
Does someone have example code for the PWM mode? All I found is for serial communication.
Thanks
Robert
robvoi
There seemed to be some example code on yerobot.com . But the site is down.
Does someone have example code for the PWM mode? All I found is for serial communication.
Thanks
Robert

2012-06-23 02:53:51 OK. I found that the problem is most likely caused by the SoftSerial library (taking interrupts and interfering with the servo library). Because of this I would like to interface the URM37 via PWM.
There seemed to be some example code on yerobot.com . But the site is down.
Does someone have example code for the PWM mode? All I found is for serial communication.
Thanks
Robert
robvoi
There seemed to be some example code on yerobot.com . But the site is down.
Does someone have example code for the PWM mode? All I found is for serial communication.
Thanks
Robert

2012-06-22 10:57:37 The Servo driver indeed works without the shaking. BUT - it only has 46 steps. So rotation is very rough.
I still would like to get it running with stearing the servo with the romeo.
I also tried the code below for scanning. I expect the servo pos. to be written at every while cycle. But the shaking stays ..
int pingTEST(int servopos)
{
int scanrounds = 0;
int pingretry = 2;
pingagain:
urm.requestMeasurement(1);
while (urm.hasReading() == false) {
servo1.write(servopos);
//Serial.println(millis());
delay(1);
}
scanrounds ++;
switch(urm.getMeasurement(value)) // Find out the type of request
{
Serial.println("Value: " + String (value));
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
return value;
Serial.println("Distance: " + String (value));
break;
case TEMPERATURE:
return 5000;
Serial.println("Status: Temperature: " + String (value));
break;
case ERROR:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Error");
break;
case NOTREADY:
Serial.println("Ping Not Ready");
break;
case TIMEOUT:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Timeout");
break;
}
}
robvoi
I still would like to get it running with stearing the servo with the romeo.
I also tried the code below for scanning. I expect the servo pos. to be written at every while cycle. But the shaking stays ..
int pingTEST(int servopos)
{
int scanrounds = 0;
int pingretry = 2;
pingagain:
urm.requestMeasurement(1);
while (urm.hasReading() == false) {
servo1.write(servopos);
//Serial.println(millis());
delay(1);
}
scanrounds ++;
switch(urm.getMeasurement(value)) // Find out the type of request
{
Serial.println("Value: " + String (value));
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
return value;
Serial.println("Distance: " + String (value));
break;
case TEMPERATURE:
return 5000;
Serial.println("Status: Temperature: " + String (value));
break;
case ERROR:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Error");
break;
case NOTREADY:
Serial.println("Ping Not Ready");
break;
case TIMEOUT:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Timeout");
break;
}
}

2012-06-22 10:57:37 The Servo driver indeed works without the shaking. BUT - it only has 46 steps. So rotation is very rough.
I still would like to get it running with stearing the servo with the romeo.
I also tried the code below for scanning. I expect the servo pos. to be written at every while cycle. But the shaking stays ..
int pingTEST(int servopos)
{
int scanrounds = 0;
int pingretry = 2;
pingagain:
urm.requestMeasurement(1);
while (urm.hasReading() == false) {
servo1.write(servopos);
//Serial.println(millis());
delay(1);
}
scanrounds ++;
switch(urm.getMeasurement(value)) // Find out the type of request
{
Serial.println("Value: " + String (value));
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
return value;
Serial.println("Distance: " + String (value));
break;
case TEMPERATURE:
return 5000;
Serial.println("Status: Temperature: " + String (value));
break;
case ERROR:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Error");
break;
case NOTREADY:
Serial.println("Ping Not Ready");
break;
case TIMEOUT:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Timeout");
break;
}
}
robvoi
I still would like to get it running with stearing the servo with the romeo.
I also tried the code below for scanning. I expect the servo pos. to be written at every while cycle. But the shaking stays ..
int pingTEST(int servopos)
{
int scanrounds = 0;
int pingretry = 2;
pingagain:
urm.requestMeasurement(1);
while (urm.hasReading() == false) {
servo1.write(servopos);
//Serial.println(millis());
delay(1);
}
scanrounds ++;
switch(urm.getMeasurement(value)) // Find out the type of request
{
Serial.println("Value: " + String (value));
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
return value;
Serial.println("Distance: " + String (value));
break;
case TEMPERATURE:
return 5000;
Serial.println("Status: Temperature: " + String (value));
break;
case ERROR:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Error");
break;
case NOTREADY:
Serial.println("Ping Not Ready");
break;
case TIMEOUT:
if (scanrounds < 2) {goto pingagain;}
else {return 0;}
Serial.println("Timeout");
break;
}
}

2012-06-22 07:40:07 Using urm37 servo driver will definitely solve your problem as it is designed to do so.
R2D2C3PO

2012-06-22 07:40:07 Using urm37 servo driver will definitely solve your problem as it is designed to do so.
R2D2C3PO

2012-06-21 23:24:29 Hi Lauren,
thanks a lot for your reply and the good explanation.
Using the hardware interface is no option as I have a bluetooth dongle in use.
1. Regarding the replacement of the delay() - do you mean in the URM37 library or at which place?
2. Would using the servo driver of the URM37 solve the problem?
Thanks
Robert
robvoi
thanks a lot for your reply and the good explanation.
Using the hardware interface is no option as I have a bluetooth dongle in use.
1. Regarding the replacement of the delay() - do you mean in the URM37 library or at which place?
2. Would using the servo driver of the URM37 solve the problem?
Thanks
Robert

2012-06-21 23:24:29 Hi Lauren,
thanks a lot for your reply and the good explanation.
Using the hardware interface is no option as I have a bluetooth dongle in use.
1. Regarding the replacement of the delay() - do you mean in the URM37 library or at which place?
2. Would using the servo driver of the URM37 solve the problem?
Thanks
Robert
robvoi
thanks a lot for your reply and the good explanation.
Using the hardware interface is no option as I have a bluetooth dongle in use.
1. Regarding the replacement of the delay() - do you mean in the URM37 library or at which place?
2. Would using the servo driver of the URM37 solve the problem?
Thanks
Robert

2012-06-21 22:35:12 Hi Robert,
The IR sensor flash rate is very fast. But the URM37 is using the software interface. In this mode, the sensor feedback will occupy the thread of the micro-controller.
However your servo control is based on the delay structure. So the servo control steps will affect by ultrasonic sensor data reading.
So, there's two solution I know.
1. Considering that the data reading from the URM37 will take about 40ms. And the software serial mode will take a longer time to get the data. So you may need to try to drive the module with hardware interface.
2. Try to remove the delay(), using the timer to replace it. Cause it's much better to use the timer to manager the robot timing thread of the micro-controller. The delay() will affect the performance.
Hope it's helpful.
;)
Regards
Lauren
Lauren
The IR sensor flash rate is very fast. But the URM37 is using the software interface. In this mode, the sensor feedback will occupy the thread of the micro-controller.
However your servo control is based on the delay structure. So the servo control steps will affect by ultrasonic sensor data reading.
So, there's two solution I know.
1. Considering that the data reading from the URM37 will take about 40ms. And the software serial mode will take a longer time to get the data. So you may need to try to drive the module with hardware interface.
2. Try to remove the delay(), using the timer to replace it. Cause it's much better to use the timer to manager the robot timing thread of the micro-controller. The delay() will affect the performance.
Hope it's helpful.
;)
Regards
Lauren

2012-06-21 22:35:12 Hi Robert,
The IR sensor flash rate is very fast. But the URM37 is using the software interface. In this mode, the sensor feedback will occupy the thread of the micro-controller.
However your servo control is based on the delay structure. So the servo control steps will affect by ultrasonic sensor data reading.
So, there's two solution I know.
1. Considering that the data reading from the URM37 will take about 40ms. And the software serial mode will take a longer time to get the data. So you may need to try to drive the module with hardware interface.
2. Try to remove the delay(), using the timer to replace it. Cause it's much better to use the timer to manager the robot timing thread of the micro-controller. The delay() will affect the performance.
Hope it's helpful.
;)
Regards
Lauren
Lauren
The IR sensor flash rate is very fast. But the URM37 is using the software interface. In this mode, the sensor feedback will occupy the thread of the micro-controller.
However your servo control is based on the delay structure. So the servo control steps will affect by ultrasonic sensor data reading.
So, there's two solution I know.
1. Considering that the data reading from the URM37 will take about 40ms. And the software serial mode will take a longer time to get the data. So you may need to try to drive the module with hardware interface.
2. Try to remove the delay(), using the timer to replace it. Cause it's much better to use the timer to manager the robot timing thread of the micro-controller. The delay() will affect the performance.
Hope it's helpful.
;)
Regards
Lauren

2012-06-21 02:01:51 Hi,
I am using the DFRobot Romeo all in one controller.
[url=https://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656]https://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656[/url]
Allatched I have a servo with IR (Sharp) and Ultrasonic (URM37) sensors.
When I turn the servo 180° step by step and only read the IR Sensor at every step, the servo does a smooth round.
When I do a Ultrasonic Scan at every step, the servo starts to share as to be seen here: [url=http://youtu.be/lEsOzdS8XlQ]http://youtu.be/lEsOzdS8XlQ[/url]
The shaking seems to be especially strong when the scan distance is high (eventually higher than the 3m max range).
The board as well as the servo is powered via the Motor Power (11.1V LiPo).
I am using the milesburton library for the URM37. Arduino sketch is attached.
Can someone explain what may go wrong?
Thanks,
Robert
robvoi
I am using the DFRobot Romeo all in one controller.
[url=https://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656]https://www.dfrobot.com/index.php?route=product/product&path=52_104&product_id=656[/url]
Allatched I have a servo with IR (Sharp) and Ultrasonic (URM37) sensors.
When I turn the servo 180° step by step and only read the IR Sensor at every step, the servo does a smooth round.
When I do a Ultrasonic Scan at every step, the servo starts to share as to be seen here: [url=http://youtu.be/lEsOzdS8XlQ]http://youtu.be/lEsOzdS8XlQ[/url]
The shaking seems to be especially strong when the scan distance is high (eventually higher than the 3m max range).
The board as well as the servo is powered via the Motor Power (11.1V LiPo).
I am using the milesburton library for the URM37. Arduino sketch is attached.
Can someone explain what may go wrong?
Thanks,
Robert
