Rotary Encoder not working as aspected help? (Solved)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Rotary Encoder not working as aspected help? (Solved)

Post by Jordy101091 »

Hi all,

Im testing a circuit that involves a rotary encoder, I have copied the schematic from the data sheet of the rotary encoder eblock, I checked it whit my scoop and its the signals are nice and clean.
However when I try to count pulses its not what I suspected. first of all the controller I'm using:

* PIC18F8722
* 25Mhz

I have made a one second flasher and its spot on scoop says 0.998 seconds.
First thing I've done was enabling the encoder. after that a interrupt that responds on a falling edge of RB0/INT0 Why not PORT interrupt, because it was even worse Im getting no result when using port interrupt, any-way in the interrupt I have macro that detects any changes. In the main program I have a loop and two macros one that counts the encoder and the second that displays the result.

The problem here is, Im not getting that smooth counting it jumps from 3 to 8 back to -4 and the back to 9 I don't know what going on.
Can I use a timer interrupt instead of interrupt on Port B0.

Please let me know,

Regards Jordy

PS. if you need the program just say :P
Last edited by Jordy101091 on Sat Jul 21, 2012 10:17 pm, edited 1 time in total.
the will to learn, should not be stopped by any price

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times

Re: Rotary Encoder not working as aspected help?

Post by Enamul »

hi jordy,

Can you please post your program so that we can have a look what is going wrong?

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Rotary Encoder not working as aspected help?

Post by Jordy101091 »

Here you go Enamul,

The rotary encoder is connected to PORTB.0 (A1)and PORTB.1 (B1)

Hope you can find something.


Regards Jordy
Attachments
AquaTronics_Controller_V2.0.fcf
(30.35 KiB) Downloaded 289 times
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Rotary Encoder not working as aspected help?

Post by Jordy101091 »

Email,

I have used à timer interrupt That was running ad 24xxxx MHz I think.
It was fast enough to record any movement of the rotary encoder, a little bit to fast because every dent cause a count of +4.
Slowing the interrupt down was not a success because again at every dent cause a count of +4 also when the encoder turns fast it does not record it. Don't know what I'm doing wrong here.

Hope this help you to find a possible solution.

Best regards jordy kleian
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Rotary Encoder not working as aspected help? (Solved)

Post by Jordy101091 »

Hi All,

I have solved this problem, the rotary encoder was working the whole time perfectly just the way it supposed to, but not the way I wanted.
The acro for this component has 4 different cases.

Code: Select all

switch (maskcheck)										//Search for current state
		{
			case ( 0 ):
				if ( %a_encoder_mask == 2 )
					%a_encoder_count = %a_encoder_count + 1;
				else
					%a_encoder_count = %a_encoder_count - 1;
				break;

			//case ( 1 ):
				//if ( %a_encoder_mask == 0 )
					//%a_encoder_count = %a_encoder_count + 1;
				//else
					//%a_encoder_count = %a_encoder_count - 1;
				//break;

			//case ( 3 ):
				//if ( %a_encoder_mask == 1 )
					//%a_encoder_count = %a_encoder_count + 1;
				//else
					//%a_encoder_count = %a_encoder_count - 1;
				//break;

			//case ( 2 ):
				//if ( %a_encoder_mask == 3 )
					//%a_encoder_count = %a_encoder_count + 1;
				//else
					//%a_encoder_count = %a_encoder_count - 1;
				//break;
		}
every time the encoder passes a dent it increments 4 times to avoid this behavior I have made the last 3 cases look like comments, now with every dent it increments 1 time ore decrements 1 time.
Problem Fixed.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times

Re: Rotary Encoder not working as aspected help? (Solved)

Post by Enamul »

Hi,
I didn't get time to see till now..

When I open again..you already solved the problem. That's great :D

Enamul
Enamul
University of Nottingham
enamul4mm@gmail.com

Post Reply