using SRF05 with RoBoard

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
2 postsPage 1 of 1
2 postsPage 1 of 1

using SRF05 with RoBoard

Post by Marsman » Mon Aug 16, 2010 5:33 am

Post by Marsman
Mon Aug 16, 2010 5:33 am

Hi,

I know, I should have bought the I2C version of the Ultra-Sonic sensors (SRF08 or SRF10) but I have not. The operation of the SRF05 (or SRF04) still is quite simple but I wonder which are the best library elements of the RB100 SW to use.

I connect the Trigger Input / Echo Output of SRF05 (Mode 2 - single pin) to one of the PWM ports (her channel 10) and intend to use the rcservo.h library. A sequence similar to this should do:

rcservo_Initialize(RCSERVO_USECHANNEL10);
rcservo_EnterPWMMode();
rcservo_SendPWMPulses(10, 15L, 14L, 1): // send 1 pulse of 15us to SRF05
while (!rcservo_IsPWMCompleted(10)); // wait until finished
while (in_value = rcservo_Inp(10) = 0); // check for rising edge of return signal
t1 = localtime(&tv.tv_sec); // will build a function to get system time in micro-seconds
while (in_value = rcservo_Inp(10) = 1); // check for falling edge of return signal
t2 = localtime(&tv.tv_sec); // will build a function to get system time in micro-seconds

pulse_length = t2 - t1; // return signal length in micro-seconds


Would you please comment if that would work with enough accuracy to determine the object's distance? To improve statistics I could put the measurement into a loop to repeat say 10 times.

I wonder if any of the servo commands in "Capture Mode" could be used to determine the return signal's pulse length?

Best regards,

Marsman
Hi,

I know, I should have bought the I2C version of the Ultra-Sonic sensors (SRF08 or SRF10) but I have not. The operation of the SRF05 (or SRF04) still is quite simple but I wonder which are the best library elements of the RB100 SW to use.

I connect the Trigger Input / Echo Output of SRF05 (Mode 2 - single pin) to one of the PWM ports (her channel 10) and intend to use the rcservo.h library. A sequence similar to this should do:

rcservo_Initialize(RCSERVO_USECHANNEL10);
rcservo_EnterPWMMode();
rcservo_SendPWMPulses(10, 15L, 14L, 1): // send 1 pulse of 15us to SRF05
while (!rcservo_IsPWMCompleted(10)); // wait until finished
while (in_value = rcservo_Inp(10) = 0); // check for rising edge of return signal
t1 = localtime(&tv.tv_sec); // will build a function to get system time in micro-seconds
while (in_value = rcservo_Inp(10) = 1); // check for falling edge of return signal
t2 = localtime(&tv.tv_sec); // will build a function to get system time in micro-seconds

pulse_length = t2 - t1; // return signal length in micro-seconds


Would you please comment if that would work with enough accuracy to determine the object's distance? To improve statistics I could put the measurement into a loop to repeat say 10 times.

I wonder if any of the servo commands in "Capture Mode" could be used to determine the return signal's pulse length?

Best regards,

Marsman
Marsman offline
Robot Builder
Robot Builder
Posts: 13
Joined: Sun Sep 27, 2009 9:47 am

Re: using SRF05 with RoBoard

Post by roboard » Mon Aug 16, 2010 10:35 am

Post by roboard
Mon Aug 16, 2010 10:35 am

For simplifying the usage and design of RoBoIO, rcservo_SendPWMPulses() and rcservo_Inp() cannot be used on the same channel at the same time.

Capture Mode is dedicated to PWM-based RC servos (such as KONDO's and HiTEC's PWM servos), and may not fit your purpose.

For your purpose, it is necessary to employ the low-level PWM lib and direct GPIO operations. You may refer to the source code of rcservo_ReadPosition_fast() in rcservo.cpp of RoBoIO src; it provides a similar implementation for you reference. :)
For simplifying the usage and design of RoBoIO, rcservo_SendPWMPulses() and rcservo_Inp() cannot be used on the same channel at the same time.

Capture Mode is dedicated to PWM-based RC servos (such as KONDO's and HiTEC's PWM servos), and may not fit your purpose.

For your purpose, it is necessary to employ the low-level PWM lib and direct GPIO operations. You may refer to the source code of rcservo_ReadPosition_fast() in rcservo.cpp of RoBoIO src; it provides a similar implementation for you reference. :)
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am


2 postsPage 1 of 1
2 postsPage 1 of 1