Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/28/04 04:19
Read: times


 
#71374 - RE: Rotary encoder problems
Responding to: ???'s previous message
Thanks very much for the detailed answer. I'll have a look at that for my next project that involves a non-detented encoder. The current project (that I wrote the original code for) is mostly a "test" project...

When I looked at the timing diagram of the encoder I also came up with another idea, and I changed my code to the code below.

void Button(void) interrupt 0	//Extern 2 - INT0
{
IE = 0;

if (BUT2 == 0)	//Encoder
	{
	TH1 = TL1 = 0;	//Reset timeout timer
	TR1 = 1;	//Start timeout timer

	while((BUT2 == 0) && (TH1 < 0xf0));
		//Wait for end of pulse with timeout

	TR1 = 0;	//Stop timeout timer

	if (TH1 < 0xf0)	//No timeout
		{
		if (ENC0 == 0)	//Vol+
			{
			if (vol < 63)
				{
				vol++;
				writespi(1);
				}
			}
		else 	//Vol-
			{
			if (vol > 0)
				{
				vol--;
				writespi(1);
				}
			}
		}
	}


That code seems to work well. I haven't had a single error yet. But I guess the problems wont show up until the encoder get's worn...

Best regards,

Mikkel C. Simonsen


List of 11 messages in thread
TopicAuthorDate
Rotary encoder problems            01/01/70 00:00      
   RE: Rotary encoder problems            01/01/70 00:00      
      RE: Rotary encoder problems            01/01/70 00:00      
   RE: Rotary encoder problems            01/01/70 00:00      
      RE: Rotary encoder problems            01/01/70 00:00      
         RE: Rotary encoder problems            01/01/70 00:00      
            RE: Rotary encoder problems            01/01/70 00:00      
               RE: Rotary encoder problems            01/01/70 00:00      
   RE: Rotary encoder problems            01/01/70 00:00      
      RE: Rotary encoder problems            01/01/70 00:00      
      RE: Rotary encoder problems            01/01/70 00:00      

Back to Subject List