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.

Can multiple inputs be put into a C-Script?

0 votes
61 views
I wanted to know how a C-script can have multiple inputs for it. For example, I have a few output signals a,b,c that I want to be inputted into the C-Script constantly like a function, but the current C-Script box only has 1 input channel and 1 output channel. Is there any way to change this so it takes in multiple different signals instead of me having to use a multiplexer/demux that would cause the signals to not be the original ones that I want them to be. Essentially, I want the C-Script block in PLECS to be able to take in more than 1 input channel. Is this possible and how would I approach it?
asked Apr 7 by Dev Singhania (12 points)

1 Answer

+1 vote

The C-Script block accepts multiple, vectorized inputs.  You can set the "Number of inputs" field as a vector which will specify the width of each input.  Within the C-Script you can access the desired input signal using the "InputSignal(int i, int j)" macro, where the first argument is the input signal and the second argument the j'th  element of the i'th input signal (zero indexed). In the screenshot below InputSignal(2, 1) would return 4.

A similar indexing approach is applied to output signals as well.

answered Apr 7 by Bryan Lieblick (1,035 points)
...