Go to Post There are always going to be tough calls, and you just have to trust in your officials to do the right thing. - Jeff Waegelin [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
  #11   Spotlight this post!  
Unread 30-03-2004, 23:21
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: More automonous help:ending stuff

Try this. In user_routines_fast.c replace the User_Autonomous_Code function with the function below. It's not a state machine, but it incorporates elements that you probably understand better.

All: Please check this for bugs!

Code:
void User_Autonomous_Code( void )
{
  static unsigned int Old_Clock = 0;

  static unsigned int time = 0;  // cycle counter
  
  while (autonomous_mode)
  {
    if (statusflag.NEW_SPI_DATA)
    {
      Getdata(&rxdata);   // bad things will happen if you move or delete this
      
      // Autonomous code goes here.
      
      if (Clock > Old_Clock) // stay synchronized to beacon data updates (this is important)
      {
        /////////////////////// CUSTOM CODE /////////////////////////
        if ( time < 456 )  // still less than 12 seconds have elapsed
        {

          // LINE FOLLOWING
          // there are 3 bits which means 8 combinations.  
          // only 4 are tested here. ??
          if (rc_dig_in01 == 0 && rc_dig_in02 == 0 && rc_dig_in03 == 0)
          {
            pwm13 = 127;  // stop
            pwm15 = 127;
          }
          else if (rc_dig_in01 == 0 && rc_dig_in02 == 0 && rc_dig_in03 == 1)
          {
            pwm13 = 139;  // turn one way
            pwm15 = 175;
          }
          else if (rc_dig_in01 == 1 && rc_dig_in02 == 0 && rc_dig_in03 == 0)
          {
            pwm13 = 175;  // turn the other way
            pwm15 = 139;
          }
          else if (rc_dig_in01 == 0 && rc_dig_in02 == 1 && rc_dig_in03 == 0)
          {
            pwm13 = 249;  // go straight and fast
            pwm15 = 249;
          } 
          
        }
        else if ( time < 532 )  // 12 seconds have gone by, but less than 14
        {
          // stop wheels
          pwm13 = 127;
          pwm15 = 127;
          
          // raise arm
          pwm03 = 175; 
        }
        else  // more than 14 seconds have gone by
        {
          // stop raising arm
          pwm03 = 127; 
        }
        
        time++;  //  count another cycle

        /////////////////////// END OF CUSTOM CODE /////////////////////////
        
        Old_Clock = Clock; // take a snapshot of the clock
        
      } // clock > oldclock
      
      Generate_Pwms( pwm13, pwm14, pwm15, pwm16 );
      
      Putdata(&txdata);   // even more bad things will happen if you mess with this
      
    } //  statusflag.NEW_SPI_DATA
  }  // while (auotnomous) 
}
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
 


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
Please - stop posting needless stuff! Andy Baker Announcements 0 13-01-2004 09:13
Free stuff at FIRST Not2B General Forum 7 30-09-2003 21:23
What does everyone like to do besides FIRST stuff?? Katie_269 Chit-Chat 45 17-07-2002 17:01
who can we buy stuff from?!?! archiver 2001 7 23-06-2002 23:04
How much robotics stuff is on your resumes??? Robby O Career 14 03-08-2001 19:51


All times are GMT -5. The time now is 02:07.

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