SimCoder C block: how to add path to the "search path" tab (PSIM 2023.3)
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:
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!
Answers
-
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".
There are examples for using the SimCoder C block. Please click "File >> Search Examples" and type "SimCoder C Block" in the "Find" space.
0 -
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.
Thank you
0 -
0
-
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”.
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”)
Fig 2: Simulation file from Test 1.
Considering this folder structure in the path “C:\temp\forum\test_1”:
Fig 3: Simulation folder for Test 1.
And setting the “C block include path” to “C:\temp\forum\test_1\src”.
Fig 4: Source code folder for the Test 1.
I’m getting the following error:
<strong>“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”</strong>
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.
Fig 6: Folder structure of the simulation for the Test 2.
Fig 7: Result plot of the simulation Test 2.
Am I missing something?
Thank you!
0 -
Hi, Andre,
Please note which tab in the C block are those lines:
0 -
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.
The includes are placed in the "Header file" tab:
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!
0 -
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".
1 -
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.
0