Go to Post Robot teams will expand to fill the available space. - topgun [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-01-2008, 16:38
Sunny Sunny is offline
Registered User
no team
 
Join Date: Jan 2008
Location: New Jersey
Posts: 3
Sunny is an unknown quantity at this point
Autonomous mode does not work

Hello I am a new programmer to FRC and having problems getting Autonomous mode to work. This is the code.

Quote:
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(digital_io_01==1)
{
if(pwm01==127) //Full Forward
{

pwm01=254;
pwm02=254;
}
}
if(digital_io_02==1)//Full Left
{
if(pwm01==127)
{

pwm01=0;
pwm02=254;
}
}
if(digital_io_03==1)
{
if(pwm01==127) // Full Right
{

pwm01=254;
pwm02=0;
}
}





Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
I think it should work but when we push the buttons on the remote only the ir board leds goes on and no pwm outputs. Also i tried just setting pwm01 and pwm02 to 254 without any ir inputs and the motors did nothing. The pwm cables are all plugged in properly and they work in RC mode. Any suggestions

Last edited by Sunny : 15-01-2008 at 16:45.
  #2   Spotlight this post!  
Unread 15-01-2008, 16:48
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Autonomous mode does not work

Autonomous mode has to be enable for autonomous code to work. You need to buy this device to test autonomous code

http://andymark.biz/am-0016.html
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #3   Spotlight this post!  
Unread 15-01-2008, 16:52
Sunny Sunny is offline
Registered User
no team
 
Join Date: Jan 2008
Location: New Jersey
Posts: 3
Sunny is an unknown quantity at this point
Re: Autonomous mode does not work

We already made the dongle for it. And the controller says it is in autonomous mode.
  #4   Spotlight this post!  
Unread 15-01-2008, 19:15
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Autonomous mode does not work

Quote:
Originally Posted by Sunny View Post
Hello I am a new programmer to FRC and having problems getting Autonomous mode to work. This is the code.
My guess is that you're trying to read digital_io_xx variables, which aren't the inputs.

These should be rc_dig_in_xx variables instead.
  #5   Spotlight this post!  
Unread 15-01-2008, 22:58
divergentdave divergentdave is offline
Registered User
FRC #1816 (Green Machine)
 
Join Date: Jun 2006
Rookie Year: 2007
Location: MN
Posts: 35
divergentdave is a jewel in the roughdivergentdave is a jewel in the roughdivergentdave is a jewel in the rough
Send a message via AIM to divergentdave
Re: Autonomous mode does not work

Quote:
Originally Posted by kaszeta View Post
My guess is that you're trying to read digital_io_xx variables, which aren't the inputs.

These should be rc_dig_in_xx variables instead.
Yes, this is correct. The digital_io_## variables just control whether a given port is to be used as an input or as an output. So, in your initialization, you'll want to set
Code:
digital_io_1 = digital_io_2 = digital_io_3 = digital_io_4 = INPUT;
Then, later, your if statements should read
Code:
if (rc_dig_in01)
__________________
Team 1816 - The Green Machine
  #6   Spotlight this post!  
Unread 15-01-2008, 23:03
Sunny Sunny is offline
Registered User
no team
 
Join Date: Jan 2008
Location: New Jersey
Posts: 3
Sunny is an unknown quantity at this point
Re: Autonomous mode does not work

I changed the variables to what you said but it does not compile then. It gives this error
Quote:
C:\Documents and Settings\Sunny Parikh\My Documents\Computer Programming\frc-code-2007-8722\FrcCode_2007_8722\user_routines_fast.c:114:Er ror [1105] symbol 'rc_dig_in_01' has not been defined
Besides I dont think that this is the problem. When i set my pwmxx to full forward without a if statement before it the motors did not work at all. I know for sure it is autonomous mode because of a printf statement I put in that is printing on the computer screen. The the pwm cables are plugged in correctly. I keep racking my head for a solution but i cant think of anything. Its probably something i did that was really stupid and cant figure out.
  #7   Spotlight this post!  
Unread 16-01-2008, 04:18
JohnC's Avatar
JohnC JohnC is offline
my other name is nigel
FRC #0360 (360 Revolution)
Team Role: Programmer
 
Join Date: Mar 2005
Rookie Year: 2005
Location: user_routines.c
Posts: 100
JohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the rough
Send a message via AIM to JohnC
Re: Autonomous mode does not work

It's "rc_dig_in##" not "rc_dig_in_##" - no final underscore.

Also, why are you checking the value of pwm01? It seems like it would make more sense just to use:
Code:
if(rc_dig_in01) {
  pwm01 = 254;
  pwm02 = 254;
} else if(rc_dig_in02) {
  pwm01 = 0;
  pwm02 = 254;
} else if(rc_dig_in03) {
  pwm01 = 254;
  pwm02 = 0;
} else {
  pwm01 = 127;
  pwm02 = 127;
}
__________________
What place are we at? ... TODAI!
  #8   Spotlight this post!  
Unread 16-01-2008, 07:34
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Autonomous mode does not work

With the current setup you have, the PWM outputs will only change if the output is already neutral--127. You want to pull these statements out, because once you have sent a command, the outputs will no longer be neutral--no longer 127.

Also, you do need to use rc_dig_in01 for digital input 1.

Let me know if you need more help.
__________________
Aren't signatures a bit outdated?
  #9   Spotlight this post!  
Unread 16-01-2008, 15:27
Vanquish Vanquish is offline
Registered User
no team
 
Join Date: Jan 2008
Rookie Year: 1980
Location: Somewhere
Posts: 19
Vanquish is an unknown quantity at this point
Re: Autonomous mode does not work

Quote:
while(rc_dig_in01)
{
if(pwm01==127)
{
pwm01=254;
pwm02=254;
}
else
{
pwm01=127;
pwm02=127;
}
}
/*
if(rc_dig_in02)
{

if(pwm01==127)
{
pwm01=0;
pwm02=254;
}
else
{
pwm01=127;
pwm02=127;
}

}
if(rc_dig_in03)
{

if(pwm01==127)
{
pwm01=254;
pwm02=0;
}
else
{
pwm01=127;
pwm02=127;
}

}

*/
When we uncomment the rest of this code we get a program error, an the program light on the RC turns red and nothing works. Any ideas?

p.s. i work with sunny
  #10   Spotlight this post!  
Unread 16-01-2008, 15:31
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Autonomous mode does not work

Quote:
Originally Posted by Vanquish View Post
When we uncomment the rest of this code we get a program error, an the program light on the RC turns red and nothing works. Any ideas?
The while() is your problem. The value of rc_dig_in01 doesn't change between one execution of the while() loop and the next, so this loop either does nothing, or runs forever and you get the red-light-of-death.
Closed Thread


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
Arcade Mode (12) does NOT work jakk Programming 2 10-07-2006 19:27
Camera does not search in autonomous mode after reset Keith Watson Programming 17 07-03-2006 00:42
How does disabled mode work? gnirts Programming 5 13-02-2006 11:47
Anyone get Autonomous mode to work? Larry Barello Control System 4 13-01-2004 15:15
Chaos theory does not work!!!!! S9ar7acu3 General Forum 3 09-02-2003 11:46


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

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