Quad Encoder!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Quad Encoder!

Post by jgu1 »

Hi all!

I need a litlle help Again Please! :D

I try to play around with Quad Encoder (Bourns). I can not really get it to work. And can this be true I can not simulate the encoder in FC :?: It would be nice with an example where a counter counts up when turning one way and down when you turn the other way-.
Does anyone know where there should be a similar eksembel, or I can read about this.(I know the function of encoders, But not in FC) or best of all, perhaps one would try making a simpel
example for me in :wink: FC.

I would be very grateful

Best regard

Jorgen

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quad Encoder!

Post by JohnCrow »

1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Thank you John. Just what I need :D

Best regard

Jorgen.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi John!

I have now tested your program. It works (almost). :)

Maybe you can tell me why the counter counts 2 or 4 steps every time I turn the encoder one step. If I spin the encoder very slowly and rotates a half step, can I be lucky to counter counts 1-2-3-4 :?:

I use the encoder type: Bourns ECW1J-B24-AC0024

Thank´s in advance

Jorgen.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quad Encoder!

Post by JohnCrow »

Hi
Mine does that with the E block one
I suspect its a limitation in the encoder
1 in 10 people understand binary, the other one doesn't !

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Quad Encoder!

Post by medelec35 »

Hi Jorgen,
Do you want to try this one:
http://www.matrixmultimedia.com/mmforum ... 773#p26697
I also used the Bourns encoder. If you look at the top post you will see all the details.

There are other examples to try as well, if you look at the whole thread.

Martin
Martin

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Quad Encoder!

Post by fotios »

Hi to all
I just looked at the datasheet of Jorgen's encoder "Bourns ECW1J-B24-AC0024". If i have correctly read its PART NUMBERING SYSTEM, i think - Jorgen please correct me if i am wrong - that is a 24 DETENT equiped encoder. From my experiments CONTINUOUS rotary encoders can be easily programmed while DETENT equiped encoders are a real headache.
@ Jorgen: In the link that gave you Martin, you can find some useful fcf codes to try your encoder. According to datasheet its PATTERN is the same with this of ALPS, so you could try directly the related fcf file.
Now regarding detent equiped encoders, those that have the pattern of Panasonic are most easily programmed from those that have the pattern of ALPS and Bourns. Please look carefully in the atached schematic. There are also ALPS encoders with the same pattern of Panasonic.
Encoder Patterns.jpg
Encoder Patterns.jpg (74.58 KiB) Viewed 16378 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Quad Encoder!

Post by fotios »

Jorgen,
Here is a fcf to try your encoder with a LCD. You can run it on simulator as well. It should be noted that the code increments or decrements the counter by "1" per each detent, and that is the correct. For this reason only the IOC (Port) interrupt of Port RB.7 is used. If both outputs A and B of a detent equiped encoder are configured to cause IOC, then a big confusion occurs. So all other Port IOC interrupts are disabled and this - using FC v5 - can be obtained only by the use of a new series micro of Microchip, e.g. P16F1827. If you try a P16F88 with FCv5 you will see that all Port IOC interrupts are enabled simultaneously. Pull-ups also are enabled, for this reason the IOC interrupt is configured in the falling edge and in Decision icon is checked if Port B.7 (corresponds to transition) is "0".
Wishes for success.
Attachments
ALPS_INT.fcf
(17.5 KiB) Downloaded 381 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Quad Encoder!

Post by fotios »

