Export PCB board to OpenEMS?


#1

Hello all,

Recently I’ve discovered OpenEMS and I would like to use it to simulate some RF board that I’ve created using Kicad. But seems that there are a big hole between those tools.

Perhaps the way to go would be to create a python script that reads the .kicad_pcb file and generates a octave/mathlab .m file for OpenEMS ?

Anyone had some experience doing that ?

thanks


#2

Hi @chrishawk

I don’t have experience with generating an .m file but I do have experience with reading and manipulating KiCAD PCB files in C++. The PCB file format is based on S-expressions and simple to parse. You could also do this in Python.

An alternative route would be to generate a Hyperlynx ASCII file and import that using hyp2mat. Although I couldn’t find a specification for the Hyperlynx file format, a couple of projects use it so I expect the information is out there somewhere.

Regards,
Niels.


#3

My colleague showed me this tool recently, seems pretty handy for simulations :slight_smile:
I found Eagles implementation here: https://github.com/plusea/EAGLE/blob/master/ulp/hyperlynx.ulp
Perhaps it could be ported to kicad and python? Even cooler would be an addition kinda like the NGspice engine, but that probably way out in the future (and more minded on the devs list)


#4

The FOSS layout editor pcb-rnd can load a kicad layout and can export a layout in hyperlynx format, allowing a Kicad user to get to hyperlynx format.

The hyperlynx export code was written by the same guy who wrote hyp2mat.

pcb-rnd can be also invoked as a headless cli utility, allowing scripted or batch conversion with the right command line flags, so there wouldn’t be too much preventing a pretty seamless solution.

Alternatively, you could look at the hyperlynx export code

http://igor2.repo.hu/cgi-bin/minisvn.cgi?cmd=browse&repo=pcb-rnd&path=trunk/src_plugins/io_hyp

to help in rolling your own implementation.

Regards,

Erich.


#5

thanks @erichVK5 for the info…
OpenEMS is a great tool and it would be very nice to have a Kicad integration…

do you know which is the license for this exporter?

EDIT it is GPL 3 :smiley:


#6

Hi. I’ve written small software to convert KiCAD PCB files to use in openEMS.
It converts PCB file to Octave/Matlab function file that can be used directly with openEMS
structures. Additional feature is it can generate automatic mesh lines for PCB
geometry. There are some other functions, but all is not documented completely.

Here is the link to project: pcbmodelgen


#7

that is awesome!!
Ill have a look at it in the upcoming days :slight_smile:
do you think this could be added to the Export menu inside PCBnew?


#8

Probably it could be done, but my program needs configuration file, at least for
some of the functions. Now you must pass JSON configuration with it.
There are many options that are not PCB related, but more for FDTD.

For example, you can set if copper layers are simulated as real material with
thickness or zero thickness polygon (one mesh line) .


#9

Hmm could be a extremely nice addition :slight_smile:
And welcome to the forums, some first entry!


#10

very nice though!
What do you use to build it?
Do you think it would be possible to port it to python to avoid the compiling?


#11

Build is with cmake. It should be very straight forward.
Only few command lines.

Porting probably would be very much work. It depends on TinyXML2 and a lot of C++ STL.
Also minor Boost usage.


#12

@jcyrax
You are on Linux aren’t you?
On win it would be more difficult :wink:


#13

Yes I’m using Linux :slight_smile:
Maybe I’ll create binary for windows, if I have time.


#14

I suppose the settings could go in a dialog with an export button :slight_smile:


#15

I’m trying to build it on MSYS2 chain (the one from KiCad winbuilder)
I could install both:
TinyXML2 and TCLAP
I also made the config to complete
cd pcbmodelgen
cmake -G "MinGW Makefiles" -DTINYXML2_INCLUDE_DIR==../../../../../../mingw64/mingw32/include/ -DTINYXML2_LIBRARY=../../../../../../mingw32/lib -DTCLAP_INCLUDE_DIR=../tclap-1.2.1/include
but the command make just fails…
@jcyrax would you give me a tip?
Thx


#16

@maui I think you need to run cmake in new build directory that is not project directory.
Create directory build and from there run:
cmake [all parameters] …/

If it doesn’t work, please include what output do you get from running make.


#17

@jcyrax
tried to create a build dir and run the command… still the same error…
here the Makefile created, with the CMakeLists.txt slightly modified
Makefile.zip (5.8 KB)


#18

@maui can you post the error text here?


#19

@jcyrax
here the log and errors
CMakeOutput-log.zip (4.9 KB)


#20

@maui I made some changes in code and CMakeLists.txt it may be the fix, but not sure.
Tried, also, to compile on Win, but my MinGW has some bug with c++11 support.
Hope this helps.