Go to Post Dean's "All Denim" (now referred to as "Deanim") look is apparently catching on. - AndyB [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
  #1   Spotlight this post!  
Unread 05-02-2007, 17:30
fallen751 fallen751 is offline
Registered User
FRC #2052
 
Join Date: Jan 2007
Location: Minnesota
Posts: 17
fallen751 is an unknown quantity at this point
Autonomous Mode

I have been coding our autonomous mode, but it seems that everytime I switch into autonomous mode it kills the camera. I was wondering if anyone could tell me if this code would keep the camera from running during autonomous mode.

Code:
void User_Autonomous_Code(void)
{

  /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
     will be stuck with the last values mapped from the joysticks.  Remember, 
     even when Disabled it is reading inputs from the Operator Interface. 
  */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
  relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
  relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
  relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;

  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */

        /* Add your own autonomous code here. */
		if(Get_Tracking_State() == CAMERA_ON_TARGET)
		 {
			
			static char oldpwm01, oldpwm02, oldpwm03, oldpwm04;
			int slowpwm01, slowpwm02, slowpwm03, slowpwm04;

			while (PAN_SERVO > 130) 
				{
					pwm01 = 147;
					pwm02 = 147;
					pwm03 = 147;
					pwm04 = 147;
				}
			while (PAN_SERVO < 124)
				{
					pwm01 = 107;
					pwm02 = 107;
					pwm03 = 107;
					pwm04 = 107;
				}
			while (rackdistance[servotodegrees(TILT_SERVO) * 2] >= 24)
				{
					int prepwm01, prepwm02, prepwm03, prepwm04;

					prepwm01 = prepwm02 = prepwm03 = prepwm03 = 127;

					prepwm01 += 1;
					prepwm02 -= 1;
					prepwm03 += 1;
					prepwm04 -= 1;

					if (prepwm02 > 127 && prepwm02 < 170)
						{
							prepwm02 += 12;
						}

					if (prepwm04 > 127 && prepwm04 < 170)
						{
							prepwm04 += 12;
						}

					pwm01 = prepwm01;
					pwm02 = prepwm02;
					pwm03 = prepwm03;
					pwm04 = prepwm04;

					oldpwm01 = pwm01;
					oldpwm02 = pwm02;
					oldpwm03 = pwm03;
					oldpwm04 = pwm04;
				}

			slowpwm01 = oldpwm01;
			slowpwm02 = oldpwm02;
			slowpwm03 = oldpwm03;
			slowpwm04 = oldpwm04;

			while ((rackdistance[servotodegrees(TILT_SERVO) * 2] < 24) && (rackdistance[servotodegrees(TILT_SERVO) * 2] >= 5))
				{
					slowpwm01 = slowdown(slowpwm01);
					slowpwm02 = slowdown(slowpwm02);
					slowpwm03 = slowdown(slowpwm03);
					slowpwm04 = slowdown(slowpwm04);

					pwm01 = slowpwm01;
					pwm02 = slowpwm02;
					pwm03 = slowpwm03;
					pwm04 = slowpwm04;
				}

			if (rackdistance[servotodegrees(TILT_SERVO) * 2] < 5)
				{
					pwm01 = pwm02 = pwm03 = pwm04 = 127;
				}
		}

	else
		{
			pwm01 = pwm02 = pwm03 = pwm04 = 127;
		}

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}
 


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
Autonomous Mode Slick Programming 22 01-02-2007 19:26
autonomous mode seanl Programming 6 31-01-2007 15:59
Autonomous mode chs938 Programming 1 03-02-2006 10:19
Autonomous Mode David Bryan Programming 1 21-01-2003 21:15
autonomous mode? bigwalt Technical Discussion 1 21-01-2003 01:14


All times are GMT -5. The time now is 20:27.

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