thiagoralves wrote:
First, you need to make sure that there is an instance and a task associated with your new program for it to run. Just go to Config0->Res0 on the left panel to see the instances and tasks window. You will see that there is one task created for the hello world program that runs every 50ms. You will need to create another task similar to that one for your new program. Also, you will need to create an instance that associates the task with the program.
About the variable conflict, having two different programs to work with the same variable is tricky. They can go into a racing condition which is a big problem in computer programs, so beware. The right way to do this is to setup a global variable. You setup global variables in the same screen you setup the tasks and instances (Config0->Res0). The first upper portion of the window is for you to create your global variables. Create your global variable by clicking on the green plus sign ("+"). Then, for each program that you want to use that variable, just add a variable with the same name and select External for the Class. Make sure that the type also matches your global variable otherwise you will get a type mismatch error during compilation.
I can see a racing condition happening on your example. For the first cycle, one program is trying to setup %QX0.0 to false and the other is trying to set it up to true. Since you can't have both at the same time, you will see %QX0.0 oscillating between false and true.
Hi, thiagoralves. Thanks for your quick and patient reply. How hard-working man you are!
I've tried to add instance and task for the program I created. I do that by means of imitating Helloworld project. However, the redefinition error remains. I don't know whether I did that wrong. My project is attached below. I will keep trying.
As for the race problem, thanks for your kind and patient remind. I will set some FLAGs to ensure that two programs won't be executed at the same time(please forget the example project I posted. It's just an example.).
Thanks for your patient reply again!
test2Programs.xml.zip