Page 1 of 1

More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 1:54 pm
by Sparkoids
I fired up Flowcode 7 to test the Rotary Encoder EB-073 and just cannot read the input into a variable.

On ReadCounter from the component macro it always returns a zero.

How do I set that up please?

All I am trying to do is detect if the rotary is turning clockwise or anti-clockwise so the number goes up and down depending upon that. I am assigning the read value to a variable called count then printing that to the LCD. Or not in this case.

I have checked the data sheet and get the quadrature bit but cannot get the variable to change.

Any ideas please?


James :-}

Re: More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 2:24 pm
by Benj
Hi James,

Please can you post your project file so we can see what you're doing.

Re: More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 2:42 pm
by Sparkoids
(I have removed the interrupt on Port B just to test it Ben)

Maybe the binary isn't being converted to decimal?
Encoder_04.fcfx
(9.28 KiB) Downloaded 361 times

Re: More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 4:06 pm
by Sparkoids
I was looking for the binary to indicate the direction.

00,01,10,11 goes one way and 00,10,11,01 goes the other. Every time I count up to four bits I can reset and go back to the interrupt on Port B and start counting again was the idea. I just need to see the number going up or down - the speed will be controlled by the interrupt being fast enough to keep up.

Re: More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 4:18 pm
by Benj
Hello,

If you are using an interrupt then use the CheckForChanges macro inside the interrupt. The check for changes macro needs to be called either on an interrupt or on a fast poll to catch the changes as they come in.

You care calling the ReadCounter macro and then using a byte variable as the return. Byte variables can only store positive numbers. Maybe use a signed int instead.

Re: More Rotary Encoder Stuff...

Posted: Mon Mar 18, 2019 7:35 pm
by Sparkoids
Ever feel like banging your head on the desk?

In fairness it's my first time on FC in three years but putting the Quad Encoder board into Port B when you're always looking for an interrupt on Port B is a better idea then having it in Port A and the LCD in Port B.

Your example program is working OK Ben thank you very much :-}

AGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH HOW MANY BLOODY HOURS DOING THIS FFS!

Re: More Rotary Encoder Stuff...

Posted: Tue Mar 19, 2019 1:40 pm
by Sparkoids
It's working perfectly now Ben - thanks for all your help as always :-}