Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

C-script cannot be loaded in rt box

0 votes
431 views
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?.
asked Sep 24, 2021 by efrain ibaceta (38 points)

1 Answer

0 votes

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

answered Sep 24, 2021 by Bryan Lieblick (1,853 points)
...