View Single Post
  #5   Spotlight this post!  
Unread 22-09-2005, 02:38
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Array problems( i think....)

You need to place code like the following somewhere that it gets called every time through the 26 millisecond control loop so your joystick values will be updated.

static unsigned char i = 0;

if ((pw_sw_trig1 == 1) && (i < 90))
{
left_side[i] = p1_y;
right_side[i] = p2_y;
i++;

pwm01 = pwm02 = 127;
} // end if

Note that the counter is a static variable so it holds its value between passes through the loop.

Also, you increment the counter before you use is so aside from your other problems, you'd never fill in the first item in each array. Remember C arrays start at 0. If pwm01 and pwm02 aren't being changed somewhere else in your code, you don't need to set them each pass through the loop. Or if you're, recording actual motor performance, then you don't need to keep setting them to 127.

Hope this helps.