Hey.
I implemented a c block that works great. I was wondering if there is any way to use parameters inside the block itself?. Now I feed a parameter as an input to the block.
I know in PSIM that it’s indeed possible.
thanks you.
I see. I’m having trouble with understanding how to work with this syntax. Maybe there is an example of defining a parameter to use inside the block ?
Sorry, maybe I lack basic spice understanding
Here is an example of how you can add a parameter for C++ block.
Remember, whatever you change input, parameter or output, you should re-create the C++ template. So, copy your code, re-create C++ template and paste the code back.
Thank you KSKelvin. Very helpful, as always.
Looking forward to the update which eases the process of regenerating the template, maybe done in a different file so the code definition does not have to change, feels like 90s
If you’re careful, you can modify the C-block for new or deleted inputs, outputs and input parameters by hand.
I do it all the time.
You do have to know the order of the inputs first as they appear on the C-block symbol. Then the input parameters then the outputs.
You can even change the order of these elements on symbol.
Give it a try. It beats reloading a new template then copying your operation code over to the new template.
Check @RDunn github projects. One of them deals with the issue about updating C-block data structure without generating a new template.
Here’s the link: C-Block Coding Basics - #19 by RDunn
Here’s n Overview of his QCodeGen program:
Yes, you can. But heed this: Even after writing the QCodeGen tool, I screw up when changing stuff manually. Most recently, I spent a couple of hours chasing down an error. I had changed the port data type in the code but not in schematic. Doh!
The QCodeGen tool has several templates. One of these generates only the component port/attribute-specific stuff. Using this template, it’s easy to regenerate only the necessary code to copy/paste. Now, if I can only discipline myself to always use it…
If you do change things manually, it’s a good idea to look at the netlist to verify the parameters. In particular, QSpice will silently ignore certain malformed port/attribute data. (QCodeGen attempts to warn of these potential problems.)
–robert
robert,
Thank you for your comments and your efforts creating a new tool to aid in making C-blocks easier to use.
You are correct as I indicated that “careful” editing is needed to manually make changes.
Len