Replies: 2 comments 2 replies
-
Hi! Thanks for the message, always good to have some feedback :-) Happy to see it is suiting your needs (for the most part). And nice use-case by the way 👍 This is the kind of stuff I was thinking of when building Spice#. If you have things you would like to see differently, feel free to post something on the Spice# issue page. The documentation having changing parameters mid-simulation can indeed use some more work. I originally added it as one of the use cases, but I didn't have much feedback on it so it didn't get more attention as Spice# got updated. Documentation is also very time-consuming for me so hard to keep updated. Having some kind of additional invalid input checking does make sense to me. This will become a noted issue for the core Spice# package, and I expect it will be part of the upcoming Spice# v3.1. But first I need to work on the new C# source generator which will be very useful for making custom components as well. Cheers! |
Beta Was this translation helpful? Give feedback.
-
First Draft to get main gist across: Basics of Using SpiceSharp for Hardware/Software in the Loop TestingSee This Page for the basics of modifying components mid simulation. Here is the basic flow for this kind of simulation: The important take-away here is that Also, the data from a timestep is only real once it is in the Example code to get DC Voltage Source Component Handle in Example code to modify the DC Voltage Source in I'd like to provide a fully working example here, but because of restrictions on what I can upload, it'll take some approval to append that. This anyway is what I would have found most useful when learning and implementing a system. |
Beta Was this translation helpful? Give feedback.
-
Hey Folks!
TLDR: I'm planning to write a more detailed tutorial for mid-simulation circuit updates. Also, I'm wondering if it makes sense to add basic Invalid Input checking on things like DcValue's for Voltage Sources. Also, SpiceSharp/Behavioral is fantastic.
I've been working with SpiceSharp and SpiceSharpBehavioral for a couple months now with great results!
I'm simulating pretty intense circuits with many orders of magnitude in them that professional grade spice programs struggle with sometimes, and I haven't had a REAL issue yet.
The basic use case for what I'm doing is simulating hardware that doesn't yet exist, and then seeing how a control algorithm reacts to that simulated hardware. So, mid-simulation, the control hardware/software is polled for an updated set of control signals, and then these new signals are injected into the simulation using voltage sources by setting their "DcValue" in the "BeforeLoad" callback.
Along the way I had many issues, though! Most were from not understanding how spicesharp worked, or just having bugs I didn't quite know how to trace down.
I think a more extensive tutorial on doing mid-simulation updates to components would help one of these issues, and I think a little more error checking could help the other.
The tutorial would be one I'd be happy to write since it's born from my total ignorance of how spice simulations work. So it'd be written for dummies like me. So, that's going on my TODO list.
The error checking though I'm unsure about... the principle issue I ran into was that I was setting a Voltage Source DC value to a NaN (divide by 0 error). The error I got though was very generic though. I feel like software should be smart enough to identify when the USER screws up his/her input as compared to the simulation actually having an issue. (The usual, "invalid input" sort of error)
I'm really happy about this tool, and I'm sure I haven't even realized what its full potential is. It's making a big impact in how software is developed and tested.
Beta Was this translation helpful? Give feedback.
All reactions