Note: Running simultaneous script utility functions

In regards to 599_Competition_Scripting_Template:

Suppose you want to combine two script steps into one and run them simultaneously.       Here is a sample script that moves a distance and has a 2 second timeout in case the move doesn’t finish.

void Script_name_1()

case 1:

int done1= Move_dist_ch1(300, 50); //command a rate of pwm 50 and move to dist1 = 300
int done2=Ms_timer_T1(2000) ;  // waits 2 seconds before done

done = (done1>0  ||  done2>0) ; //  Sets done = 1 when either done1 or done2 is completed else o.



done = (done1>0 || done2>0)  is equivalent to the following  if test and is easier.
if(done1>0 || done2>0)
{done = 1;}
{done = 0;}

We had trouble with this method in the past because we did not set done = 0 as the default.  This was normally set to zero by the  utility function  returning a zero.  E.g.  done = Move_dist_ch1(..) .

Changing this to done1 = Move_dist_ch1(..)  did not reset done = 0 so we have make sure to use the above coding.


One Response to Note: Running simultaneous script utility functions

  1. I really enjoyed the navigational experience. As I have already been searching across the internet, I can see
    that I need to utilize something apart from Tumblr.
    Thanks a lot for the attention opening experience

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: