I have a disc, 10" in dia, mounted on a stationary base. The disc's plane is tilted w/r to the base (which rests on a table) I want to measure the angular rotation (orientation) of the disc, around the axis perpendicular to the disc. I do NOT want to measure its rotation rate, but the angle. What's the cheapest way to do it? The disc is tilted so I could use an accelerometer on the disc, but they seem to be in the $10-$20 range. There are also rotary encoders, but they need to be on the axis (dead center), but the space there is very limited. Is there a cheap optical sensor, which optically reads some markings to establish the angle (and doesn't have to be in the center of the disc)?
Sure. You could put a series of lines on the underside of the disk and use an IR sensor that also contained an IR LED for illumination, and count the lines as your moved the disk.
Please tell how fine you need the angular displacement and the total displacement needed.
Thanks. Accuracy isn't important, but I want to know the absolute angle (angular position), not just the amount of angular displacement (by counting the lines). E.g. if the disc is rotated when the device is off (so it's no longer in its last known position) I want to detect this. I think I need some reference point (or points) on the disc, so that, when the device is back on, I can re-establish a specific, fixed angular reference
Then you need an absolute position sensor. What resolution ( in degrees) do you want?
Many people use an optical sensor to locate an index hole on the disk, or a pin or vane on the shaft to establish the zero position. This requires you to rotate the disk upon power up, to locate the zero reference.
Well, yes, but of what kind ? Resolution isn't important, I think I can get away with ~20 deg accuracy.
@johnerrington beat me to it. Paint a 4-circle Grey code or binary code (not sure what the difference between those two types is, they seem the same to me) and detect the angle with 4 IR sensors. This will give you an accuracy of 22.5 degrees. If you can't find IR sensors cheaply enough, 4 LEDs and 4 LDRs would probably work.
With binary code (0000, 0001, 0010, 0011, 0100) you sometimes get two channels changing 'at the same time' which causes race conditions. With Grey code (0000, 0001, 0011, 0010, 0110) only one channel changes at a time.
Thanks @johnwasser. It's a very clever idea!
Thanks for that link. Looking at the patterns, I came up with an idea of using just 2 LEDs/rings, yet being able to fix an absolute position within 1/8 of a turn. In the pic below, the inner lines measure relative angular change. The outer lines encode 8 markers around the ring (like hours on a clock). They are numbers 0-7 but in binary (using 4 spots). A "gray" space in the inner ring marks the beginning (or the end) of the binary marker in the outer ring (depending on the direction). I used gray lines in "blank" spots, so it's more clear. One can speed up the acquisition of an absolute angle with more binary markers around the ring (more spots per marker). With 5 spots per marker (numbers 0-15), you could fix an abs. position within 1/16 of a turn. The angle accuracy depends on the number of spots in the inner ring. In this case it's 360/184=~2 deg
Credit where its due - its not GREY code
The reflected binary code (RBC), also known just as reflected binary (RB) or Gray code after Frank Gray, is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit).
Looks like a possibility. How do you detect the direction of travel? How does the sensor on the inner ring detect the difference between a blank spot and a slow move between two non-blank spots? I'm guessing the inner ring needs a quadrature sensor for both purposes.
I should probably add that in my case there are specific types of rotation: no small rotations, but larger sweeping arcs 40, 60, 90 deg etc (sort of like steering wheel in a bus). The direction of motion isn't important, just the final rest position. Having said that, the previous 2-ring design has some flaws, so I came up with a new 2-ring idea: the outer ring calibrates black, white and mid-gray values for the current lighting conditions. The inner ring just reads a white-to-black gradient (in the same lighting conditions) to get the current angle. The mid-gray is to account for non-linear light response (gamma). I think light sensors can detect 256 colors (360/256=~2 deg), it should be more than enough for my 20 deg accuracy
If you're going to to that, then why not dispense with the multiple rings and just use a grey gradient around the entire circle and use that as your absolute position?
You can calculate the orientation with the rotation rate. For example, I calculate the orientation of my rocket this way. A very cheap chip for this job would be the MPU6050 a more expensive one would be BN055 (if you are planing on longer measurements probably the way to go because of low drift)
Right now, the gadget is open (no case), so outside light gets in. I'd have to account for changes in lighting conditions (which change the values for B & W points). To use just the gradient ring, I'd need to add a LED next to the light sensor, and a light-proof enclosure around the LED/sensor to force constant lighting. I may do it.
Like I said, I need an absolute angular position of the disc, not just a relative angular change. Also, I need to account for cases when the disc is moved (when the device is not in use) or if the whole device is moved (in case of geomagnetic sensors). Would MPU6050 tell me the absolute angle and account for these issues?
MPU6050 has a built-in accelerometer with which you can take the absolute orientation