App Notes

Here you will find out latest app notes.

Including Relays in PSpice Simulations

Category: 
Application Notes
Language: 
English

In this application note, we will discuss two approaches for modeling the relay: the mechanical model approach, and two purely electrical (behavioral) models approach. 

  • The Mechanical Model Approach
  • The Electrical (Behavioral) Model Approach

    • Model of a Relay (without Contact Bounce)
    • Model of a Relay (with Contact Bounce)

The Mechanical Model Approach

The mechanical model for the relay is modeling the mechanical part of electromechanical devices in general, using the relay as an example. This model constructs an electrical analogy to the mechanical operation of the relay. To do this, it calculates the magnetic and mechanical forces acting on the contact arm of the relay, and simulates the acceleration, velocity, and position of the arm in response to these forces. The electrical contacts of the relay are simulated by switches controlled by the position of the contact arm. There are two problems with this modeling approach: first it requires information about the physical construction of the relay (spring force, contact arm moment, magnetic permeance as a function of contact arm position) that is not normally available to the user of a relay, and second, it takes a lot of computer time to simulate the exact position of the contact arm. Most of this time is wasted if all the user needs to know is whether the contacts are open or closed. This type of physical model could be useful for designing a relay, but it is overkill for simulating its electrical behavior.

 

The Electrical(Behavioral) Model Approach

The second and third approaches simply model the electrical behavior of the relay coil and contacts. Rather than requiring physical construction parameters, these models require behavioral parameters.

 

Model of a Relay(without Contact Bounce)


The first behavioral model does not include contact bounce, and is the fastest to simulate. It requires parameters for coil inductance and resistance, contact resistance, pull-in and dropout coil currents, and make and break times. The model uses a PSpice digital buffer's propagation time to model the make and break times, and uses the Analog to Digital conversion device to model the pull-in/dropout current hysteresis. It uses a Digital to Analog conversion device in an unusual configuration to model the contacts. By using the digital devices, it is easy to set the delays using sub-circuit parameters, and there are no time step problems that can be caused by very high gain analog switches. The following circuit file shows the simple behavioral model of a relay (without contact bounce). 

* End of RELAY_SPDT_BHV_BOUNCE model
* Behavioral model of a relay. (No contact bounce)
.subckt RELAY_SPDT_BHV coila coilb no nc com
+ PARAMS:
+ T_make = 20mSec ; Time for contact to close when current is turned off/on
+ T_break= 10mSec ; Time for contact to open when current is turned off/on
+ I_pull = 35ma ; Pull-in current
+ I_drop = 25ma ; Drop-out current
+ R_coil = 100 ; Coil resistance
+ L_coil = 5mH ; Coil inductance

+ R_open = 100MEG ; open circuit contact resistance
+ R_close= .05 ; closed circuit contact resistance
* electrical model of coil
v_winding coila a1 0
r_winding a1 a2 {R_coil}
l_winding a2 coilb {L_coil}
* make a voltage from the current
e_cc cc 0 value = {limit(I(v_winding),-3*I_pull,3*I_pull)}
r_cc cc 0 1k
* use digital to create a switch with hysteresis
o_mag cc 0 relay_1 DGTLNET=d digio_1
* by using min/max delay we can use a single N-device to simulate both
* the no and nc contacts.
u_dly buf dpwr dgnd d cnt relay_2 digio_1 MNTYMXDLY=4
n_cnt com no nc relay_3 DGTLNET=cnt digio_1
.model relay_1 doutput (
+ s0name="0" s0vlo={-I_pull} s0vhi={I_pull}
+ s1name="1" s1vlo={I_drop} s1vhi={4*I_pull}
+ s2name="1" s2vlo={-4*I_pull} s2vhi={-I_drop}
+ timestep={T_make/1000}
+ )
.model relay_2 ugate (
+ tplhmn={T_break} tphlmn={T_break}
+ tplhmx={T_make} tphlmx={T_make}
+ )
.model relay_3 dinput (
+ s0name="0" s0tsw={T_make/1000} s0rlo={R_open} s0rhi={R_close}
+ s1name="1" s1tsw={T_make/1000} s1rlo={R_close} s1rhi={R_open}
+ s2name="R" s2tsw={T_make/1000} s2rlo={R_open} s2rhi={R_open}
+ s3name="F" s3tsw={T_make/1000} s3rlo={R_open} s3rhi={R_open}
+ s4name="X" s4tsw={T_make/1000} s4rlo={R_open} s4rhi={R_open} 
+ s5name="Z" s5tsw={T_make/1000} s5rlo={R_open} s5rhi={R_open}
+ )
.model digio_1 uio
.ends
* End of RELAY_SPDT_BHV model

 