Good morning to all
I have to add some thoughts:
One of the dominant efforts of all manufacturers of micros, is to incorporate into these as much peripherals as possible thus minimizing the need of use external components. In this direction have been incorporated e.g. the internal pull-ups. So it should use them.
On the other hand, the detent equiped encoder is constructed under the logic to offer a sense of the "clicks" of a traditional rotary switch rather than a potentiometer or dialer; i.e. the feeling that each "click" is equivalent to ONE state change. So the IOC interrupt is only needed to one of the two switches of encoder. The second switch serves only in the evaluation of the rotation direction. In the picture it is evident that the pattern of Panasonic is more distinct, more clear than the pattern of ALPS - Bourns. The imaginary line of each detent coincides with the middle of ON - OFF pulses produced by switch A. Thus, when the encoder is rotated clockwise, the High to Low transition of switch A clearly coincide with the positive edge of pulses produced by switch B . When the encoder is rotated counterclockwise, a High to Low transition of switch A - again - clearly coincide with the negative edge of pulses of the switch B. That offers the ability of the use of only one interrupt making the whole process simplest.
In a comparison the detents of ALPS - Bourns encoders are located at the negative edge of pulses of both switches A and B and even in a short distance from transition points. So, it's some hard to evaluate the direction of rotation using the falling edge IOC interrupt - remember please that the internal pull-ups are enabled - without mistakes.
Thanks for your attention
Best Regards FOTIS ANAGNOSTOU

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hello to you all!

Many thanks for your help. It's really good I can always get help here. :D

I must try to have bought a different type of encoder and chip and have tested it.

But in the meantime I have become very confused. I have previously in version 4.5 made ​​a program for this BOURNS ENCODER without interrupt. I would test it again and brought it into the version FC ver. 5.2 and compile it to the chip. But it does not work. I have saved the original ver. 4.5 program. Then I start CF ver. 4.5 up and compile the original FC program to the chip, then it works? Now my question, should it be it not be possible to open a ver. 4.5 FC program in 5.2 and then the compile to the chip :?: :?:
In this case not. I would be happy if anybody would be able to test it and confirm and maybe tell me what i am doing wrong or to take care of if I use a FC 4.5 program in FC5.2.

When I coplile to chip in ver.4.5 everything work´s fine encoder display in real world.
When I use ver.5.2 I only see the first string in the display and nothing happend when I turn the encoder :?: .

The att. file is an original ver.4.5 program and have NOT being opened in ver 5.2

Fotoios and all, thank´s

Regard the confused

Jorgen
Attachments
Bourn5.fcf
(10.5 KiB) Downloaded 343 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quad Encoder!

Post by Benj »

Hello Jorgen,

Hm thats strange that it's not working for you when compiled with v5.2.

I guess the wait until macros are getting stuck for some reason. In v5.2 we have implemented full debounce on switch inputs so this could be the issue.

In the properties for both the switch components the debounce is set to 10ms. Try setting this to 0 and the program should hopefully start working for you as expected under v5.2

Let me know how you get on.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi Ben! :D

Yes, of course this could be the reason. I will test it later today when i am home (still at work) and you hear from me. Thank´s!

Best regard

Jorgen

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi Ben!

Unfortunately Ben it dosn´t help. I am pretty convinced that there is some bug in FC5. I am still experiencing the same thing. In FC4, no problems. But in FC 5 does the same program not work. I can I be lucky sometime after compile to the Pic that the encoder will steppe up or down max 4 to 5 step but then its stop working. Not even if I reset the Pic.

Sorry. PLS help

Best regard

Jorgen :x

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quad Encoder!

Post by Benj »

Hi Jorgen,

Please can you play around with the active high / active low and see if this helps with the v5.2 version. There was a bit of confusion regarding this in v5.0 but this should all be sorted by now.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi again Ben!

I would do anything to solve the problem. But do you mean by active high/low to put an output on another port, to check where the program stop. Yesterday I spend many Hours by this tests, and I could see everytime the program stop when it comes to the componentmacro for switch.
But if I misunderstod you, please explain further.

Best regard

Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quad Encoder!

Post by Benj »

Hello,

I mean the option in the switch component properties. Try setting one of the switches to active low and then the other and then both and let me know how you get on with the hardware.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Ok Ben!

When both switch is active low: I can se the program continue, the display is updating but the counter stop at 0 (down) and stop at 2 (up)

When switch 0 is active low and 1 is active high: Nothing happen.

When switch 1 is active low and 0 is active high: The same as both active lov.

If you want, I can send you a bourn encoder as I use and a pic16f876 for free of course.

Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quad Encoder!

Post by Benj »

Hi Jorgen,

Hopefully we can work this out fairly quickly without the need for sending parts to us but many thanks for the offer. If we cannot bottom this problem then it may come down to that.

