Connect with us

side: better simulators?...

Discussion in 'General Electronics Discussion' started by BGB, Apr 30, 2015.

Scroll to continue with content
  1. BGB

    BGB

    154
    11
    Nov 30, 2014
    well, for a while I have been using LTspice, and it basically works, however:
    I would like to be able to run and tweak circuits in real time (or interactive sub-real-time, say, 1000x slower than real-time), and don't like having to manually re-simulate;
    I would like something that doesn't freeze up or take an excessive amount of time if it doesn't like the circuit (general problem with trying to build oscillators in LTspice, they either don't work or they cause the simulator to freeze up);
    would like the ability to also simulate digital logic, or run code in a virtual micro-controller (say, can roughly simulate an ATmega or Cortex-M);
    want it to be downloadable and decently fast, not some extremely laggy web-based thing;
    also, I would like it to keep track of watts dissipation, and maybe indicate when components would overheat (ex: if it says I am running 40A through a TIP120, I suspect the real-world output will diverge, even maybe just slightly), or indicate when wires would be running too much current (say, 100A through a 16 AWG wire);
    aim would be mostly on power-electronics (such as for running electric motors or similar);
    ...

    and, I would want it all to be free.

    I have partly considered if needing trying to write something like this, but haven't gotten to it.
    probably wouldn't use SPICE, but likely a more direct linear iterative approach probably over a fixed time-step (IOW: no integrators). this will trade off accuracy for speed, but mostly try to gain modest accuracy by the use of a relatively small time-step. other parts are likely to be primarily driven by update events.

    considering also laying out components in terms of a logical 0.1" pitch grid, likely with components represented more in terms of logical pins than in terms of schematic symbols. most likely, it would work it terms of update events between adjacent blocks, which would recalculate ohm-law and other things for that moment in time.


    but, not much point if something good already exists...

    (a lot of my UI-based software has been plagued with an issue of terrible UIs, and no one giving a crap, so yeah...).


    also, side notes:
    any thoughts about modifying an old alternator into a BLDC motor (probably for operation at around 1kW);
    or good/cheap MOSFETs or IGBTs for driving an approx 150V 1000A (1kA) inductive load (may also need some good capacitors).

    thoughts?...
     
  2. BobK

    BobK

    7,671
    1,681
    Jan 5, 2010
    I can answer one part of your problem. When using LTSPICE with oscillators you need to go to the "Edit simulation cmd" dialog and check the box "Start external DC supply voltages at 0V" and / or "Skip initial operating solution". These will prevent it from finding a stable solution and get the oscillator going.


    Bob
     
  3. BGB

    BGB

    154
    11
    Nov 30, 2014
    ok. I had tried these before, and the oscillator would typically start going a little bit, but then usually stall out (say, I only get the initial rise of the waveform, and the simulation never completes).

    I had wandered off and came back, but it is still stuck at that point.

    I had looked around before, and fiddled with some options for the integrator, but it didn't seem to make any difference.

    typically, this was with resistor+capacitor+transistor oscillator or multivibrator designs.

    granted, I may have been missing something, and there may be an option somewhere to prevent it from freezing up.



    otherwise, may start doing some art and coding something up for a simulator, and see how far I get with it.

    partly uncertain if it should use a single-layer grid, or have a pair of grids representing the front and back of a piece of perfboard (probably with components on the front, and wires/traces on the back). some of this effects how grid cells should work and may influence how wires can be run.

    yeah, as-noted, it would probably be board-oriented, rather than schematic-oriented.
     
  4. BobK

    BobK

    7,671
    1,681
    Jan 5, 2010
    Hmm. I have always been able to get it to work with oscillator circuits. Perhaps the circuit really does behave that way, have your tried it on circuits that actually work when built?

    Bob
     
  5. BGB

    BGB

    154
    11
    Nov 30, 2014
    I don't think "LTspice freezes up" is normal circuit behavior (because... reality doesn't just freeze up).

    a lot of times, either one of:
    LTspice shows it as steady-state, but the real-life circuit oscillates (this has happened with some of my current-limiter attempts);
    it is an oscillator IRL, but LTspice stalls or freezes when it starts to oscillate in the simulation.

    if the simulation stalls, and one hits the "halt" command, a lot of time, the LTspice user interface may also freeze up (requiring manually killing it in Task Manager or similar).

    could be it doesn't really like my computers, both of which run Windows 7, one using an AMD K-10, and another using a "Pentium Dual Core".

    but, I don't really know...
     
  6. Arouse1973

    Arouse1973 Adam

    5,164
    1,079
    Dec 18, 2013
    Can you post the circuit so we can have a go.
    Adam
     
  7. BGB

    BGB

    154
    11
    Nov 30, 2014
    contents of a simple ".asc" file (dunno ATM how to attach files on here...).

    didn't have a prior circuit on-hand (one I could send was on my laptop, didn't feel like pulling it out and starting it up), but threw one together which still proves problematic.

    however, it seems after an update earlier, LTspice no longer freezes up, rather the simulation dies with an error message (more or less, "timestep too small, timestep=1.25e-019").

    ADD: just noticed, forgot the ground this time. adding the ground, however, makes it just go to a steady state.

    Code:
    Version 4
    SHEET 1 880 680
    WIRE 64 -112 -96 -112
    WIRE 160 -112 64 -112
    WIRE 256 -112 160 -112
    WIRE 352 -112 256 -112
    WIRE 64 -80 64 -112
    WIRE 160 -80 160 -112
    WIRE 256 -80 256 -112
    WIRE 352 -80 352 -112
    WIRE 64 16 64 0
    WIRE 128 16 64 16
    WIRE 256 16 256 0
    WIRE 256 16 192 16
    WIRE 64 32 64 16
    WIRE 256 32 256 16
    WIRE 128 64 128 16
    WIRE 224 64 128 64
    WIRE 160 96 160 0
    WIRE 160 96 64 96
    WIRE 352 96 352 0
    WIRE 352 96 256 96
    WIRE 192 112 192 16
    WIRE 192 112 64 112
    WIRE -96 128 -96 -112
    WIRE 160 128 160 96
    WIRE 352 128 352 96
    WIRE 64 176 64 112
    WIRE 96 176 64 176
    WIRE 224 176 224 64
    WIRE 288 176 224 176
    WIRE 160 272 160 224
    WIRE 256 272 160 272
    WIRE 352 272 352 224
    WIRE 352 272 256 272
    WIRE -96 336 -96 208
    WIRE 256 336 256 272
    WIRE 256 336 -96 336
    SYMBOL npn 96 128 R0
    SYMATTR InstName Q1
    SYMBOL npn 288 128 R0
    SYMATTR InstName Q2
    SYMBOL res 336 -96 R0
    SYMATTR InstName R1
    SYMATTR Value 1000
    SYMBOL res 240 -96 R0
    SYMATTR InstName R2
    SYMATTR Value 50000
    SYMBOL res 144 -96 R0
    SYMATTR InstName R3
    SYMATTR Value 1000
    SYMBOL res 48 -96 R0
    SYMATTR InstName R4
    SYMATTR Value 50000
    SYMBOL voltage -96 112 R0
    WINDOW 123 0 0 Left 2
    WINDOW 39 0 0 Left 2
    SYMATTR InstName V1
    SYMATTR Value 12
    SYMBOL cap 240 32 R0
    SYMATTR InstName C1
    SYMATTR Value 0.000022
    SYMBOL cap 48 32 R0
    SYMATTR InstName C2
    SYMATTR Value 0.000022
    TEXT -130 342 Left 2 !.tran 0.1 startup uic
    

    ADD 2: here is a version which does seem to recreate the "stall" effect:

    Code:
    Version 4
    SHEET 1 880 680
    WIRE 64 -112 -96 -112
    WIRE 160 -112 64 -112
    WIRE 256 -112 160 -112
    WIRE 352 -112 256 -112
    WIRE 64 -80 64 -112
    WIRE 160 -80 160 -112
    WIRE 256 -80 256 -112
    WIRE 352 -80 352 -112
    WIRE 64 16 64 0
    WIRE 128 16 64 16
    WIRE 256 16 256 0
    WIRE 256 16 192 16
    WIRE 64 32 64 16
    WIRE 256 32 256 16
    WIRE 128 64 128 16
    WIRE 224 64 128 64
    WIRE 160 96 160 0
    WIRE 160 96 64 96
    WIRE 352 96 352 0
    WIRE 352 96 256 96
    WIRE 192 112 192 16
    WIRE 192 112 64 112
    WIRE -96 128 -96 -112
    WIRE 160 128 160 96
    WIRE 352 128 352 96
    WIRE 64 176 64 112
    WIRE 96 176 64 176
    WIRE 224 176 224 64
    WIRE 288 176 224 176
    WIRE 160 272 160 224
    WIRE 256 272 160 272
    WIRE 352 272 352 224
    WIRE 352 272 256 272
    WIRE -96 336 -96 208
    WIRE 128 336 -96 336
    WIRE 256 336 256 272
    WIRE 256 336 128 336
    WIRE 128 384 128 336
    FLAG 128 384 0
    SYMBOL npn 96 128 R0
    SYMATTR InstName Q1
    SYMBOL npn 288 128 R0
    SYMATTR InstName Q2
    SYMBOL res 336 -96 R0
    SYMATTR InstName R1
    SYMATTR Value 1000
    SYMBOL res 240 -96 R0
    SYMATTR InstName R2
    SYMATTR Value 5000
    SYMBOL res 144 -96 R0
    SYMATTR InstName R3
    SYMATTR Value 1000
    SYMBOL res 48 -96 R0
    SYMATTR InstName R4
    SYMATTR Value 5000
    SYMBOL voltage -96 112 R0
    WINDOW 123 0 0 Left 2
    WINDOW 39 0 0 Left 2
    SYMATTR InstName V1
    SYMATTR Value 12
    SYMBOL cap 240 32 R0
    SYMATTR InstName C1
    SYMATTR Value 0.000022
    SYMBOL cap 48 32 R0
    SYMATTR InstName C2
    SYMATTR Value 0.000022
    TEXT -130 342 Left 2 !.tran 0.1 startup uic
    
    ADD 4: ok, seems it actually does work, just it requires wandering off and doing something else for a while (ex: takes about 20 minutes or so).
     
    Last edited: May 1, 2015
  8. BGB

    BGB

    154
    11
    Nov 30, 2014
    ADD:
    spent part of last night writing a simulator, and thus far it basically simulates wires (so, it is possible to effectively short between a voltage source and ground, and get crazy high amperage readings...).

    may get back to working on it, and adding support for some components (such as resistors and transistors).


    but, otherwise, got ahold of an old alternator and spent a while converting it into a motor (and cleaning it up, as it was pretty old and rusty and filled with gunk from laying around outside for probably years...). when I got it, it was basically seized up due to rust (but, internally wasn't in as bad of condition as I had worried, and got it for free from a relatives' yard, save the possible cost of partly breaking my sink due to a piece of the alternator falling off and hitting it). but, got it free-spinning pretty good now, and the coils still work, and in basic tests seems to behave as expected as a motor.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-