5 Replies Latest reply on Jun 22, 2012 1:18 PM by yibing_dong

    How does the Simulator update ARC voltage,current, and resistance?


      I am trying to modify the QuickStart diode model to be a proper diode.


      Currently the diode model calculates a resistance based on a rated wattage and nominal voltage (much how the lamp model should of been).  The default values result in a set resistance of 28.8 ohms.


      This will result in a voltage drop of 28.8 Volts when 1 amp of current is running through the diode.

      Any EE can tell you that the standard diode will have a voltage drop of around 0.7 Volts regardless of the current.


      Therefore I have attempted to modify the diodes component model to recalculate the resistance every time the current changes in order to force the voltage drop to be constant (rather than the resistance).


      Below is the code I have implemented to change the resistance on ARC1.I.hasChanged()



           current %= math.abs(ARC1.getActualCurrent());


           if ARC1.isActive()


                resistance %= (voltageDrop / current);





      voltageDrop is set to 0.7 by default.

      While the code appears sound I have run into a most unusual problem while testing my diode.

      I have found that kirchoffs law does not hold true in VeSys.  V does NOT equal I*R



      While tracking the ARC1 properties I see that

      ARC1.V = 1.454

      ARC1.I  = 0.042

      ARC1.R = 16.599


      ARC1.V should be equal to 0.7 Volts.  It seems that my code properly updates the ARC resistance, which in turn causes the current to change.  However, the voltage does not update.



      Is it possible to force the Simulator to update the SPICE calculations?

      Is there a better way to build a proper diode model?



      Any help would be greatly appreciated.


        • 1. Re: How does the Simulator update ARC voltage,current, and resistance?



          In your model, you have mixed behaviors:

          1. *.isActive() is for LC analysis

          2. fro the numerical analysis, you should make the the voltagedrop between two node equal to your target


          float v := p..getActualVoltage() - n..getActualVoltage();
          float voltageDrop := 0.7;

          if ((math.abs(v) - voltageDrop) > 0) then


             // change the arc resistance to match that




          In general, analysis model using SAINT performs parameter change (resistance here) to reach the target (v = 0.7 here).


          Please let me know if this helps.


          Yibing Dong

          • 2. Re: How does the Simulator update ARC voltage,current, and resistance?

            Hello Dr. Yibing Dong,


            I have updated my code.  Now the updates are part of a function which is called each time ARC1.I.hasChanged() is triggered.

            I have noticed that in this code the while loop will do one of two things.

                 1) the while loop will never execute since resistance is equal to zero making voltage equal to 0.

                 2) the while loop will execute 10 times changing the resistance once while the voltage and current will never update/change.


            Again the issue seems to be related to the SPICE engine not running with the changed resistance.

            I have examined my circuit closely and noticed that all values are calculated with SPICE and updated.  Then once the design schematic is done updating Nodes and Arcs my code manually changes the resistance of ARC1.  The new resistance is never put back through and the changes do not cascade through the schematic.


            You mentioned that SAINT is used to change parameters.  From what I have seen only ARC resistances can be changed through SAINT.  Voltage and current can not be changed, nor can the electrical properties of a Node.  Is this correct?





            function int updateSimulation()



            voltage %= math.abs(ARC1.getActualVoltage());

            current %= math.abs(ARC1.getActualCurrent());


            int loop;

            loop %= 0;


               while ( (voltage - voltageDrop) > 0.0 )


                 loop %= loop +1;

                 current %= math.abs(ARC1.getActualCurrent());

                 if current != 0.0


                      resistance %= (voltageDrop / current);




            if loop >= 10

            then break;






            I have attached the component model that I am using for my diode.


            Thank you for your help,


            • 3. Re: How does the Simulator update ARC voltage,current, and resistance?



              It would be very hard to model a diode behavior using SAINT due to the way of SAINT works. Your are right on the SAINT language that it can only modify the ARC resistance during the simulation and analysis run. Capital Analysis uses the SPICE simulator to run the simulation and adjust the model parameters if needed for another run.


              So, for the diode modeling, the behavior would be:

              If (voltage < voltageDrop) then the diode is off and diode resistance will be very large.


              Otherwise, the voltage = voltageDrop.




              By adjusting ARC resistance to get the voltage = voltageDrop is very difficult by SAINT model.


              I modified your model a little bit. Please let me see if this is good enough for you. Otherwise, you have to use the SPICE diode model




              1 of 1 people found this helpful
              • 4. Re: How does the Simulator update ARC voltage,current, and resistance?

                Thank you for the response,


                The Analysis model you have supplied me seems to be acceptable.  In most scenarios the model will come within 10% of the voltage drop.


                However, there is a race condition that exists.  By simply switching between a onResistance and offResistance, only TWO states are possible.  In some cases the simulation will simply keep switching between on and off Resistances.

                I have included a loop counter to force the simulation to stop in this case.


                I am not sure why changing the diodes resistance to 0.0 will cause the voltage across the diode to approach the voltage drop (in this case 0.7).  It seems to me that a resistance of 0.0 should always result in a voltage drop of 0.0


                I wonder if instead of switching between onResistance (0.0) and offResistance (10000000) if incrementing or decrementing the resistance in steps would be more accurate.



                Thanks again for your support,

                I will let you know if I come up with anything else.



                • 5. Re: How does the Simulator update ARC voltage,current, and resistance?



                  You are right about the behavior of the model I sent to you. I also tried the method you mentioned at bottom of your email.


                  There could be a lot of discussions and I do not think the communities is the right place. Do you want to discuss it  directly to my email :yibing_dong@mentor.com?