1

I am building a chair for a special 4 year-old with cerebral palsy, I thought it would be a good idea to add two distance sensors on each arm of the chair to measure the angle at which he presses buttons(a gaming chair). Normally I would figure this out on my own but I don't have much time to finish so I thought i'd ask the experts. What's the best way to use to ultrasonic sensors data to produce an angle?

Seaver Olson
  • 123
  • 5

1 Answers1

2

Your question is unclear. You say you want "...to measure the angle at which he presses buttons". I don't know what that means.

If you're using ultrasonic sensors those measure distance. buttons tend to be fixed in place. Maybe you're talking about having a joystick on the gaming chair? Two-axis joysticks should let you input an X and a y value.

If you're trying to calculate the angle between a pair of ultrasonic sensors and something that is in their "line of sight" (line of sound?) then you'd use trig.

You would have your sensors at a known distance from each other. You'd measure the distance to each sensor, form a triangle out of all 3 distances, and use the law of cosines to calculate the angles.

The formulas from that page are:

cos(C) = a² + b² − c²/2ab

cos(A) = b² + c² − a²/2bc

cos(B) = c² + a² − b²/2ca

(Where upper case letters denote the angles of the triangle at a vertex, and lower-case letters denote the legs of the triangle. See the illustration on that page.)

 SensorA
    \
     \      SensorB
      \       /
       \     /
        \   /
         \ /
          V
        object

(one leg would be the SensorA-to-SensorB distance. Another leg would be the SensorA-to-object distance, and the 3rd leg would be the SensorB-to-object distance.)

However, all of that will only work if the object you are detecting is in the range of angles in which your sensors are able to detect objects, and in the range of distances they provide accurate readings.

Edit:

When I copied the formulas from the source site, the superscripts were lost. I've edited them back so the formulas are more readable.

Duncan C
  • 5,562
  • 3
  • 16
  • 28