Model of a Relay(with Contact Bounce)

In some systems the previous model is too simple, since it does not include contact bounce. This model includes contact bounce for a specified period of time after the contacts close. The contact bounce is created by taking a digital contact close signal and converting it to an analog ramp using a Digital to Analog conversion device. The analog ramp forms the input to a table-controlled voltage source. The table creates a bounce output voltage which is then converted to digital to square it up. The digital value is used to control another Digital to Analog conversion device which models the contacts.

Note: Contact bounce is caused by the physical bouncing of the electrical contacts as they close. It looks electrically as if the relay contacts close and open several times in quick succession before they remain closed.

 

* End of RELAY_DPDT_BHV model
* Behavioral model of a relay with contact bounce.
.subckt RELAY_SPDT_BHV_BOUNCE coila coilb no nc com
+ PARAMS:

+ T_make = 20mSec ; Time for contact to close when current is turned off/on
+ T_break= 10mSec ; Time for contact to open when current is turned off/on
+ T_bounce=5mSec ; bounce time (after T_make)
+ I_pull = 35ma ; Pull-in current
+ I_drop = 25ma ; Drop-out current
+ R_coil = 100 ; Coil resistance
+ L_coil = 5mH ; Coil inductance
+ R_open = 100MEG ; open circuit contact resistance
+ R_close= .05 ; closed circuit contact resistance
* electrical model of coil
v_winding coila a1 0
r_winding a1 a2 {R_coil}
l_winding a2 coilb {L_coil}
* make a voltage from the current
e_cc cc 0 value = {limit(I(v_winding),-3*I_pull,3*I_pull)}
r_cc cc 0 1k
* use digital to create a switch with hysteresis
o_mag cc 0 relay_1 DGTLNET=d digio_1
u_dly buf dpwr dgnd d cn_no relay_2 digio_1
u_inv inv dpwr dgnd d cn_nc relay_2 digio_1
* model contact bounce with subckt
x_no cn_no com no RELAY_CONTACT_BOUNCE
+ PARAMS:
+ T_make = {T_make}
+ T_break= {T_break}
+ T_bounce= {T_bounce}
+ R_open = {R_open}
+ R_close= {R_close}
x_nc cn_nc com nc RELAY_CONTACT_BOUNCE
+ PARAMS:
+ T_make = {T_make}
+ T_break= {T_break}
+ T_bounce= {T_bounce}
+ R_open = {R_open}
+ R_close= {R_close}
.model relay_1 doutput (
+ s0name="0" s0vlo={-I_pull} s0vhi={I_pull}
+ s1name="1" s1vlo={I_drop} s1vhi={4*I_pull}
+ s2name="1" s2vlo={-4*I_pull} s2vhi={-I_drop}
+ timestep={T_make/1000}
+ )
.model relay_2 ugate (
+ tphlmn={T_break} tphlmx={T_break}
+ tplhmn={T_make-0.126*T_bounce} tplhmx={T_make-0.126*T_bounce}
+ )
.model digio_1 uio
.ends

 

PSpice simulation using each of the Relay's Model

Following is an example of using each of the relay model for PSpice simulation: 

 

IncldgRlysPSpcMdlng_Fig1.png

                        Figure 1: Relay Model Circuit

 

Figure 2 shows the results of the PSpice simulation of the Relay Model circuit.

 

IncldgRlysPSpcMdlng_Fig2.png

                                Figure 2: Output from Relay Model Circuit

 

Figure 2 shows a Probe plot of the input current, and the output voltages of each of the relay model from each circuit.

Note: Circuits with physical relay model may take longer time to simulate in comparison to circuits without physical model.

 

 

© Copyright 2016 Cadence Design Systems, Inc. All rights reserved. Cadence, the Cadence logo, and Spectre are registered trademarks of Cadence Design Systems, Inc. All others are properties of their respective holders.

 

Download PSpice and try it for free! Download Free Trial
Cadence