So the polarity is not the issue - glad of this as I know this was fixed.
And the debounce is not the issue we think - At least a 0 debounce shouldn't cause you any problems.

I wonder what sort of frequencies you are getting back from the encoders. Could you have a guess at how often the pins change state? Is it dependent on how fast you are spinning the encoder?

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Ben it is hard to say how fast it is, but there is no change no matter how quickly or slowly I turn, and again why it works perfectly in ver.4 and certainly not in Ver.5 But there was the change when both were active low, so I could see that the display was updated but the counters did not work.

Now you me tell if I bother too much. :D :(

Regard
Jorgen.

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quad Encoder!

Post by JohnCrow »

Hi Jorgen

Ive just tried your flowchart

Works fine as is in FC4
Did not work in FC 5.2 as you say

Just tried changing the switchs to active low (from active high) it now works on my system
Bourn5-Active Low.fcf
(15.7 KiB) Downloaded 261 times
TW-700198.pdf
Data Sheet
(84.94 KiB) Downloaded 280 times
Im using an Alpha Rot Enc (318-ENC130175F-12PS)
A & B have 10k pullups to 5V (Outer terminals) center is gnd.
Mine will roll over to 0 from 255 and to 255 from 0

I left the debounce at 10ms
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi John!

Thank you for testing!

Glad to hear you get the same result... So I am not totaly crasy, Hi,hi. :D

I have just tested your program. I am only able to count down. And I use exactly the same settings in the hardware as you, but of course the encoder is not the same.

But anyway, it works in ver.4 but not in ver 5 and you get the same result. What can be wrong :?: Í mean, should´n it work in both version.

What can be wrong??

Best regard

Jorgen

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Quad Encoder!

Post by JohnCrow »

Very Strange

The Bounes is a good high quality component. The alpha I'm using a very cheap one. Think it cost about £2.50 (About 3 euro)
I got it before Matrix released the Rot Enc e-block to to try a few tests with, didnt want to spend much as I wasn't sure at that time FC could work with encoders.

I maybe clutching at straws, but have you tried configuring the Rot Enc as it is on the e-block. The circuit has RC network as a lowpass filter on the output.
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi John!

RC filter was also my first thought when I opened the program with Ver.5 so I've also tested without success. But then of course I remembered that I had created the program in ver.4 and could remember the program worked. So I opened the original application in ver.4 and could see it was perfect. So my thoughts are, should it not give the same result in Ver.5. with same program.

I still think there is an error in Ver.5 :?:

Thank´s for your care.

Jorgen

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Quad Encoder!

Post by medelec35 »

Hi Jorgen.

The only thing with switches that have to WaitTillHigh and WaitTillLow, is if encoder not moving then your program is halted until encoder moves again.

I have modified a flowchart for your encoder then will used port B interrupts for encoder detection, so your program can be doing other things whilst waiting if desired.
The only thing is A an be B of encoder had to be connected to portB 6 and 7 respectively.
You won't need resistors because I have enabled portB weak pull-ups
If you are using EB006, and have not got a parallel IDC lead, then you can use an continuity tester e.g. multimeter on low ohms range
and with no power going to board, buzz out RB6 and RB7 of your chip to any empty IC socket and use link wires from the IC socket to your encoder.

I have tested FC5 flowchart on real hardware (works better than simulation) with 16F883 and a bourns encoder as shown on a link in a post above.
Encoder works very fast if required.

Of course it's up to you if you give it a go, but at least it's something to fall back on if all else fails

Martin
Attachments
Rotory Encoder 16F876 V1.fcf
(18.37 KiB) Downloaded 316 times
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Quad Encoder!

Post by jgu1 »

Hi Martin!

Ok I will of course test your program and thank you. but it becomes tomorrow. But it still not give me an answer.


Now it´s not something I need urgent. It causes from the start I try to play around with the quad encoder component in ver.5 and then I discovered this "bug" by the switches.


But still, my big question, why it works in ver.4 and not Ver.5? Should it do it?.

I hope you understand my frustrations.

At the same time I thank all who helped.

Jorgen.

Post Reply