Yup, as long as one is LOW, it remains in the loop.
Robert
Yes it will for the time that either is in LOW state. If there is a possibility that this condition is likely to happn pemanently, then you have other options to choose.
As stated on he first post, that is an interesting experiment of another way (more simple) to do the same task. No-one is forced to accept it. Or use it. Just forget it and you will be just fine.
Ioannis
Please forgive me if it seemed that I was complaining. I was just trying to understand how your method worked.
If you're using a rotary encoder with detents as a control, detecting a single AB transition (out of four) between detents is probably preferable. That's how I do it but I use a switch state latch and simple parallel switch state logic to filter out the unwanted switch states.
Your method is simple and elegant. Thank you for sharing with us...
Cheerful regards, Mike
No problem Mike. I have to admit that I was a little touchy.
Yes, the idea was to read a mechanical rotary encoder with detents. Sure is better to buffer the port states and then do the processing.
Even better, use interrups to grab the port change and then do whatever you want. More, make a debounce based on interrupts since mechanical switch of the encoder do bounce a little. But this is for more advanced programmers. Maybe later when my related project allows.
Ioannis
Hello world. I have learnt a lot from lurking these threads so i thought i would try and help someone else out a bit.
All your encoder worries can be over for about 50 pence and if i can get a picture in here i will show you how...........
the thing to realise is that moving along waveform A from left to right the negative edge of A is always when B is low. moving back the other way the negative edge is always when B is high.
the jk flip flop clock input is negative edge triggered and when triggered it feeds the input on J through to Q -- but only if j and k inputs are opposite hence section 1 of the nor gate to invert the signal. j is always opposite to k now. and the clock input always gets triggered right in the middle of the high or low so it never misses.
so, when moving clockwise Q will be high and anticlockwise it will go low.
two other parts of the quad nor gate (2 and 3 above) to produce a hardware XOR on output C and producing the waveform at bottom of screen.
Now all you need to do is feed C into an input that generates interrupts on a negative edge trigger. when the interrupt fires all it has to do is look at the level of D and either add 1 to clockwise total or subtract 1. Thats it. Your programming days are over.
And, all the mushy signal edges and bounce are tidied up too. Lovely solid latched outputs.
And you are going to have to go some to bother them with speed or with slowness.
Not bad for 50p I hope you will agree.
Hey podgycode...
I have not tried your circuit. I would guess it works as you describe.
What I can't understand is why is this so difficult to do using two PIC pins and some code. Are these rotary encoders so difficult to read using code??
I am struggling with this very thing myself. I have two rotary encoders... one that I have wired up and done some basic testing... one that I have not tried yet.
I have also done quite a bit of searching over on the Parallax Basic Stamp forum, since the basic stamp uses VERY similar language to our PICbasic.
I really would like to use interrupts (DT instant INT's, if possible)
My real problem is TIME. If I only had more of it, I'm sure you all can relate.
Any way, if anyone has some good sample code (that used interrupts) for one to try... that they might be willing to share![]()
Last edited by Heckler; - 4th November 2011 at 15:43.
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Bookmarks