Is there a sensor I could use which would let me know which direction an object is heading/facing? i.e. I have a servo that can rotate 0 to 180 degrees, and I have another sensor on a block. When I turn the block 45 degrees, I want the servo to also turn 45 degrees - I thought I could do this with a compass, but the varying magnetic fields make it impossible. Gyro/acc maybe? Except I don't know how to use that to solve this problem.
So in other words we need to know the block was rotated 45 degrees using a sensor on the block, which tells the servo to rotate 45 degrees.
-
2You can lookup "sensor fusion" (which is a complicated matter) and "MPU6050", which is a cheap board with some hardware support and plenty of examples for it - perhaps it might be what you need.Mishony– Mishony2016年06月21日 07:10:49 +00:00Commented Jun 21, 2016 at 7:10
-
Great thanks, I think that might work I have used that sensor before for an indoor positioning system / IMU setup -- one question though is there a way to have two separate MPU6050 synchronize orientations? That was the reason for my compass system - both knew which way was north irregardless of when they were turned on so I could use that as a calibration point.eWizardII– eWizardII2016年06月21日 07:37:14 +00:00Commented Jun 21, 2016 at 7:37
-
Lookup Magnetometer sensor.Gerben– Gerben2016年06月21日 13:32:27 +00:00Commented Jun 21, 2016 at 13:32
-
You could use the accelerometer to "synchronize orientation" because gravity always points down, but that will only work if the two sensors rotate on an axis that does not line up with gravity (e.g. they don't rotate around an axis pointed up). Similarly, a magnetometer won't work if the table rotates around the north vector.BrettFolkins– BrettFolkins2016年07月27日 18:40:04 +00:00Commented Jul 27, 2016 at 18:40
1 Answer 1
Use a gyro, it will give you the angle. Gyros are difficult to find spare, so you should buy an IMU like MPU6050 that contains also an accelerometer.