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 :-}
More Rotary Encoder Stuff...
- 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...
Hi James,
Please can you post your project file so we can see what you're doing.
Please can you post your project file so we can see what you're doing.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 267
- Joined: Mon Sep 14, 2009 10:34 am
- Has thanked: 30 times
- Been thanked: 19 times
- Contact:
Re: More Rotary Encoder Stuff...
(I have removed the interrupt on Port B just to test it Ben)
Maybe the binary isn't being converted to decimal?
Maybe the binary isn't being converted to decimal?
-
- Posts: 267
- Joined: Mon Sep 14, 2009 10:34 am
- Has thanked: 30 times
- Been thanked: 19 times
- Contact:
Re: More Rotary Encoder Stuff...
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.
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.
- 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...
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 267
- Joined: Mon Sep 14, 2009 10:34 am
- Has thanked: 30 times
- Been thanked: 19 times
- Contact:
Re: More Rotary Encoder Stuff...
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!
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!
-
- Posts: 267
- Joined: Mon Sep 14, 2009 10:34 am
- Has thanked: 30 times
- Been thanked: 19 times
- Contact:
Re: More Rotary Encoder Stuff...
It's working perfectly now Ben - thanks for all your help as always :-}