More Rotary Encoder Stuff...

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times
Contact:

More Rotary Encoder Stuff...

Postby Sparkoids » Mon Mar 18, 2019 1:54 pm

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 :-}

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

Re: More Rotary Encoder Stuff...

Postby Benj » Mon Mar 18, 2019 2:24 pm

Hi James,

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

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times
Contact:

Re: More Rotary Encoder Stuff...

Postby Sparkoids » Mon Mar 18, 2019 2:42 pm

(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 51 times

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times
Contact:

Re: More Rotary Encoder Stuff...

Postby Sparkoids » Mon Mar 18, 2019 4:06 pm

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.

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

Re: More Rotary Encoder Stuff...

Postby Benj » Mon Mar 18, 2019 4:18 pm

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.

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times
Contact:

Re: More Rotary Encoder Stuff...

Postby Sparkoids » Mon Mar 18, 2019 7:35 pm

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!
These users thanked the author Sparkoids for the post:
Benj (Tue Mar 19, 2019 1:53 pm)
Rating: 5.56%
 

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times
Contact:

Re: More Rotary Encoder Stuff...

Postby Sparkoids » Tue Mar 19, 2019 1:40 pm

It's working perfectly now Ben - thanks for all your help as always :-}
These users thanked the author Sparkoids for the post:
Benj (Tue Mar 19, 2019 1:52 pm)
Rating: 5.56%