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

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

More Rotary Encoder Stuff...

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

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

Re: More Rotary Encoder Stuff...

Post by Benj »

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...

Post 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 350 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...

Post 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.

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

Re: More Rotary Encoder Stuff...

Post 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.

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...

Post 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!

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...

Post by Sparkoids »

It's working perfectly now Ben - thanks for all your help as always :-}

Post Reply