VHDL-AMS and Switch Hysteresis

Visiting with customers, particularly in a first or second visit when we’re introducing the benefits and features of SystemVision, is always quite interesting and usually enlightening. Many of these first discussions end with the customer asking the inevitable question: “Can you take one of our existing circuits and simulate it in SystemVision?” If we’re visiting with electronics designers, this usually means entering a SPICE-level circuit in SystemVision then running the design through its paces. But with the many versions of SPICE available, from the full-featured commercial packages to the freebie home-grown versions, we frequently face “model not available” problems. So what do we do? Fortunately, and as I’ve mentioned in earlier blog posts, SystemVision supports the IEEE standard VHDL-AMS modeling language.

Using VHDL-AMS it’s possible to model a variety of device behaviors. As an example, earlier this week I worked on a customer circuit trying to figure out how to add a bit of hysteresis to the operation of a SPICE-level voltage controlled switch model. The SystemVision model library has a voltage controlled switch model, but it doesn’t include hysteresis. Rather than invent a new switch from scratch, I simply took the source code for this switch and added a new architecture.

There are, of course, a variety of ways to model hysteresis, ranging from basic functionality to quite complex. For the project at hand, I only needed basic functionality. Here is the new architecture I added to the existing switch model (note that text preceded by double-dashes “- -“ are comments):

    architecture hysteresis of vc_switch is
 
        -- Define the switch resistance and initialize it to Roff which means
        -- the switch is normally off.
        quantity r_switch : RESISTANCE := Roff;
 
        -- Define the input and output voltages
        quantity v_in across in_p to in_n;
        quantity v_out across i_out through out_p to out_n;
 
    begin
 
        -- Check to see if v_in exceeds the threshold voltage.
        -- If so, set the switch resistance to the ON value.
        if v_in'above(Vt + Vh) use
            r_switch == Ron;
 
        -- Check to see if v_in drops below the threshold voltage.
        -- If so, set the switch resistance to the OFF value.
        elsif not v_in'above(Vt - Vh) use
            r_switch == Roff;
 
        -- If v_in is between the upper and lower hysteresis values,
        -- switch resistance remains unchanged.
        else
            r_switch == r_switch;
 
        end use;
 
        -- Force the analog solver to take extra sample points at
        -- threshold crossings.
        break on v_in'above(Vt + Vh), v_in'above(Vt - Vh);
 
        -- Use Ohm’s law to calculate the switch’s output voltage.
        v_out == i_out*r_switch
 
    end architecture hysteresis;

 To make the switch model as flexible as possible, Ron, Roff, Vt, and Vh are VHDL-AMS generics defined in the model entity (not shown here). A generic is simply a parameter the model user can change to characterize the model’s behavior. Ron and Roff are the on and off resistances for the switch, respectively. Vt is the input voltage threshold level at which switching occurs, and Vh defines the range of switch hysteresis. Increasing Vh reduces the switch’s contact bounce. Here is a brief description of how the switch works:

  • If the input voltage (v_in) is greater than the sum of Vt and Vh (v_in > Vt + Vh), the switch resistance is set to Ron which is typically very small, effectively turning the switch on.
  • If v_in is less than Vt minus Vh (v_in < Vt – Vh), the switch resistance is set to Roff which is typically very large, effectively turning the switch off.
  • If v_in is within Vh of Vt, whether on the high or low side (Vt – Vh <= v_in <= Vt + Vh), the input voltage is in the transition region so the switch resistance remains unchanged.

And that’s all there is to modeling basic voltage controlled switch hysteresis using VHDL-AMS. With the architecture defined, it’s a simple matter to create the model entity to support the architecture. As with any simulation model, the key is understanding how the device functions. The rest is simply describing the function using VHDL-AMS syntax.

What would you add to make the switch hysteresis more realistic?

Post Author

Posted June 16th, 2010, by

Post Tags

, ,

Post Comments

No Comments

About Mike Jensen's Blog

Views, insights, and commentary on mechatronic system design and analysis. Mike Jensen's Blog

Comments

Add Your Comment

Archives

