• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Real Time Analogue Circuit Simulation C++

Status
Not open for further replies.

NIDALAP

New Member
Hello! I'm wondering how would I go about creating a real time simulation of an analogue circuit in C++? I spent a couple of days searching google, but couldn't find anything. The only thing I've realised in that SPICE seems to be the go to in terms of circuit simulation. Question is, where can I get libraries for it and can it do real time simulation?
 

MikeMl

Well-Known Member
Most Helpful Member
What do you mean by "real time"?
 

NIDALAP

New Member
Well, my understanding is that MATLAB for example, you create a model in simulink, then you specify the duration of the simulation and the result is all the data from t=0 to your specified time limit. This is a passive simulation. You let it run and it does so. What I'm after is a simulation where it's like having the physical circuit in your hands - so you can turn various components on and off, use various components thereby changing their power consumption etc... so basically I want to have a virtual model that you can play with.
 

NIDALAP

New Member
Sounds like I'm not seeing something very obvious. This may sound obtuse, but I didn't find any info related to c++/c etc libraries to use SPICE in my program hence my question.
 

ci139

Active Member
can you be more specific - as it must be obvious - you can not simulate complex/fast/event-dense circuits in real time - what exactly you have to collate from your intended experiment
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Well, my understanding is that MATLAB for example, you create a model in simulink, then you specify the duration of the simulation and the result is all the data from t=0 to your specified time limit. This is a passive simulation. You let it run and it does so. What I'm after is a simulation where it's like having the physical circuit in your hands - so you can turn various components on and off, use various components thereby changing their power consumption etc... so basically I want to have a virtual model that you can play with.
There are numerous programmes that already do exactly what you want - and you don't want 'real time' - as it would be far too fast for you to see any results.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Sounds like I'm not seeing something very obvious. This may sound obtuse, but I didn't find any info related to c++/c etc libraries to use SPICE in my program hence my question.
There will be.. BUT!! If I made a simulator in C++ to do all the stuff you want, I wouldn't post my code.. Proteus uses C++ to run all the spice models in their software.. If you subscribe you are given a C++ skeletal program to design your own models, you have to sign a waver saying that you will not disclose!! But! Yes there are C++ libraries..
 

alec_t

Well-Known Member
Most Helpful Member

crutschow

Well-Known Member
Most Helpful Member
It's not possible to simulate analog circuits in real time, unless it's a simple circuit and you happen to have a super computer at your disposal. :rolleyes:
 

NIDALAP

New Member
Well, I managed to find the SPICE library on the Berkeley website - go figure. Since spice is so old, I didn't even think of going straight to the source but it exists. The rest of your comments are not very endearing :). I'm not sure whether my circuit can be classified as big, so I guess I'll have a poke around and see whether I can get performance that I need out of it. First step is to figure my way around the library and figure out how to use it. That might take some time.
 

ci139

Active Member
that time may be 10-s of years or a few clicks if there's an example avail of similar to what you intend
 

NIDALAP

New Member
A simplified aircraft electrical circuit. By simplified I mean, I'll be approximating instruments by resistors, other than that, all the buses and all the switches need to be there. My biggest concern are the circuit breakers. I have over 300 of them, but they are simple switches so not sure how that's going to affect performance. All I'm doing is probing the circuit at every refresh cycle. I think maximum of 60hz. Whatever the values are is what they are. So having said all that, perhaps it's not as simple as I at first thought.
 

ronsimpson

Well-Known Member
Most Helpful Member
Looks like you want to do this on a "PC".
Search for "PC i/o board". You can get a plugin board that has up to 144 inputs/outputs.
You can also get a USB I/O board. I used one with 32 inputs/outputs.
This can take care of your 300 breakers.
You can also scan the I/O like a keyboard encoder.

Don't know what you are really doing but I think a DAC board will give a voltage output that can drive meters directly. (instruments)
Many of these boards output 0 to 5 volts in 256 steps.

Driving instruments might be hard. You can use a monitor and just put up a "picture" of an instrument and make the meter move in graphics.

I have had some problems with a PC in real time. "60hz" Some times Windows just goes away for a period of time.
 

NIDALAP

New Member
Yep, interfacing the circuit breakers will need some sort of IO board, haven't figure out which one yet.

It's for a flight simulator. Just trying to model the electrical system. Specifically, I was thinking along the lines of trying to figure out how much power consumption the electronics would be drawing for a realistic battery drain. But I think I might simplify and just turn everything off after a certain time limit instead. I think modeling the whole system the way I initially envisaged would be too arduous and the benefits would be marginal.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top