PIC Assembler users - rotary encoder routines?

Homebrew equipment discussion, show off your projects.
VK5TM
Posts: 242
Joined: Sun Oct 28, 2018 11:40 pm
Location: South Australia
Contact:

PIC Assembler users - rotary encoder routines?

Unread post by VK5TM »

I'm hoping that somewhere amongst the various members here there may be some users of the PIC micro.

If there is, has anybody come across (or has and is willing to share) a routine for a rotary encoder that will work much like on a commercial rig, as in, as you spin the encoder faster, the frequency step size increases.

I've tried some routines from way back in the dark ages, but they just don't work smoothly (if at all) or just don't feel right for some reason.

This has been a thorn in my side for years trying to get a decent routine for use on my DDS projects.

Please note I program in assembler, 'C' just makes this old brain seize up with it's weird syntax, vague plot lines and ..... :?: ... snore!
M0XXQ
Posts: 484
Joined: Thu Sep 27, 2018 10:23 pm
Location: Newcastle upon Tyne
Contact:

Re: PIC Assembler users - rotary encoder routines?

Unread post by M0XXQ »

Hey Terry, can't be much help ASM mate but C and C++ no problems.
I wrote such a routine for my Arduino based AD9959 DDS, so rather than go into code as it was done in C++ I will talk about it as a function.
Essentially what you need to do is monitor the encoder RPM with a counter and a timer, once the counter has reached a predetermined limit and the timer has elapsed X milli second's you switch the step size radix from say 10Hz to 100Hz.
Of course you need to monitor this the other way for different tuning directions and use signed Integer data types as counters may go negative.
When I get back to the hotel later I shall knock up a block diagram of the function to better illustrate what I am on about.

Cheers

Rob
VK5TM
Posts: 242
Joined: Sun Oct 28, 2018 11:40 pm
Location: South Australia
Contact:

Re: PIC Assembler users - rotary encoder routines?

Unread post by VK5TM »

Thanks Rob.

I've tried one like that but it was very twitchy around the step size change point.

Really needed some hysteresis added in to make it less twitchy.

Must go and look at which of the PIC's have a built in Encoder port and get some samples. :)
Post Reply