View Single Post
  #1   Spotlight this post!  
Unread 14-02-2009, 18:47
cvxdes cvxdes is offline
Registered User
FRC #0061
 
Join Date: Feb 2009
Location: Milford MA
Posts: 7
cvxdes is an unknown quantity at this point
Storing a variable outside of a loop

We're trying to work on our acceleration algorithm. At first we were going to go with the accelerometer, but the thing is actually a lot more unpredictable than we thought, so we now want to use just a straight line for acceleration, something like y=mx+b. Only problem is, we can't seem to figure out how to store the previous y, since y will become b the next time around the loop. I know how to do this in php, but I have NO idea about LabVIEW.

Since what I just said could be kinda confusing, here's how I would have coded it if robots could run php:
PHP Code:
<?
$override 
false// This would become true if the pilot presses a button, for taking turns or suddenly going in reverse to brake. 
$current_speed 0;
$wants_to_go 1;
$acceleration 0.05;
while(
true){
    if(!
$override){
        while(
$current_speed <= $wants_to_go){
            
$current_speed $current_speed $acceleration;
        }
    }else{
        
$current_speed $wants_to_go;
    }
}
?>
Reply With Quote