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.

How do we use C Script box?

+1 vote
4,797 views
How are inputs and outputs defined in the code?

Do we need a main function to run it?

Is a do-while loop required to run it forever? or it loops itself as in Arduino.
asked Feb 3, 2018 by Aviral (13 points)

2 Answers

+1 vote
Hello Aviral,

Keep in mind that using the C-Script block is non-trivial and requires some deeper knowledge of PLECS. Try using PLECS blocks to create the required function first.

To start using the C-Script block, have a look at the C-Script chapter in the documentation and try some of the examples.

Best Regards

Falk
answered Feb 5, 2018 by Falk Kyburz (253 points)
+1 vote
It's not too bad to figure out. As Falk said start by reading the documentation and looking at the examples. It took me about a day to go through that and then try some simple scripts. I'm no expert now but I am now able to do state machines (although Plexim provides native support for state machines) and logic blocks in c-script. I'm actually converting some of these from Verilog into C.

I use a trigger so that the c-script is only executed on certain clock edges. It then might do a bunch of If/then/else statements, and updates its outputs, until asked to execute again.

...Roger
answered Feb 14, 2018 by rcolbeck (21 points)
@Roger Need help about C-Script
How can I help?

Late here. Will try to answer tomorrow if you can give me some details.

Roger
I am trying to build MPPT block on C-script, there is no error in code. But still not getting desired duty cycle. Attached is the algorithm i implemented on C-script. Please guide me what changes i need to make.
ok probably best if someone from Plexim could help you but if I will try to find time to look at this, maybe this weekend.

....Roger
Okay thanks. Will contact you soon.
...