Quadrature selection with BS1
Liquidaudio
Posts: 8
Hello all
I am trying to use a BS1 since I thought this would be an easy project to program but I running into many problems I had not thought of. What I am doing it making an automatic selector to choose between a pair of quadrature encoders and have the output A and B signals increment or decrement as the selected input does. What I am finding makes this so hard is one set of inputs changes 2 states (i.e. ALWAYS rests at 00 or 11 and cannot be changed without big hassels) while the other only changes one bit at a time. Inputs are very slow, under 100Hz at the top end, typical measured values are 12Hz to 3Hz.
I have experience in C and assembly language for Motorola 68HCxxx and find the lack of freedom with the Pbasic language hard to cope with. If you have any suggestions or reference website's for graycode counting or conversion to binary I am eager to find out how this may be possible. Or would changing Stamps to a BS2 be better?
Thanks, John
I am trying to use a BS1 since I thought this would be an easy project to program but I running into many problems I had not thought of. What I am doing it making an automatic selector to choose between a pair of quadrature encoders and have the output A and B signals increment or decrement as the selected input does. What I am finding makes this so hard is one set of inputs changes 2 states (i.e. ALWAYS rests at 00 or 11 and cannot be changed without big hassels) while the other only changes one bit at a time. Inputs are very slow, under 100Hz at the top end, typical measured values are 12Hz to 3Hz.
I have experience in C and assembly language for Motorola 68HCxxx and find the lack of freedom with the Pbasic language hard to cope with. If you have any suggestions or reference website's for graycode counting or conversion to binary I am eager to find out how this may be possible. Or would changing Stamps to a BS2 be better?
Thanks, John
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
http://www.emesys.com/BS2fsm.htm
Also in the same article, encoders. It sounds like one of your encoders might be defective.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
thanks for the info. The encoder is not defective, that is what it was designed to do. It transitions from 00 to 01 then 11 in one detent then 11 to 10 then 00 in the next. The two are mechanically interlocked to prevent both from being operational at the same time. Adjustment of the single bit change encoder is not possible from what I can see, it becomes unstable and waveforms jitter due to mech vibration in the system.
The machine is expecting the sequence described above but the additional encoder that only changes one bit per detent must be conditioned so that it too will output the same sequence from 00 to 11 or vice versa.
So, it may be possible with the BS1 to accomplish this task? RAM space so far is my biggest limitation, I only have one unused word.
Thanks, John
The quadrature encoder which transitions one-bit-at-a-time is expressing its output in Gray Code (00 01 11 10) as you have noted. However, an encoder which outputs only two binary patterns (00 11) isn't gioing to be usable for quadrature purposes. That may or may not be important to you.
A quadrature output will provide both speed and direction, and missing codes are detectable with four states to work with. There is no ambiguous case with quadrature output. The same can not be said of a straight binary (00 11) output with only two states.
Unless there is more information available, I'm not sure I can see how a four state output can be extrapolated from a two state device accurately and reliably. Perhaps I'm missing something though.
There is another possibility, however. The seemingly 2 state output may actually be a sine wave output, as opposed to a square wave output. If that's the case then polarity comes into play and there are 4 discernable states (Ex. 0, -1 | -1, 0 | 0, +1 | +1, 0). Ignoring the polarity (by error) would make it look like a two state device and your output which appeared to transition from 00 --> 11 was actually transitioning from 01 --> 10, 10 --> 01 . I suppose there are other variations on that same theme as well. Just a thought.
Regards,
Bruce Bates
The encoder does go through 1 change between 00 and 11, it ONLY rests at these values due to gear arrangements. They are dry contacts. for example increase is 00 - 01 - 11 for one step, next step is 11 - 10 - 00; deacreasing is 00 - 10 - 11 for the first step, then 11 - 01 - 00 for the second.
I did get the conversion for grey to binary working this morning, makes figuring out direction much easier, speed is not important. It looks like I may have to move up to a BS2 since I'm out of space for variables and only have 9% more EEPROM space left.
BTW one encoder is 10cpr the other is 28cpr
Thanks, John