Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited

Best Way To Keep A Script Running?

I have a script that I want to run none stop. What is the best way to do this?


ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

AI Support Bot
Related Content
Synthiam
United Kingdom
#1  

Code:

:start
# Script here
Sleep(100)
Goto(start)


Adjust the sleep as required but it's always an idea to have a slight delay to avoid resource hogging.
#2  
I prefer using the repeatuntil command for continuously running loops....
#3  
Rich, I thought the goto would only work in an IF statement.

Richard R, I'm having trouble working with repeatuntil.
United Kingdom
#4  
Labels and Gotos work anywhere.
#5  
Basic loop

Code:


$x=0
repeatuntil(0) #repeats without a condition forever
print($x)
$x++
sleep(250)
endrepeatuntil



Code:


$x=0
repeatuntil($x=100) #repeatuntil with a condition 100 times
print($x)
$x++
sleep(250)
endrepeatuntil
PRO
Synthiam
#6  
I would recommend using Goto instead of RepeatUntil(0) because the Goto will use 1 less cpu instruction than RepeatUntil(0). That means a goto is a teeny bit faster:)
#7  
Thanks guys. I'm slowly learning this. Its hard to learn easy things when all the Arduino and other things I'm use to using are much more comp0licated. I seem to be overthinking things a bit.

Thanks for all the help.:)
#8  
@DJ, that's good to know. For some reason I thought the repeatuntil would be way faster and more efficient than the old goto loop. Sounds like they are not much different in terms of resources. Maybe the repeatuntil is just a little more neater to look at. I guess it depends on who you are.
United Kingdom
#9  
Each have their own pros and cons. Personally I prefer Labels and Gotos as I feel a RepeatUntil should always have an end (hence the until). But as Dave said, it depends who you are and how you think.

It also depends on the script. There are some instances where a repeatuntil may not work correctly or require additional labels and gotos anyway where it could render the repeat redundant.