Issues with quad encoders, second phase is missing counts??
rwgast_logicdesign
Posts: 1,464
Im having a really weird issue, I built two Quad encoders and I just went to tweak there placement and do a final bolt down with lock tight. Well I noticed that on my left quad encoder one channel is reading a much lower frequency than the others. All three encoder channels were reading about 480hz at 3.7v, The fourth channel which would be the lower one used to determine direction on the left wheel is only reading about 200hz. In reality I guess this isnt too important since it is not the encoder reading the speed. But whats bugging me is the wave form looks perfect! Im not seeing missing counts or longer pulses on the direction channel... Here is a picture showing the frequency at the bottom and the waves...
Comments
Can you post an Oscope shot that zooms in on a single wave form of ch 1 and ch 2? I'm seeing a strong 10 and a strong 01,but the necessary 00 & 11 conditions aren't so clear.
So I guess the new question is, are these encoders going to work even with the slightly shorter pulses on channel two?
Second is more problematic, your TCRT5000 sensors are not good for this application. They are relatively large and have no real directional isolation, just a minimal shield between the LED and PTX. They will give you a loosey-goosey output signal, not a sharp transition. Do you have any (electronic) filters or Schmidt triggers on this to give you a sharper signal to your micro? All I see is some resistors on your sensor PCB.
You could try to add a small tube to your sensor (at least the phototransistor) to make it more directional. Paint it flat black.
If you want a great sensor for DIY encoders, try these: http://www.junun.org/MarkIII/Info.jsp?item=48
http://forums.parallax.com/showthread.php/149740-Rare-Wheel-Encoder-Sensors-Available-Strike-Now!
Still out of phase a little bit, but much better. I know you use encoders all the time erco.. in your opinion is the signal above good enough? Im definitely going to see what I can do about getting the best transition point with the comparator and try to get the sensors a bit more directional too.. just wondering if where im at now is even close to acceptable or if the two encoder phases have to be absolutely perfectly 90 degrees off no exceptions!?
I have no problems buying the sensors you recommend above, but I would really just like to get what I have working so I can move on to this part of the software ASAP.
Well, I can't seem to upload the image this morning, but if you search the internet images for Q encoder wave forms you'll clearly see the 4 necessary states.
Shift the lower channel shown to the left a bit to give you a better 90 degree phase shift.
Per wild@, spend some time optimizing your encoder spacing for best results.
90' is the ideal point for best margin, and gives linear LSB edges.
A good Quad decoder, will still work, even with switching skewed a long way from 90'.
One problem with skew, is the Quad state decision time, needs to complete inside the smallest dT at highest speed, so you compromise the highest attainable speed.
The Propscope display does not make sense - the waveforms do not match the reported numbers ?
Both traces show just under 5 cycles in 10ms, but the numbers do not agree.
I will try conditioning the signal as well as I can then moving the sensors back a little farther if need be, as that will require some precision drilling. Thanks for all the info and links guys.
Sounds like the PropScope is less than ideal in how it calculates Freq, if you swap sources, does the error swap, or stay on Ch1 ?
Do you have another measurement instrument choice ?
eg try the frequency counter included here
http://www.daqarta.com/
Have you seen my hardware thread about encoders? One of the first things to take into account is the placement of the sensors. For example the ActivityBot encoder openings are are spaced 11.25 degrees apart (360/32). In order to get the sensor positioned correctly I placed them 14.06 degrees apart (11.25 * (5/4)). Since the openings were too close together for a 90 degree offset I used a 360 + 90 offset. 360 in this case is a full encoder cycle.
Since your cycles are 60 degrees apart, you'd want your sensors spaced either 15 degrees apart or 75 degrees apart (45 degrees should also work). You might be able to adjust this angle by moving your sensors radially from the center of the disk. You want one sensor to be right in the middle of a stripe (either color) and the other sensor to be right at a transition between colors.
You can get away with the encoders not being aligned just right as long as each transition can be caught separately.
I think my encoder software could distinguish the transitions as long as there were 6 us between the transitions. I think there's other software with even better resolution.
Be aware that Kye's QE object turns out to have a bug. Wildatheart found it. The object doesn't catch all the transitions.
I'm pretty sure it doesn't count transitions accurately either. Kye posted another object in the tread I previously mentioned. I've looked at it but it's over my head (as much of Kye's stuff is).
@Duane I have not tried to read the encoders using the Propeller yet. That is the next step. Im really doing whatever I can to try to not have to redo my sensor boards or re-drill my chassis.Basically what Im taking away from what you said above is that I should be fine as long as the encoders are in the right states for at least 6uS, and if I want my encoders have perfectly out of phase signals Im going to have to offset my sensors at 15 or 75 degrees and not 90?
Try AC coupling (ie a series 0.1uF) ?
It is strange that it is not even a 2:1 error - looks like a bug, and may be related to Phase, or trigger thresholds.
Does it change if the trigger channel changes ?
The icon shows a trigger point on a single cycle, but the screen does not show exactly where it is extracting the Freq info from. (ie Threshold used, how many cycles are included, and how it manages whole cycle inclusion)
Perhaps the PropScope Logic analyser mode includes a Freq Ctr ?
Yes, the loop reading the encoders take about 6us (though that included PWM generation) and you don't want both the A and the B channels to have both transitioned during one loop of the PASM code. As long as the transitions occur in separate loops the direction will be detected correctly.
The problem here is where using two different systems when we talk about degrees. There's the degree around the encoder disk and there's the degree within an encoder cycle. The two are not the same. They would be the same if your encoder disk had one black stripe which took up half of the disk. In this case the degrees of the encoder cycle would match the degrees around the disk.
Let's assume for a bit that you do have one big black stripe. Now lets say the black/white transition is at zero degree on the disk. You'd place one sensor inline with this transition and the other one in the center of either the black or the white area. In this case the sensors are 90 degrees out of phase.
If instead of a single black stripe you now had two so each section took up a quarter of the disk. If you left your sensors in the same location you'd now have both sensors over a transition point. While the sensors are still 90 degrees apart around the disk, they're 180 degrees out of phase in relation to the encoder cycle. To fix this you'd move one sensor so it's in the middle of a black or white section.
The important thing to remember is:
Some of your readouts look like they're 180 degrees out of phase and not 90. You do not want both channels to transition at once.
You may be adjusting one or both sensors only a few thousands of an inch. I found that slightly slotted fastening holes work well to adjust the sensors (for close to 90 degrees out of phase). Use a small rat tail file or the side of your drill to elongate the mounting holes - shouldn't require a major rework to your bot or your board. Set your scope to observe a single set of pulses and lock the sensors down as detailed above.
I'm using a 30 slot disk with a pair of TCST2103 optical slot switches and had to do exactly as I'm suggesting here. I also had to reduce the encoder slot size to a width of about .025 inches to keep my TCST's in the same plane.
Wildatheart I have already super glued the sensors and potted the board in rubber, so my easiest option may be to just print a new disk. Second best option is to probably just remake the two sensor boards.