June 2014
  • Wow Factor
  • May 2014
  • SystemVision 5.10.3
  • March 2014
  • IESF 2014: Military & Aerospace
  • Engineering Oops!
  • Big Engineering
  • January 2014
  • SystemVision Model Wizard
  • December 2013
  • SystemVision 5.10.2
  • Modeling: An Engineer’s Dilemma
  • October 2013
  • What is Your Legacy?
  • September 2013
  • Automotive IESF 2013
  • July 2013
  • Simple Design Solutions
  • June 2013
  • SystemVision 5.10
  • May 2013
  • Engineering Muscle Memory
  • EDA vs. Windows 8
  • March 2013
  • VHDL-AMS Stress Modeling – Part 3
  • January 2013
  • VHDL-AMS Stress Modeling – Part 2
  • VHDL-AMS Stress Modeling – Part 1
  • December 2012
  • Practice! Practice!
  • November 2012
  • Sharing Tool Expertise
  • October 2012
  • Preserving Expertise
  • Virtual Prototyping — Really?
  • Innovations in Motion Control Design
  • September 2012
  • Game Changers
  • Do We Overdesign?
  • August 2012
  • Tsunami Remnants
  • July 2012
  • A New Look at Device Modeling
  • SystemVision 5.9
  • June 2012
  • Veyron Physics
  • May 2012
  • Rooster Tail Engineering
  • April 2012
  • Automotive IESF 2012
  • Teaching and Learning CAN Bus
  • March 2012
  • Analog Modeling – Part 6
  • Analog Modeling – Part 5
  • Analog Modeling – Part 4
  • February 2012
  • Analog Modeling – Part 3
  • Analog Modeling – Part 2
  • January 2012
  • Analog Modeling – Part 1
  • Connecting Tools and Processes
  • December 2011
  • Turning-Off and Tuning-In
  • Use vs. Experience
  • Analyzing the Big Picture
  • November 2011
  • Simulating for Reliability
  • October 2011
  • SystemVision 5.8
  • VHDL-AMS Model Portability — Fact or Fiction?
  • September 2011
  • IESF 2011 Moves to Frankfurt
  • Simulation Troubleshooting
  • August 2011
  • Qualities of VHDL-AMS Quantities
  • Military & Aerospace IESF 2011
  • Touring Johnson Space Center
  • July 2011
  • Engineering versus Science
  • June 2011
  • System Reengineering
  • May 2011
  • Integrating Hardware and Software Design
  • Engine Remote Start
  • Integrated System Design
  • Simulation Experiments (Part 3)
  • April 2011
  • Automotive IESF 2011
  • Pushbutton Cars
  • System Simulation with FEA-Base Motor Models
  • March 2011
  • Simulation Experiments (Part 2)
  • Simulation Experiments (Part 1)
  • Japan: Patience and Grace Amid Disaster
  • Top Gear = Driving Fun
  • February 2011
  • Buoyancy
  • Ideas in Motion
  • January 2011
  • The Mechanical Half of Mechatronics
  • Detroit Auto Show
  • Signal-flow vs Conserved System Modeling
  • SystemVision 5.7…Ready, Set, Go!
  • December 2010
  • SystemVision and Windows 7
  • Friction Vacation
  • Simulation Beyond Volts and Amps (Part 4)
  • November 2010
  • Simulation Beyond Volts and Amps (Part 3)
  • Simulation Beyond Volts and Amps (Part 2)
  • Simulation Beyond Volts and Amps (Part 1)
  • October 2010
  • SAE Convergence Recap (and an Unexpected Surprise)
  • VHDL-AMS Black Belt
  • Converging on SAE Convergence
  • System Design vs System Repair
  • September 2010
  • What’s the “AMS” in VHDL-AMS?
  • How Sensitive is Your System?
  • Do You Trust Your Simulator?
  • August 2010
  • What’s in a SPICE Model?
  • Cycling + Gravity = Pain
  • NI Week: Fun for Engineers
  • June 2010
  • Are You a Flexible Thinker?
  • VHDL-AMS and Switch Hysteresis
  • May 2010
  • VHDL-AMS Revisited
  • Segway to U3-X
  • Atomic Glue
  • March 2010
  • IESF Recap
  • February 2010
  • IESF is Coming…
  • System Level HDL-topia
  • January 2010
  • Mastering Design Abstraction
  • The Joy of Disassembly