Sonar scanning RobotC questions

Probably should ask in the RobotC forum, but thought it might be better to try and get answeres here.

1stly anyone know of a way in RobotC for telling that it has just finished an ultrasonic reading apart from checking to see that the reading has changed.

2ndly if you stop and start a motor quick quickly are you likely to damage it.

As far as I can tell the Ultrasonic range finder can give about 10 readings a second. I’m rotaiting the sensor and want to make sure the reading matches the angle, although looking at the beam pattern/angle I’m not sure any of that will improve things, but I just want to see what I can do to improve accuracy.


No official way and the unofficial way is unreliable.

The Ultrasonic sensor is polled approximately 20 times per second but varies depending on the distance.

The ping is initiated, the receiver will wait up to about 36mS for a reply, there is a delay of 50mS before the next ping.

Here is the sonar detecting an object about 130cm away. The blue trace is the output ping, the yellow trace goes low when the reply is received.


Here is the sonar failing to detect a reply.


So one way of monitoring the sonar status would be to monitor the IO port for the received signal and check to see if is high or low, there are no specific ROBOTC commands to do this but it can be done, not going to go into how on the forums though. It does not work well for objects that are close but the assumption here would be that data is valid, probably just as easy to monitor the raw sonar data and detect changes.

If you are interested in the guts of the ultrasonic sensor, it uses an SRF04 module that you can read about here.

Probably not, depends on what it’s driving and the duty cycle. Obviously there will be a certain amount of mechanical stress.


Don’t ask at this link:
Only ROBOTC staff answer questions there–the rest of us can’t. However, the actual ROBOTC forums ([
Yes, but the extent of the damage depends on many factors (for example, moment of inertia of the part attached to the motor).
EDIT: Sorry–I read your post to say “can you damage it?” not “are you likely to damage it?” There will be stresses involved, but unlikely to damage if you’re spinning something relatively lightweight.


]( are pretty good for pure programming questions.)

thanks for the replies, they help clarify things.