Go to Post The code won't compile if you violate the rules of the programming language...but English is more robust, it seems to work pretty well no matter how we engineering nerds mangle it! - MrForbes [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Spotlight this post!  
Unread 09-12-2004, 16:51
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: how about this code.

Quote:
Originally Posted by stephenthe1
we tried to keep the motor speed down so the encoder will read each tick before the program refreshes. so the motor doesn't "beat" the program before it reads the encoder.

Code:
//the encoder is at 50 resolution
	//the arm motor is attatched to pwm_02
	//the encoder is attatched to rc_dig_in06
	static unsigned int encoder;
	static unsigned int pressedornot;
	if (p1_sw_trig == 1)
               {
	   if (encoder <= 10)
                  {
                   pwm_02 = 150;
                   if (rc_dig_in06  == 1)
                     {
	         encoder = encoder + 1;
	         if (encoder > 10)
                        {
	            pwm_02 = 127;
                        }
                     }
                  }
               }
Stephen,

You can see I attempted to reformat your code to make it more readable. Now you can see how your code nests...

I agree with Mark. I'm not worried about you missing an encoder ping but rather that you will get multiple hits at one ping.

You should consider implementing a state machine. Do you have a mentor on your team (what team are you with anyway?) who can teach you what a state machine is?
__________________
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...
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[OCCRA]: motor brush springs greencactus3 OCCRA Q&A 1 28-09-2004 20:56
Multiple Motors phrontist Motors 12 21-06-2004 23:05
Mounting the drill motor Veselin Kolev Motors 11 26-04-2004 14:27
WHich motor to lift and for arm thoughtful Motors 8 25-02-2004 10:34
Thermal Protection archiver 2000 1 23-06-2002 23:27


All times are GMT -5. The time now is 04:31.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi