View Single Post
  #1   Spotlight this post!  
Unread 21-09-2005, 21:02
Andrew Blair's Avatar
Andrew Blair Andrew Blair is offline
SAE Formula is FIRST with Gasoline.
FRC #0306 (CRT)
Team Role: Alumni
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Corry
Posts: 1,193
Andrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond repute
Send a message via AIM to Andrew Blair Send a message via Yahoo to Andrew Blair
Array problems( i think....)

I have recently been working on a copy cat program, and am just in the development stages, so right now i'm working on placing array values every program cycle from user input, then just replaying them. Right now i'm just putting the array values to ram (we don't have much code right now, so our ram is pretty much empty), then replaying them. Ultimately I plan to save them to eeprom by pressing a save button.

My problem is that the code compiles fine, but when the copycat is executed, I have no control and it blinks code error *almost* immediately. The way my code is set up, I have about 2 seconds of record time, and it dies about 2 seconds in. (I do intend to scale my code appropiately, so i'll have much more record time than that, but for right now it's fine recording a value every program cycle).


I warn you, what you are about to see is very crude and may shock you with blatent programming errors. I am actually expecting my array to be very screwed up, because i'm still learning how to use them.

Code:
unsigned char left_side[90];    
unsigned char left_side[90];
unsigned char right_side[90];

unsigned int i;


//record device, takes i variable(increases address every program loop), takes value from joystick input.

if (p2_sw_trig==1)
{
   i=0;
   i++;
while( i<90)
{
left_side[i]=p1_y;
right_side[i]=p2_y;
}

if (i<90)
{
  pwm01,pwm02=127;
}

}


//replay device, takes value from table and puts it to pwms

if ( p1_sw_trig==1)

{
i=0;
i++;
while(i<90)
{
pwm01=left_side[i];
pwm02=right_side[i];
}

if(i>90)
{
  pwm01=127;
  pwm02=127;
}

}


Thanks so much in advance! I hope I put that all down right. I just realized I didn't check the main processor anytime in that while loop. Could that my problem?
__________________
Reading makes a full man, conference a ready man, and writing an exact man.
-Sir Francis Bacon

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
-Albert Einstein