BJT amplifier with Simscape Electrical

 In this simscape electrical tutorial, a BJT amplifier is designed and simulated. It is shown how to build a bipolar junction transistor based amplifier with common emitter configuration biased with the  voltage divider biasing method.

What is Simscape Electrical?

Simscape Electrical is a specialized block programming tool for modeling and simulating electrical systems within the Simulink environment. It allows users to design and analyze various types of electrical circuits, such as power electronics, electromechanical systems, and control systems.

Simscape Electrical provides a library of pre-built components, such as resistors, capacitors, inductors, transformers, motors, and power sources, which can be easily interconnected to create complex electrical models. The software supports both linear and nonlinear simulations, and it can be used to model both continuous-time and discrete-time systems.

In addition to its simulation capabilities, Simscape Electrical also includes features for parameter estimation, model optimization, and automated code generation. It can be used in a variety of applications, including power electronics design, renewable energy systems, automotive systems, and aerospace and defense systems.

BJT amplifier in Simscape Electrical

Open a new Simulink model and create the following circuit diagram in the new model.

BJT amplifier circuit diagram with Simscape

Components:
 
You can find the components in the Simulink library as follows:
 
Capacitor:   Simscape > Foundation Library > Electrical > Electrical Elements   
Resistor:   Simscape > Foundation Library > Electrical > Electrical Elements
Electrical Reference(GND):    Simscape > Foundation Library > Electrical > Electrical Elements
electrical elements

NPN BJT Transistor: Simscape > Electrical > Semiconductor & Converters
 
BJT transistor simscape
AC Voltage Source :   Simscape > Foundation Library > Electrical > Electrical Sources
voltage source
 
Battery:     Simscape > Electrical > Sources
battery

 
PS-Simulink Converter:     Simscape > Utilities

You can type in the component value by double clicking it and if you want to display the value with unit then you need to change the properties the component to show the values and its units. For example, to display the resistor value with unit, right click on it and click on the properties. In the properties window, click on the the block annotation tab and add the %<R>%<R_unit> tokens and arrange them as shown in the figure below.
block annotation

 Similarly you can change the properties to display the component value with unit of the rest of the components.

To know how to calculate the resistor and capacitor values see the BJT transistor biasing tutorial or you can use use the BJT amplifier calculator and choose the voltage divider method.
 
Here we have used 5V supply DC voltage. The input signal is 50mV and has frequency of 5KHz.
 
The NPN BJT transistor is modeled as 2N3904 bipolar junction transistor. The following shows the Simscape BJT transistor configuration.

BJT model in simscape

The above values were obtained from the 2N3904 bipolar junction transistor datasheet.

Next we have to configure the model simulation. For this go to Modelling > Model Settings > Model Settings as shown below.
model settings

Choose Variable-step in the Solver Selection type and choose ode15s(stiff/NDF) in the Solver field. Then also set the stop time to 0.2 as shown below.

model settings for simscape
 
Next double click the solver configuration block(f(x)=0 block) in the model and set to use the local solver and set the sample time to 1e-6 as shown below.
 
solver configuration simscape

 At this point the BJT amplifier model is build in Simulink as simscape model and properly configured. The next step is to simulate the amplifier model to view the input and output signal waveform on time scope and view their frequency spectrum using the spectrum analyzer block.

Simulation

To view the input and output signal waveform in time scope go to DSP System Toolbox > Sinks and use the Time Scope block in the model.   


Also add PS-Simulink Converter from Simscape > Utilities to the model and them as shown in the following model diagram.

measuring signal in BJT amplifier circuit diagram with Simscape

Run the simulation and view double click on the Time Scope to view the input and output waveform. This is shown below.

signal waveform of BJT amplifier circuit diagram with Simscape

This shows that the input signal is amplified and 180 out of phase relative to the output signal.

Similarly we can view the input and output signal frequencies in the frequency spectrum analyzer. To obtain this we need to add spectrum analyzer from the DSP System Toolbox > Sinks as shown below.

spectrum analyzer block

We also need a ADC(Analog to Digital Converter) block and Zero Order Hold block to send the physical system signal from simscape which is continuous to convert to discrete type signal with same sampling rate. The ADC block can be found under Mixed Signal Blockset > Architectures. There are two ADC blocks, Flash ADC and SAR ADC. Here we will choose the Flash ADC block as shown below.

ADC

The Zero Order Hold Block can be found in Simulink > Discrete or you can simple search for it.

Zero Order Hold

Now join the voltage sensor at the input and output to the Flash ADC then to the Zero Order Hold and connect finally to the two ports of the Spectrum Analyzer block as shown below.

Spectrum analysis in Simscape model
Set the run time to inf and start the simulation. Open the Spectrum analyzer, set the frequency span from 0 to 20e3(20KHz) and you will see the input signal and output signal frequencies in the spectrum analyzer as shown below.

Spectrum analysis in Simscape model

In this way we can build BJT amplifier model with Simscape electrical in Simulink and see the input and output signal waveform and their frequency spectrum.

Video Demonstration

The following video shows all the steps described above from adding simscape electrical components, configuring them, setting up the model simulation configuration, running the simulation and view the outputs.



Conclusion

In conclusion we have explained what Simscape electrical is and how to use to model and verify a Bipolar Junction Transistor(BJT) based amplifier. 
 
References:
 
 

Post a Comment

Previous Post Next Post