Showing posts with label MATLAB. Show all posts
Showing posts with label MATLAB. Show all posts

Friday, July 29, 2022

How to Add and Simulate Gas Sensor in Proteus 8 | DC Voltmeter

Today, I will share how to add and simulate a gas sensor in Proteus 8 software. Gas sensors are used to detect and identify different gasses in the atmosphere. Eight types of gas sensors (MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-7, MQ-8, and MQ-9) are available in this library.


References:

Components:

  1. Gas sensor
  2. Logic state
  3. DC voltmeter

Steps (Add Library)
  1. Download the gas sensor library file at TheEngineeringProjects.com or click the link HERE. The download link will appear after 20 seconds.

  2. Open the zip file and go to the folder Proteus Library Files. You will find three files on the downloaded zip file named:
    -GasSensorTEP.LIB
    -GasSensorTEP.IDX
    -GasSensorTEP.HEX


  3. Extract these three files to the Proteus libraries folder (C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA\LIBRARY).

Steps (Gas Sensor):
  1. Open your Proteus software and add LOGICSTATE and all Gas Sensor components to the workspace.


  2. Wiring components:
    -Connect VCC, OUT, GND of GAS SENSOR to the POWER, DC VOLTMETER through GROUND and GROUND.
    -Connect TestPin of GAS SENSOR to the LOGICSTATE.
    -
    Repeat the same step for other types of the GAS SENSOR.


  3. Double click the gas sensor and click the folder icon in the Program File box. Go to Local Disk (C:) > Program Files (x86) > Labcenter Electronics > Proteus 8 Professional > DATA > LIBRARY > GasSensorTEP.HEX > Open > OK. Repeat the same step for other types of the GAS SENSOR.


  4. Start the simulation. If the logic state is HIGH, then the OUT pin gives 5V output (HIGH).


  5. If the logic state is LOW, then the OUT pin gives 0V output (LOW).


Video:


If you have any suggestions, please write in the comment section. Thank you for your time 👷.

Tuesday, June 29, 2021

How to Calculate and Design Uncontrolled Halfwave Rectifier with R Load | MATLAB Simulink

A half-wave rectifier is a rectifier that converts ac to dc and widely used for low-power applications. However, the practical application of this circuit is limited and worth studying in detail. Figures (i) and (ii) show the circuit and a voltage waveform of an uncontrolled half-wave rectifier with the resistive load that has a 240 V source of voltage at a frequency of 50 Hz with the load resistor 10 Ω. 

First, determine the values of (a) the average load current, (b) the average load voltage, (c) the average load power, (d) the rms value of load current, (e) the rms value of load voltage (f) the rms value of load power and (g) the power factor of the circuit. After that, design the rectifier using Simulink MATLAB. Finally, compare the simulation result with the theory.

(i) The circuit of uncontrolled half-wave rectifier with resistive (R) load

(ii) The voltage waveform of uncontrolled half-wave rectifier with resistive (R) load

List of symbols:
$I_{o,avg}$ average output current
$I_{o}$ output current
$I_{s,rms}$ source current in rms value
$I_{o,rms}$ output current in rms value
$V_{m}$ maximum voltage
$V_{d}$ diode voltage
$V_{o,avg}$ average output voltage
$V_{o}$ output voltage
$V_{s,rms}$ source voltage in rms value
$V_{o,rms}$ output voltage in rms value
$V_{f}$ forward voltage
$P_{o,avg}$ average output power
$P_{o}$ power output
$P_{o,rms}$ output power in rms value
$\omega $ angular frequency
$t$ time
$pf$ power factor
$R$ resistor
$S$ apparent power

