Help needed with Ngspice d_process usage

Hi,
I have been using Kicad for board design for quite a few years and now I am interested in full system level simulations using the capabilities of ngspice. I have made really good progress using some of the Xspice code models. I have, however not been very succesful using the d_process code model. I have followed the ISOTEL example of the motor control but when I call the motorforce_ngut.exe file, I get the message:
Message: ERROR: d_process failed to spawn.
Error: ngspice.dll cannot recover and awaits to be detached

My subcircuit looks like this:


.subckt DPROCESS_BLOCK d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 clk reset w0 w1 w2 w3 w4 w5 w6 w7
Acontrol [d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11] clk reset [w0 w1 w2 w3 w4 w5 w6 w7] firmware
.model firmware d_process (process_file=“motorforce_ngut.exe”)
.ends

I am using Kicad 8.0.4 on Windows 11 Pro. I compiled the C files from the ISOTEL motor control project using GCC 7.4.0 If anyone can share some pointers, it will be greatly appreciated. And even better if a simpler example can be provided. The ISOTEL project is amazing but there is a lot to digest and quite possible I have not fully understood how to use d_process. Thank you very much.

I have no experience with Xspice (and this probably won’t make a difference) but I would encourage you to update to the latest stable version of KiCad, currently v8.0.7, in case the simulation behavior has been improved in the bug fix releases over the past few months. Again, no idea if it will actually make a difference, sorry.

Check my model of a buck converter here for a complete Kicad d_process example: Easier mixed mode simulation (and real world comparison!) - #4 by slh . It was originally based on the Isotel model by @uros.

There’s a good chance that you’ve run into a problem I found when I shared my first version ( Mixed mode simulation including C code and verilog ). Ngspice doesn’t get given the working directory properly so it doesn’t know where to look for the executable. My models have a change directory (cd) command in the ngspice control block on the schematic.

If you want to use gdb to debug the controller then check my first link as there’s a minor bug in ngspice in how you name the pipes.

Hello scandey,
Thank you for your response and my apologies for my delayed response. Upgrading the Kicad version was a great suggestion since my installed Kicad version was using an older ngspice version. That however did not quite resolve my issues. But thank you for all the good suggestions.

Hello slh,
Thank you for taking the time to look into this and respond. It does indeed seem that problem you encountered is very similar to mine. I have since then included the “cd into the directory” included in the “.control” section of the kicad schematic. However, I feel the problem is more than that. It probably has something to do with windows operating system and the way it handles pipes. I have not yet tried the d_process but tried the other 2 code models, d_cosim and d_source. Given the success with d_cosim, I am encouraged to try the d_process today on Ubuntu. I am trying bits and pieces to see what works and what does not before trying to put an entire tool flow together. But thank you once again for all the pointers.

Happy to help. I want more people experimenting with d_process so we can get the bugs out of it and produce a decent power electronics modelling tool as well.

I’ll shortly be sharing an even better d_process example model that should be easier for people to pick up and run without knowing too much XSPICE. I’ve hidden some of the complexity in sub circuits.

I think the biggest improvement that I could ask for at the moment is for buses in ngspice/XSPICE as then we could make sub-blocks (eg PWM blocks and ADC blocks)in Kicad and link them together rather than using a text file model. I don’t need it personally as I’m happy to learn ngspice/XSPICE but it would increase the possible user base as tools like PLECS and PSIM don’t need text files.

1 Like