Announcement

Collapse
No announcement yet.

Ultrasonic sensor capabilities

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ultrasonic sensor capabilities

    I have a student who is attempting to build the inverted pendulum robot with the Lego NXT kit. He is trying to use the ultrasonic sensor instead of the gyroscopic sensor, as the gyroscopic sensor costs 50 dollars.

    The result is quite a jerky robot. Can anyone tell me what the maximum sample rate for the ultrasonic sensor happens to be? Also, what is the smallest increment of distance it can see. From what I see online, it looks like 1 cm. So, it can see that something is 4 cm or 5 cm away, but not 4.5 cm.

    Any other advice would be helpful.

  • #2
    Re: Ultrasonic sensor capabilities

    Yes, I believe 1 cm is smallest increment of distance for the ultrasonic sensor.
    Also, it can't distinguish distances closer than about 5 cm.

    I think you may be pushing the limits of what the ultrasonic sensor can do.
    You may want to look at doing something similar with the color or light sensor.
    See this project from nxtprograms.com for a self-balancing robot using the color sensor.

    Comment


    • #3
      Re: Ultrasonic sensor capabilities

      Originally posted by cbix View Post
      I have a student who is attempting to build the inverted pendulum robot with the Lego NXT kit. He is trying to use the ultrasonic sensor instead of the gyroscopic sensor, as the gyroscopic sensor costs 50 dollars.

      The result is quite a jerky robot. Can anyone tell me what the maximum sample rate for the ultrasonic sensor happens to be? Also, what is the smallest increment of distance it can see. From what I see online, it looks like 1 cm. So, it can see that something is 4 cm or 5 cm away, but not 4.5 cm.

      Any other advice would be helpful.
      In addition to timdavid's comments (total agreement) I recommend doing some experiments, with the sensor at short distances, and varying the angle between the US beam and the surface it's reflecting from. My experience indicates that at close ranges (under 20 cm), the sensor is very picky about alignment, and what the surface is made from. Factoring these effects into the algorithm for the pendulum robot, that makes for a very dynamic solution.
      FIRST Tech Challenge Judge: 2010, Referee: 2017
      FIRST LEGO League Mentor, Instructor, and/or Referee/Head Referee since 2011
      FIRST Robotics Competition judge (Chairman's Award): 2014
      Dean says I'm an "Oompa Loompa of Science"

      Comment


      • #4
        Re: Ultrasonic sensor capabilities

        I ran a simple test to see if I could determine the sampling rate of the ultrasonic sensor.

        I wrote a short program that looped for 10 seconds, while incrementing a variable and taking a reading from the ultrasonic sensor. It iterated 12612 times in 10 seconds, so it appears the maximum sample rate is about 1260 times a second, which is faster than I would have guessed.

        Removing the sensor reading, the simple loop executed about 36000 times in 10 seconds, or about 3600 times a second.

        I also tried the light sensor, and that looped about 18000 times in 10 seconds, or 1800 times per second.
        Last edited by timdavid; 04-20-2012, 08:45 PM. Reason: correct math

        Comment


        • #5
          Re: Ultrasonic sensor capabilities

          Originally posted by timdavid View Post
          I ran a simple test to see if I could determine the sampling rate of the ultrasonic sensor.

          I wrote a short program that looped for 10 seconds, while incrementing a variable and taking a reading from the ultrasonic sensor. It iterated 12612 times in 10 seconds, so it appears the maximum sample rate is about 1260 times a second, which is faster than I would have guessed.

          Removing the sensor reading, the simple loop executed about 36000 times in 10 seconds, or about 3600 times a second.

          I also tried the light sensor, and that looped about 18000 times in 10 seconds, or 1800 times per second.
          The number of times you can read the US sensor value is not the same as how often the sensor value is updated.

          Comment


          • #6
            Re: Ultrasonic sensor capabilities

            Originally posted by Dean Hystad View Post
            The number of times you can read the US sensor value is not the same as how often the sensor value is updated.
            Ah, that makes more sense. The rate I was calculating seemed far too high.

            I haven't found a definite answer on the real specification for the sampling rate.

            Answers in this page suggested "ping" times between 12 and 75 ms, and suggested it is actually configurable in the hardware. I'm not sure if that is a possibility using NXT-G.

            Another page had this interesting information:

            The product’s official specifications are as follows:
            • Detection range: from 0 to 255 cm with a margin of +/- 3 cm
            • Resolution of approximately 6 cm

            The few limitations that have emerged with this ultrasound sensor are:
            • Measurements under 4 cm cannot be made. This is because of the return time needed for the wave;
            • Measurements up to 20 cm are relatively accurate within an angle ranging between -8° and +30°. In fact, the receiver is on the left and the transmitter on the right, which explains why measurements made on the left are less accurate than measurements made on the right; and
            • Between 20 and 80 cm, measurements can still be made with a margin of error under 8%, which is not too bad for a sensor of this kind.
            I had always wondered which of the two parts of the ultrasonic sensor was the transmitter and which was the receiver.

            Comment

            Working...
            X