Wednesday, September 11, 2013

Hysteresis Comparator with Simscape Library

In this post, I would like to implement a simple hysteresis comparator. I use to simulate this type of circuits with PSPICE, since the drawing of the circiuit is easier than Simulink. However, if interaction with some logic signals is needed, it would be easier to create all the schematic with Simulink.

Note: In order to create this example, SimScape library is needed.

First of all, the schematic I am going to follow can be seen in the next figure:

Hysteresis Comparator general schematic
For this circuit, the equations to design the values we want are the following:

Vref = Vcc * (R4 / (R4 + R3)
Vu = Vref * (R1 + R2) / R2  Vupper threshold
Vl = (Vref * (R1 + R2) - Vcc * R1) / R2  Vlower threshold

Base on that, the first step is to chose the components depending on whatever we want. I wanted Vu = 2.33V and Vl= 2.95. Since Vcc = 5V then the R values calculated are the following:
After chose normalized values, I recalculate my constrains. Since they fits with what I need, I can continue with the example.
Final designed values

To simulate these theoretical values, the Simulink schematic is created:
Hysteresis comparator Simulink Schematic


After designing the circuit, the values of the components must be set. The input signal I chose to test the circuit was 'Pulse Voltage Source' block

Pulse voltage source configuration
Finally the output of the example is showed in the next figure:
Output signals

Zoom in at Vupper value

Zoom in at Vlower value
It can be seen that the output is the one expected.


Licencia Creative Commons

No comments :

Post a Comment