Step 1: Theory
  1. The average load current, $I_{o,avg}$
    \[I_{o,avg}= I_{o}= \frac{V_{o}}{R}=\frac{V_{m}}{\pi R}\]
    \[V_{m}=\sqrt{2}\times V_{s,rms}\]
    \[I_{o,avg}=\sqrt{2}\times 240\]
    \[I_{o,avg}=10.80\:A\]

  2. The average load voltage, $V_{o,avg}$
    \[V_{o,avg}=V_{o}=I_{o}R=\frac{V_{m}}{\pi }\]
    \[V_{o,avg}=\frac{\sqrt{2}\times 240}{\pi }\]
    \[V_{o,avg}=108.04\:V\]

  3. The average load power, $P_{o,avg}$
    \[P_{o,avg}=P_{o}=P_{o,avg}I_{o,avg}=I_{o,avg}^{2}R=\frac{V_{o,avg}^{2}}{R}\]
    \[P_{o,avg}=\frac{108.04^{2}}{10}\]
    \[P_{o,avg}=1167.26\:W\]

  4. The rms value of load current, $I_{o,rms}$
    \[I_{o,rms}=\frac{V_{o,rms}}{R}=\frac{V_{m}}{2R}\]
    \[I_{o,rms}=\frac{\sqrt{2}\times 240}{2\times 10}\]
    \[I_{o,rms}=16.97\:A\]

  5. The rms value of load voltage, $V_{o,rms}$
    \[V_{o,rms}=I_{o,rms}R=\frac{V_{m}}{2}\]
    \[V_{o,rms}=\frac{\sqrt{2}\times 240}{2}\]
    \[V_{o,rms}=169.71\:V\]

  6. The rms value of load power, $P_{o,rms}$
    \[P_{o,rms}=V_{o,rms}I_{o,rms}=I_{o,rms}^{2}R=\frac{V_{o,rms}^{2}}{R}\]
    \[P_{o,rms}=\frac{169.71^{2}}{10}\]
    \[P_{o,rms}=2880.15\:W\]

  7. The power factor of the circuit, $pf$
    \[pf=\frac{P_{o,rms}}{S}=\frac{P_{o,rms}}{V_{s,rms}I_{s,rms}}=\frac{V_{o,rms}}{V_{s,rms}}\]
    \[I_{s,rms}=I_{o,rms}\]
    \[pf=\frac{169.71}{240}\]
    \[pf=0.707\]
Step 2: Simulation
  1. For simulation, open the Simulink Library Browser and add blocks (Scope, AC Voltage Source, Diode, Series RLC Branch, RMS, Mean, Display, Voltage Measurement, Current Measurement, Goto, From, powergui, Product and Divide) to model.

  2. Rearrange, copy and paste, and rename blocks accordingly, as shown in the figure below.



  3. Click Series RLC Branch block and change the parameters to "Branch type:" to R, "Resistance (ohms):" to  10, and "Measurement" to None.


  4. Click Diode block and change all the parameters to 0 and unclick Show measurement port.


  5. Click Scope > File and set the Number of Input Ports > More... > Number of input ports: change to 4.


  6. Click Mean blocks and change the parameter "Fundamental frequency (Hz):" to 50. Other parameters change to 0.


  7. Click RMS blocks and change the parameters "Fundamental frequency (Hz):" to 50, "Initial RMS value:" to 240, "Sample time:" to 0, and click True RMS value.


  8. Click AC Voltage Source block and change the parameters "Peak amplitude (V):" to 240*sqrt(2), "Phase (deg:)" to 0, "Frequency (Hz):" to 50, "Sample time:" to 0 and "Measurement" to None.


  9. After setting all the parameters, change Stop Time to 2 and run the simulation.

  10. Click Scope block to shows the result of waveform  $I_{o,rms}$, $V_{o,rms}$, $V_{s,rms}$, and $V_{d}$.


  11. Display shows the result of $I_{o,avg}$, $V_{o,avg}$, $P_{o,avg}$, $I_{o,rms}$, $V_{o,rms}$, $P_{o,rms}$,  and $pf$.



Discussion
  1. The value of parameters for theory and simulation are almost equal.
  2. The waveform generated from the simulation is identical to the theory waveform.
Conclusion
The objection of this experiment is to compare the theory and simulation in terms of parameters value and waveform.  The result shows that the value of the parameter of the theory is almost equal to simulation; the same goes for the waveform. Hence, the experiments were held successfully.

Video:

That all from me. If you have any suggestions, please write in the comment section. Thank you for your time 👷.





Wednesday, June 9, 2021

MATLAB Tips and Tricks: Dock and Undock for Editor | Workspace | Current Folder | Command Window

Today, I want to share tips and tricks to dock and undock workspace, current folder, and command window in MATLAB. These tips and tricks should work for some problem such as:

  • Command window or current folder or workspace disappeared.
  • Command window or current folder or workspace undock or open in a separate window.
  • The new script (editor) keeps opening in a new window.
  • Return all layout to its original position.



Example 1: Undock (Editor, Workspace, Command Window and Current Folder)
  1. Click the down arrow icon in the title bar.
  2. Then select the "Undock" option or shortcut key: ctrl+shift+U.
  3. You will see the command window separate from the MATLAB window: repeat steps 1 and 2 to undock workspace, editor, and current folder.
Example 2: Dock (Editor, Workspace, Command Window and Current Folder)
  1. Click the down arrow icon in the title bar.
  2. Then select the "Dock" option or shortcut key: ctrl+shift+D.
  3. You will see the command window return to its original place: repeat steps 1 and 2 to undock workspace, editor, and current folder.
Example 3: Undock All Layout
  1. Go to the "HOME" tab in the MATLAB toolstrip, click "Layout" and select "Default".
  2. All layout restore to the original position.
That all from me. If you have any suggestions, please write in the comment section. Thank you for your time 👷.