Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help creating circuit simulation software

  1. Aug 13, 2004 #1
    I am creating a circuit building simulation using multimedia software 'Flash'.

    Basically the user is presented with a circuit board onto which they can drag components such as batteries, resistors, bulbs, ammeters, voltmeters, switches, and of course lengths of wire.

    I have been reading up on ohms law and kirchoffs law and whilst I understand the principles, I am not sure how to go about resolving the values for the voltage and current at any point on the circuit.

    I think I need to work this out based on the entire circuit that the user has built.

    What I would like is to know the order of steps to resolve a circuit. The circuit board will have 5 pegs across and 4 down. So the user basically drops the elements (e.g bulbs) in between the pegs to create their custom circuit.

    I have a feeling that some seriously difficult maths and physics may be involved like simultaneous equations and matrixes?

    If there are any physics experts out there, the more detail you can give me about solving this, the better!

    Many thanks in advance

  2. jcsd
  3. Aug 13, 2004 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    In the completely general case, you will have a linear equation in 20 unknowns, the voltage at each of the 20 pegs on the board.

    You generate the 20 equations to solve for the 20 unknowns by applying Kirchoff's current law at each peg

    You'll have to decide what to do about wires - will they have a truly infinite conductance, or a finite conductance?
  4. Aug 14, 2004 #3


    User Avatar
    Staff Emeritus
    Science Advisor

    I had a few more thoughts about the best way to tackle this, but it may be an ambitious project.

    The first step is to go through and to number or otherwise label all the "nodes" in the circuit. Any two "pegs" connected by wires should be given the same "node" number. You'll probably want to flag any "dangling" nodes with only one connection for special treatment. Unused pegs don't get a node number.

    After this, you start generating equations. A battery connected between two different nodes will set the voltage difference between them. A battery with both terminals conneted to the same node is an error. You'll have to think about how you go about flagging this error to the user.

    You'll need to set one node in the circuit as the "ground" or reference node, with a potential of zero. You might label one peg on your circuit "ground", you'll have to think about how the ground node is determined. What if the user doesn't connect anything to the ground node, for instance?

    A node that does not connect to a battery in any way whatsoever will have its voltage determined by Kirchoff's current law. The current to a neighboring node will be the voltage difference divided by the resistance. Sum and set to zero. Nodes connected to a battery won't generate any Kirchoff's current law eq's because whatever current is needed will come from the battery.

    You'll probably want to give voltmeters a finite but large resistance (10 megohms is probably good), in case some joker puts two voltmeters in series with a battery to see what happens.

    You'll probably want to give switches a small but finite "on" resistance. What happens if someone shorts out a battery with a switch?

    It may or may not be desirable to give ammeters a finite resistance.

    You'll need someway to solve all the equations once you generate them (probably a linear matrix package, elimination to tri-diagonal form).
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook