C-script cannot be loaded in rt box

gretings. I have an RT box CE and I want to charge the following block made by 2xC-scripts. Nevertheless, the following error appears. How could I fix it in order to charge successfully this model in RT BOX?.

NLC.plecs (21.7 KB)

Efrain,

The short answer to get your model to compile is to declare variables you are initializing in your Code Declarations (tabla, counter) as “static”.

I am going to copy a relevant comment from another discussion here on the forum that explains the behavior you’ve observed.

""When running a simulation in PLECS, every C script always has a private symbol space.

However, when the code is generated and compiled. The code of each C script is written into a .c file, which is then linked to the main .c file. If the same global, non-static variable then appears in multiple C-Script files, there is a link error.

The solution is to declare the variables as static, using the “static” prefix before all variables in the “Code declarations” tab. Then you can include multiple copies of the same C-Script within the model without generating an error when compiling for the RT Box. You’ll notice this is the convention used in most C-Scripts included in demo models and the PLECS library.“”

Regards,

Bryan