SimCoder C block: how to add path to the "search path" tab (PSIM 2023.3)

Leopoldino
Leopoldino Altair Community Member
edited February 29 in Community Q&A

Hello!

I'm using the "SimCoder C Block" and I'm strugling to use the tab "Search Path" to organize my source code. The help doesn't mention how to use this feature and there is no example in the example path.

- how do I specify a path relativelly to the simulation file path?

I have a folder named "src" in the same path as the simulation file. In this folder I have two files: teste.c and teste.h.

What I tried:

image

Noting that with the source codes in the same path as the simulation file everything works.

Tested within PSIM 2022.3.0.60.

Thank you!

Tagged:

Answers

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited September 2023

    Hi, Andre, 

    It is simple to include your header files and external c files in the SimCoder C block.

    Please use the tabs "Header File" and "External File".

    image

     

    There are examples for using the SimCoder C block. Please click "File >> Search Examples" and type "SimCoder C Block" in the "Find" space.

    image

  • Leopoldino
    Leopoldino Altair Community Member
    edited February 15

    Hello,

    in all listed examples the source codes are in the same folder as the simulation file.

    So none of the listed examples actually uses the tab "search path". In this way my question remains: how to add path to the "search path" tab?

    In other words: how to use source code that is not placed in the same folder/directory as the simulation file? 

     

    These screenshots show examples with the source code in the same directory of the *.psimsch.

    image

     

    image

     

    Thank you

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited February 19

    image

     

    image

  • Leopoldino
    Leopoldino Altair Community Member
    edited February 20

    Hi, thank you for the answer.

     

    But the original question was about the “Search path” option in the SimCoder C Block not about the global PSIM “C block include path”.

    image

    Fig 1: Help file of  the SimCoder C Block.

    ====

    By the way, the simulation still doesn’t work with the procedure that you posted. 

    I made two simulations using copies of the same simulation file and the source code in distinct folders.

     

    Test 1: source code into the /src folder (specified in the “C block include path”)

    image

    Fig 2: Simulation file from Test 1.

    Considering this folder structure in the path “C:\temp\forum\test_1”:

     

    image

    Fig 3: Simulation folder for Test 1.

     

    And setting the “C block include path” to “C:\temp\forum\test_1\src”.

    image

    Fig 4: Source code folder for the Test 1.

     

    I’m getting the following error:

    <strong>&ldquo;Error #5005: The following file specified in SimCoder C Block is not found. Please check it.</strong>

    <strong>C:/temp/forum/test_1/parameters.h&rdquo;</strong>

    image

    Fig 5: Configuration of the "C Block Include Path" and the simulation error.

     

    Test 2: source code into the simulation folder

    Just to show that the code works. No error.

    image

    Fig 6: Folder structure of the simulation for the Test 2.

     

    image

    Fig 7: Result plot of the simulation Test 2.

     

    Am I missing something?

    Thank you!

     

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited February 26

    Hi, Andre,

    Please note which tab in the C block are those lines:

    image

  • Leopoldino
    Leopoldino Altair Community Member
    edited February 26

    Hi Rhonda,

    I think there is a misunderstanding going on.

    In the "Runtime Code" I placed the code that runs each time and not the "includes" statements.

    image

    The includes are placed in the "Header file" tab:

    image 

    As I said in my last post, the simulation runs only if the source codes and headers are placed in the same folder as the psim simulation file (Test 2). And doesn't work when I put the source codes and headers in another folder and make the setup of the "C Block Include Path" configuration (Test 1).

    -----

    For the sake of clarification I share with you both simulations made with the PSIM 2022.3.0.60.

     

    Thank you!

     

     

  • Rhonda_20369
    Rhonda_20369 New Altair Community Member
    edited February 27

    PSIM path is only used in PSIM side, SimCoder doesn't use it.

    SimCoder only uses relative path or absolute path for a file.  

    SimCoder assumes the current directory is the project folder, say "C:\abc\test1(C code)".

    If SimCoder C block's include/source files folder is "C:\abc\src", then user can use relative path ".\src\types.h", or absolute path "c:\abc\src\types.h".

  • Leopoldino
    Leopoldino Altair Community Member
    edited February 29

    Thank you!

    With your last answer I was able to include the source and the header files using relative path and run the simulation sucessfully. But without using the "search path" tab in the SimCoder. I can work with that.

    As suggestion, Altair could create examples in the next version explaining how to use the "search path" in the SimCoder C Block.