0
\$\begingroup\$

I want to simulate a software driven PWM. So, I need to program the controller output based on the transient/instantaneous feedback from some part of the circuit in the simulation (i.e. the software logic must run as part of the simulation).

In other words, I basically want to have as simulation input an arbitrary function of the circuit properties itself.

For instance, imagine a PIC controlling a MOSFET, and the output from PIC depends on its analog input from some other part of the circuit. What tools can I use to simulate such circuit? I don't want to simulate the PIC itself, I just want some way to control some digital input signal depending on the instantaneous properties of the simulated circuit.

\$\endgroup\$
5
  • \$\begingroup\$ Can the dependency be modelled with some discrete parts? \$\endgroup\$
    – Eugene Sh.
    Aug 17, 2015 at 20:56
  • \$\begingroup\$ In theory, yes, because digital circuitry are turing complete, but it can be impractical for complex functions, so I wanted some tool that allowed me to code it in software. \$\endgroup\$
    – lvella
    Aug 17, 2015 at 20:59
  • \$\begingroup\$ So my question was how complex it would be and perhaps it can be simplified for the simulation purposes? Otherwise the tools that might exist are rather expensive. Just googled and found this for example. Not sure how good it is.. \$\endgroup\$
    – Eugene Sh.
    Aug 17, 2015 at 21:03
  • \$\begingroup\$ I'm not sure what you mean by software-driven PWM. Are you talking about simulating a bit-banged PWM signal, or simulating a software-controlled varying duty cycle signal such as is found in many control systems? The former makes no sense and the latter is straight-forward. \$\endgroup\$ Aug 18, 2015 at 2:45
  • \$\begingroup\$ I guess I am talking about simulating a bit-banged PWM signal... why it makes no sense? \$\endgroup\$
    – lvella
    Aug 18, 2015 at 4:27

1 Answer 1

1
\$\begingroup\$

Sorry, but it is not very clear what are your requirements.

Anyway, Multisim, which is available for free from National Instruments with some sort of student license, is also a SPICE simulator and among its models has a PIC simulation engine, i.e. you can enter PIC assembly code. I never used it myself, but I knew a couple of people that said it is decent. YMMV

But you say you don't need to simulate the PIC, so maybe you could use LTspice, it is a free professional SPICE simulator. It supports behavioral voltage sources, i.e. sources whose output is modeled by mathematical functions. Excerpts from its help file:

B. Arbitrary Behavioral Voltage or Current Sources Symbol names: BV, BI

Syntax: Bnnn n001 n002 V= [ic=]
+ [tripdv=] [tripdt=]
+ [laplace= [window=]
+ [nfft=] [mtol=]]

...

Tripdv and tripdt control step rejection. If the voltage across a source changes by more than tripdv volts in tripdt seconds, that simulation time step is rejected.

Expressions can contain the following:

o Node voltages, e.g., V(n001)

o Node voltage differences, e.g., V(n001, n002)

o Circuit element currents; for example, I(S1), the current through switch S1 or Ib(Q1), the base current of Q1. However, it is assumed that the circuit element current is varying quasi-statically, that is, there is no instantaneous feedback between the current through the referenced device and the behavioral source output. Similarly, any ac component of such a device current is assumed to be zero in a small signal linear .AC analysis.

o The keyword, "time" meaning the current time in the simulation.

o The keyword, "pi" meaning 3.14159265358979323846.

o The following functions:

...

And then lists a lot of functions and operators. Refer to the guide for more details or this very complete LT WIKI page.

You can even specify the source behavior using Laplace transforms.

Maybe it can be useful for you: you can enter the schematic of your analog part and model the interactions using behavioral sources.

\$\endgroup\$
1
  • \$\begingroup\$ Yes, I believe what I wanted was these "behavioral sources". Thanks. \$\endgroup\$
    – lvella
    Aug 17, 2015 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.