Local Variables

I’ve been holding off upgrading to the 3.60 firmware due to the lack of updating local variables. However I’ve been facing constant issue of disconnection between the robot and the controller. When it happens it seems that the robot continuously inputs the final command leaving the robot to break its own motors and axles.

So if possible can someone please help me rewrite me program to allow it to work the same way w/ the new firmware.

void FBdrive(int speed,float milimeters)
{
float threshold = 0.2, pre_enc = 100;
float enc = ((milimeters/(3.14*101.6)*1000));
while(true)
{

float avg_enc = abs(nMotorEncoder[BRdrive] + nMotorEncoder[BLdrive]/2);
if ( abs(pre_enc - avg_enc) > abs(speed*threshold))
{
if(abs(avg_enc) < enc - dead)
{
pre_move(speed,speed,speed,speed);
wait(0.1); pre_enc = avg_enc;
}
else
{stay();break;reset_enc();}
}
else
{stay();break;reset_enc();}
}
}

i know there are a lot of redundancies but the program worked well for previous competitions using 3.08 firmware.
The basic idea of the program is to run till the desired distance unless interruption occurs at that point if the value doesn’t update then the function cancels and motors don’t burn out. If anyone can find a fix it would be appreciated.

You should not need to rewrite your program.

http://www.robotc.net/blog/2012/10/24/robotc-3-5-global-vs-local-variables-and-the-debugger/

Ah, you mean pre-local vs. global variables ROBOTC. Didn’t realize that. In that case, there is a setting under View -> Preferences -> Global/Local Variable Setting . Choose “Force ‘Classic’ - All Variables as Globals”

You don’t have to worry about global vs. local variables anymore.

https://taypga.bn1.livefilestore.com/y1pVBXlXn-92Rb07yLcS9uoJUXCK-liHqA7YP3yF3zhFuMOCHmm68An2oO1XLWnhJXvSxPNslQUhG0/Force%20Disable%20Local%20Variables%20ROBOTC%20copy.png

I ******* love you. Honestly I’ve been at this for several days now and you just fixed my program. Hats off to you and if you need any help don’t be afraid to come by 1973D. This account however is another teams that I borrowed to post since my account it new

Haha, no problem