Page 2 of 2

Re: Quad encoder

Posted: Wed Sep 27, 2023 8:42 pm
by chipfryer27
Hi Martin

I though his issues were simulating the examples?

Regards

Re: Quad encoder

Posted: Wed Sep 27, 2023 9:06 pm
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.

Re: Quad encoder

Posted: Wed Sep 27, 2023 11:06 pm
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

Re: Quad encoder

Posted: Thu Sep 28, 2023 6:21 am
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

Re: Quad encoder

Posted: Thu Sep 28, 2023 6:58 am
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

Re: Quad encoder

Posted: Thu Sep 28, 2023 2:58 pm
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 4685 times

Anticlockwise two clicks
Anticlockwise.jpg
Anticlockwise.jpg (47.86 KiB) Viewed 4685 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

Re: Quad encoder

Posted: Thu Sep 28, 2023 3:49 pm
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

Re: Quad encoder

Posted: Thu Sep 28, 2023 4:35 pm
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

Re: Quad encoder

Posted: Thu Sep 28, 2023 4:57 pm
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