Quad encoder

Any bugs you encounter with Flowcode should be discussed here.
chipfryer27
Valued Contributor
Posts: 1149
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 286 times
Been thanked: 412 times

Re: Quad encoder

Post by chipfryer27 »

Hi Martin

I though his issues were simulating the examples?

Regards

medelec35
Matrix Staff
Posts: 1452
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Quad encoder

Post by medelec35 »

Yes, but the 360 edges if that is not the same as the hardware, it will make it look the the encoder is not rotating, especially if the repeat rate is set to slow.
Martin

chipfryer27
Valued Contributor
Posts: 1149
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 286 times
Been thanked: 412 times

Re: Quad encoder

Post by chipfryer27 »

Hi

Why would his HW affect a downloaded example file, or am I missing something (probably)?

I thought he was having issue with simulating the example file.

I can probably play with HW tomorrow and see what I find.

Regards

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Quad encoder

Post by WingNut »

The issue is with simulating the example file. I haven't programmed the example into hardware. My own circuit and program has the issue but with out the example simulating I don't have a starting point to reference. I have tried every setting including those mentioned and the simulation still jumps but I will continue to test

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Quad encoder

Post by WingNut »

Ok so I've change the repeat rate to slow and it seems to simulate with only minor jumping. It misses the odd click with the mouse.
Hardware is different. There appears to be 20 detents (or is it 19). I'd already determined this. But its difficult to tell if the device is mechanically accurate - i.e. is the A and B outputs placed accurately between the detents. More testing required and I'll figure out what sim settings is best to allow me to carry on with the hardware side

chipfryer27
Valued Contributor
Posts: 1149
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 286 times
Been thanked: 412 times

Re: Quad encoder

Post by chipfryer27 »

Hi

I connected a decoder to a logic analyser and this one seems to have little bounce if rotated smoothly (but it does suffer if not)


Clockwise two clicks

Clockwise.jpg
Clockwise.jpg (47.04 KiB) Viewed 4481 times

Anticlockwise two clicks
Anticlockwise.jpg
Anticlockwise.jpg (47.86 KiB) Viewed 4481 times


I downloaded the example Quad_Encoder_Timer file from the WiKi, changed the chip / ports to suit, and set the component postcaler from 1:1 to 1:4. As each "click" creates four transitions having the scaler set to 1:4 returns "click count". Note I'm using a KY040, other modules may differ)

https://www.flowcode.co.uk/wiki/index.p ... ral_Input)

I'd no problem using it. I didn't try IOC as my chip has them on Port-B, which my combo uses as LCD so.....

Regards

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Quad encoder

Post by WingNut »

I agree that in hardware if you rotate the knob slowly you could see the counter go up and down by one. And thats not using my analyser just a pure observation. So theres probably a set up and filtering hardware issue to fix. But the simulation of the example for me jumps and I don't know whay. Thanks for taking the time chipfryer

chipfryer27
Valued Contributor
Posts: 1149
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 286 times
Been thanked: 412 times

Re: Quad encoder

Post by chipfryer27 »

Hi

Does it make any difference if you slow your simulation speed down at all? Extra "clicks" sounds perhaps your PC is reading too quickly. Is it the same for IOC?

Regards

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Quad encoder

Post by WingNut »

The best I can get is 20 edges 1:1 post scaler, slow repeat rate and a pause between clicks. But even then it skips a count. Odd as can be. Think I'll focus on the hardware but its hard to develop a program without the simulation running correctly. Not tried the IOC or timer interrupt as the interrupt isnt a reliable simulation anywaay

Post Reply