View Single Post
  #6   Spotlight this post!  
Unread 09-12-2004, 16:05
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts 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;
Stephen,

A good start.

First of all, you have not initialized your counter (maybe this is done in your actual code... I don't know).

Second, what happens the next time through the loop? I'm assuming that you will want to perform this maneuver again and again (once again, I may be mistaken). For now, I will assume that this is a one shot deal...

Here is what I think will happen: When the encoder hits 11, the arm is turned off but the encoder micro-switch is still "closed". The count will increase to 12 and the arm will continue to travel. You might want the last test to be "encoder > 11"...

Does this make sense to you?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...