Thread: encoders
View Single Post
  #1   Spotlight this post!  
Unread 12-01-2005, 15:07
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Question encoders

I'm posting this in hope that someone who has actually registered on this site will post something. there are so many people viewing this, but not posting anything. with that said, I thought this would be a nice place for people to discuss encoders. of course, my main motivation is that these things have been my killing me over the past month. I have tried numerous things, and I can never seem to get it to work. Coding, for the most part, I don't think is a problem. I'm using 2004's code written by Mr. Watson that supports encoders and interrupts. I have everything configured, the only thing that could possible be keeping the encoder from working is my code in User_Routines_Fast.c
what the code does is this, when the third joystick is pushed forward, the arm on last year's robot goes up untill the encoder has "clicked" 12 times. then the motor on the arm is set to neutral. it's as simple as that. (for testing purposes).

Code:
	static long lec = 0;            //lec = encoder count
	lec = lec + Get_Left_Encoder_Count();     //add previous count
      //plus the new count
//the static long is supposed to hold the value every loop                                                               
	if (lec >= 12)
	{
	pwm02 = 127;		//set it to neutral
	}
	else
	{
	pwm02 = p3_y;
	}
can you please tell me why this won't work, or if you think it should. please tell me yourself and don't refer me to somewhere. I've spent so much time, and a simple few lines of code would help me to understand this almost completely. (don't forget, Mr. Watson's 2004 encoder code is what I'm using.)

HELP!!!
thanks,
Stephen

Last edited by stephenthe1 : 12-01-2005 at 15:09.