View Single Post
  #4   Spotlight this post!  
Unread 09-12-2004, 16:04
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,810
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: encoder vs. motor

Quote:
Originally Posted by stephenthe1
can you look at this and tell me if you see any errors.

Code:
	//the encoder is at 50 resolution
	//the arm motor is attatched to pwm_02
	//the encoder is attatched to rc_dig_in06
	unsigned int encoder;
	if (p2_sw_trig == 1)
	pwm_02 = 220;
	if (rc_dig_in06 == 1)
	encoder = encoder + 1;
	if (encoder == 11)
	pwm_02 = 128;
Couple of problems, such as,
"encoder" needs to be static or a global, so it retains it's value from call to call.
The check on rc_dig_in06 will increment "encoder" more often than every "tick"
"encoder" might shoot right past 11 and keep going.

But first what model encoder are you using?
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle