I have something like a "data ready" on my mind, where an extra detector with a very short hole tells the CPU to "read now". This has the disadvantage of not knowing, where the encoder is when the system is powered on. But the reading of the position while it's moving will always be at the best position - the center of a obscured or open area. And who will stop you from implementing a Hamming code here too together with the Grey code 😀
Nice work there! A couple suggestions I can think of, are to have the copper side of the encoder near the detectors, to minimize the difusion of their edges to the detectors. Next a slit mask over the detectors, so they only can see light from a think slit of the encoder. Leave off the solder mask of you next encoder, or test to find which mask transmits the most Near IR. Your code can be quite simplified with a lookup table. You can go from a HUGE if() tree, down to just a few lines. (smaller code space, much faster execution) EXAMPLE with 2 bit grey code : int Grey2Pos[ ] = 0b00, 0b01, 0b11, 0b10 ; gray = (encoder) posTest = Grey2Pos[ grey & 0b11 ]; // the "& 0b11" masks for wrap around, aka mod-4 If ( (posTest == (pos + 1) ) || (posTest == (pos -1) ) // has it moved to the next or privous posistion? pos = posTest; // YES, Save the new position else glitch++; // No, there's been a glitch... so record it In the future, say in your next project, you should look into how digital calipers work, as they give dozens of microns of resolution, with a simple capacitor array.
OPS! There's a bug in the code... it missed the edge cases of "pos = 0" and "pos = MAXpos" The test for if "pos" should be updated needs to expand.... add to top: greyMASK = 0b11; MAXpos = 3; and change the one if() test to 4 tests... if (pos == 0) // test for underflow of posPrev posPrev = MAXpos; else posPrev = posTest =1; if (pos == MAXpos) // test for overflow of posNex posNext = 0; else posNext = pos+1; if (posTest == posPrev) pos = posPrev; if (posTest == posNext); pos = posNext; Not only will this actually work, it's easier to follow what it's doing.
I'd want an absurd amount of these to use for smart home stuff, but I'd hide them in innocuous items and decorations. Then I get to have fun controlling light or volume or whatever by interacting with my room in a weird way
Nice job, this could be very useful in detecting the angular position of a non constrained rotor like the rotor of a lidar or radar. Thank you for sharing!
Hi, thank you for the effort on this series; my use case would be a much lower frequency application as a wind vane position indicator to show and record wind direction. bye
You are on a good track that will work. It will be interesting to see how fine a resolution you can get. There are certainly uses for 4-bit absolute encoders, but the greater the resolution, the more uses for the encoder. I always wanted to work with these when I had the facilities to do so, but I never had the time. Now, it is much less expensive to do these kinds of things, so it is good to see you doing them.. Using a single light fiber smaller than the width of the copper trace to precisely illuminate each trace of the encoder would reduce the cross talk at the price of added parts and complexity. Moving the light sensor to 8 different positions around the axis of the encoder should eliminate cross-talk and the cost of the need to very accurately position the light sensors or do a fix-up in software needing a much faster CPU to race the same speed the simple encoder can achieve.
Thanks for watching! Spacing the pairs of photodiodes and LEDs around the circumference is a great suggestion! I think the fibers will be too expensive for the intended use cases. Feel free to check out the latest video It features an updated 8-bit version.
Nice. If you do get the thing remade again, I’d try it with copper on both sides. Also no solder mask. 3D printed light funnels might help to prevent crosstalk. For a use-case? A cheap brushless servo to replace stepper motors on CNC machines like 3D printers. If only TMC4671s were cheaper, maybe there’s a Chinese company making something equivalent.
I'm interested in a really cheap absolute linear position encoder. It doesn't need to be particularly fast, since it is tracking the movement of a 3d printed mechanism being positioned by a servo motor. This approach seems like it could be adapted to this use case, and it could be implemented by PCBs with surface mount components, so it would be cheap to prototype. Do you think this approach would be feasible and yield the results that I'm looking for? Anybody have an open source example of somebody doing something similar?