Updates from April, 2020 Toggle Comment Threads | Keyboard Shortcuts

  • jalves61 4:53 pm on April 1, 2020 Permalink | Reply

    Object Oriented Programming and C#: Simple Program to add three numbers 

    The following is a simple program that takes a user input of three numbers and adds them but does not crash when an exception is thrown (eg. if a user inputs a non integer value). The “int?” variable is used to include the “null” value used to signify that a bad input was received. The user is notified instantly when an incorrect input is received by the program with a “Bad input” command prompt message.


    The code above shows that the GetNumber() method is called (shown below) three times, and as long as these are integers, they are summed and printed to the console after being converted to a string.


    The code shows that as long as the sum of the three integers is not equal to null (anything plus null is equal to null, so if at least one input is a non-integer this will be triggered) the Console will print the sum of the three numbers. The GetNumber() method uses the “TryParse” method to convert each string input to an integer. This will handle exceptions that are triggered by passing a non-integer to the command line. It also gives a convenient return of “null” which is used above.

    The following shows the effect of both a summation and an incorrect input summation failure.



  • jalves61 8:28 pm on March 30, 2020 Permalink | Reply  

    Power Factor and the Power Triangle 

    Power factor is very important concept for commercial and industrial applications which require higher current draw to operate than domestic buildings. For a passive load (only containing resistance, inductance or capacitance and no active components), the power factor range from 0 to 1. Power factor is only negative with active loads. Before delving into power factor, it is important to discuss different types of power. The type of power most are familiar with is in Watts. This is called active or useful power, as it represents actual energy or time dissipated or “used” by the load in question. Another type of power is reactive power, which is caused by inductance or capacitance, which leads to a phase shift between voltage and current. To demonstrate how a lagging power factor causes “wasted” power, it would be helpful to look at some waveforms. For a purely resistive load, the voltage and current are in phase, so no power is wasted (P=VI is never zero at any point).


    The above image captures the concept of leading and lagging power factor (leading and lagging is always in reference to the current waveform). For a purely inductive load, the current will lag because the inductor will create a “back EMF” or inertial voltage to oppose changes in current. This EMF leads to a current within the inductor, but only comes from the initial voltage. It can also be seen that this EMF is proportional to the rate of change of the current, so when the current is zero the voltage is maximum. For a capacitive load, the power factor is leading. A capacitor must charge up with current before establishing a voltage across the plates. This explains the PF “leading” or “lagging”. Most of the time, when power factor is decreased it is because the PF is lagging due to induction motors. To account for this, capacitors are used as part of power factor correction.

    The third type of power is apparent power, which is the complex combination of real and reactive power.


    The power factor is the cosine of the angle made in this triangle. Therefore, as the PF angle is increased the power factor decreases. The power factor is maximum when the reactive power is zero. Ideally, the PF would be between 0.95 and 1, but for many industrial buildings this can fall to even 0.7. This leads to higher electric bills for this buildings because having a lower power factor leads to increases current in the power lines leading to the building which causes higher losses in the lines. It also leads to voltage drops and wastage of energy. To conserve energy, power factor correction must be employed. Often capacitors are used in conjunction with contactors that are controlled by regulators that measure power factor. When necessary, the contactors will be switched on and allow the capacitors to improve the power factor.

    For linear loads, power factor is called as displacement power factor, as it only accounts for the phase difference between the voltage and current. For nonlinear loads, harmonics are added to the output. This is because nonlinear loads cause distortion, which changes the shape of the output sinusoids. Nonlinear loads and power factor will be explored in a subsequent post.

  • jalves61 9:23 pm on March 26, 2020 Permalink | Reply
    Tags: ,   

    RFID – Radio Frequency Identification 

    RFID is an important concept in the modern era. The basic principle of operation is simple: radio waves are sent out from an RF reader to an RFID tag in order to track or identify the object, whether it is a supermarket item, a car, or an Alzheimer patient.

    RFID tags are subdivided into three main categories: Active, passive and semipassive. Active RFID tags employ a battery to power them whereas passive tags utilize the incoming radio wave as a power source. The semipassive tag also employs a battery source, but relies on the RFID reader signal as a return signal. For this reason, the active and semi passive tags have a greater range than the passive type. The passive types are more compact and also cheaper and for this reason are more common than the other two types. The RFID picks up the incoming radio waves with an antenna which then directs the electrical signal to a transponder. Transponders receive RF/Microwaves and transmit a signal of a different frequency. After the transponder is the rectifier circuit, which uses a DC current to charge a capacitor which (for the passive tag) is used to power the device.

    The RFID reader consists of a microcontroller, an RF signal generator and a receiver. Both the transmitter and receiver have an antennas which convert radio waves to electrical currents and vice versa.

    The following table shows frequencies and ranges for the various bands used in RFID


    As expected, lower frequencies travel further distances. The lower frequencies tend to be used for the passive type of RFID tags.

    For LF and HF tags, the working principle is inductive coupling whereas with the UHF and Microwave, the principle is electromagnetic coupling. The following image shows inductive coupling.

    inductive coupling

    A transformer is formed between the two coils of the reader and tag. The transformer links the two circuits together through electromagnetic induction. This is also known as near field coupling.

    Far field coupling/radiative coupling uses backscatter by reradiating from the tag to the reader. This depends on the load matching, so changing the load impedance will change the intensity of the return wave. The load condition can be changed according to the data in order for the data to be sent back to the reader. This is known as backscatter modulation.

  • jalves61 8:45 pm on March 24, 2020 Permalink | Reply  

    Using GIT – Introduction 

    Git is essentially a version control system for tracking changes in computer files. This can be used in conjunction with Visual Studio to program in C#, for example. Git can be accessed through commands through the command window in windows. Git is generally to coordinate changes to code between multiple developers and is also used to work in a local repository which is then “pushed” to a remote depository such as Github.com

    Git tracks changes to files by taking snapshots. This is done by the user by typing “git commit ….” in the command prompt. The files should be added to the staging area first by using the command “git add <filename>”. “Git push” and “git pull” are used to interact with the remote repository. “Git clone” will copy and download a repository to your local machine. Git saves every version that gets committed, so a previous version can always be accessed if necessary. The following image illustrates the concept of committing.


    You can essentially “branch” your commits which can later be merged together by using “git commit” command with multiple parents. The master branch is the main/linear list of saves. This can be done in the remote repository or the local. A “pull request” essential means taking changes that were made in a certain branch and pulling them into another branch. This means multiple people can be editing multiple branches which can then be merged together.

    Git is extremely useful for collaboration (as with websites such as google docs) where multiple authors can work on something at the same time. It also is excellent for keeping track of the history of projects.

  • jalves61 7:27 pm on March 23, 2020 Permalink | Reply
    Tags: ,   

    Mobility and Saturation Velocity in Semiconductors 

    In solid state physics, mobility describes how quickly a charge carrier can move within a semiconductor device when in the presence of a force (electric field). When an electric field is applied, the particles begin to move at a certain drift velocity, given by the mobility of the carrier (electron or hole) and electric field. The equation can be written as: density

    This is also related to Ohm’s law in point form, which is the conductivity multiplied by the Electric field. This shows that the conductivity of a material is related to the number of charge carriers as well as their mobility within the material. Mobility is heavily dependent on doping, which introduces defects to the material. This means that intrinsic semiconductor material (Si or Ge) has higher mobility, but this is a paradox due to the fact that intrinsic semiconductor has no charge carriers. In addition, mobility is inversely proportional to mass, so a heavier particles will move at a slower rate.

    Phonons also contribute to a loss of mobility due to an effect known as “Lattice Scattering”. When the temperature of semiconductor material is raised above absolute zero, the atoms vibrate and create phonons. The higher the temperature, the more phonon particles which means greater collisions and lower mobility.

    Saturation velocity refers to the maximum velocity a charge carrier can travel within a semiconductor in the presence of a strong electric field. As previously stated, the velocity is proportional to mobility, but with increasing electric field there reaches a point where the velocity saturates. From this point, increasing the field only leads to more collisions with the lattice structure and phonons, which does not help the drift speed. Different semiconductor materials have different saturation velocities and are strong functions of impurities.

  • jalves61 10:58 am on March 22, 2020 Permalink | Reply
    Tags: ,   

    Transistor IV curves and Modes of Operation/Biasing 

    In the field of electronics, the most important active device is without a doubt the transistor. A transistor acts as a ON/OFF switch or as an amplifier. It is important to understand the modes of operation for these devices, both voltage controlled (FET) and current controlled (BJT).

    For the MOSFET, the cutoff region is where no current flows through the inversion channel and functions as an open switch. The “Ohmic” or linear region, the drain-source current increases linearly with the drain-source voltage. In this region, the FET is acting as a closed switch or “ON” state. The “Saturation” region is where the drain-source current stays roughly constant despite the drain source voltage increasing. This region has the FET functioning as an amplifier.


    The image above illustrates that for an enhancement mode FET, the gate-source voltage must be higher than a certain threshold voltage for the device to conduct. Before that happens, there is no channel for charge to flow. From there, the device enters the linear region until the drain-source voltage is high enough to be in saturation.

    DC biasing is an extremely important topic in electronics. For example, if a designer wishes for the transistor to operate as an amplifier, the FET must stay within the saturation region. To achieve this, a biasing circuit is implemented. Another condition which effects the operating point of the transistor is temperature, but this can be mitigated with a DC bias circuit as well (this is known as stabilization). “Stability factor” is a measure of how well the biasing circuit achieves this effect. Biasing a MOSFET changes its DC operating point or Q point and is usually implemented with a simple voltage divider circuit. This can be done with a single DC voltage supply.  The following voltage transfer curve shows that the MOSFET amplifies best in the saturation region with less distortion than the triode/ohmic region.


  • jalves61 10:31 am on March 21, 2020 Permalink | Reply
    Tags: ,   

    Quantum Wells in LEDs 

    Previously, the topic of a quantum well’s functionality was discussed. Here, the topic of quantum wells’ function specifically within Light Emitting Diodes is discussed. In fact, quantum wells often implement multiple quantum wells to increase their luminescence, or total light emission.

    Quantum wells are formed when a type of semiconductor (or compound semiconductor) with a more narrow bandgap between its conduction and valence band is placed in between two wider bandgap semiconductors (such as GaN or AlN). The quantum well traps electrons within it at the conduction band, so as to increase recombination. Holes from the valence band will recombine with the conduction band electrons to emit photons which gives the LED its distinct emission of light. The quantum well is the reason why the LED does not function strictly as a diode. If the electrons were not trapped, the current would simply flow normally as in a regular LED. Although a greater number of quantum wells increases the luminescence of the LED, it can also lead to defects in the device.

    LEDs generate different colors of light by using different semiconductor material and different amounts of doping. This changes the energy gaps and leads to a different wavelength of light being produced. Gallium is a common element used in these compound materials.

  • jalves61 7:28 pm on March 20, 2020 Permalink | Reply

    Power Amplifiers basics 

    Multistage amplification is used to increase the overall gain of an amplifier chain. The total gain is the product of each stage’s gain. For example, a microphone can be connected to first a small signal amplifier (voltage amplifier), then a power amplifier before being supplied to a speaker or some other load. The PA (large signal amplifier) is the final stage of the amplifier chain and is the most power hungry. The major features of these PAs are it’s efficiency (usually drain efficiency for FET archetypes or Collector efficiency for BJT amplifiers) and impedance matching to the load. The output power of a PA is typically in tens of watts (small signal amplifiers generally output in mW up to 1 Watt maximum).

    “Small signal” transistors are used for small signal amplifiers whereas “power” transistors are used for PAs. Small signal transistors behave linearly whereas power transistors can suffer from nonlinear distortion.

    PAs can be classified based on the operating point (Q point) location. Class A amplifiers have a Q point at the center of the active region. For Class B, the Q point is at the cutoff region. For Class AB, the Q point is between that of class A and class B. For Class C, it is below cutoff.

    A major parameter of a PA is its efficiency. This is the ratio of AC power to DC input power and is generally expressed in a percentage.

    Harmonic distortion of a PA involves the presence of harmonic multiples of the fundamental frequency at the output. A large input signal can cause this type of distortion

  • jalves61 6:14 pm on March 19, 2020 Permalink | Reply

    Object Oriented Programming and C#: Methods 

    Methods in C# are quite similar to functions in C. A function is something that takes input parameters and returns outputs. The major difference between methods, which are involved with object oriented programming, and functions is that methods are associate with objects. Methods give the programmer a huge advantage in the sense that their code is much easier to read and allows the user to reuse code to avoid repetitions. It is important to note that methods can only be contained within classes and methods declared within methods are not allowed. The method “Main” is included in every program.

    The following is the syntax for a method:


    The return type for “main” is void since it does not return a value. The name of the method and list of parameters are called the “method signature”. The name of the method should contain either a verb or a noun and a verb. An “access modifier” gives the compiler information about how the method can be used, just as with classes. Examples are public, private, etc. The “static” method is a method that does not need to be instantiated.

    “Local variables” are variables defined within a method that can only be used within the method. The area of visibility for this variable is from where it is defined to the last bracket of the method body.

    Methods can be called from the “main” method or from some other method. In fact, methods can call themselves (this is called recursion). You can also call a method BEFORE it is declared!

    A method’s parameters are the inputs necessary to complete whatever task the method needs to achieve. Arrays can be used as parameters if necessary. When declaring a method with parameters, the values in the parentheses are called parameters, but when the method is called, the values actually used are called arguments.

    Another important note is that when a variable is passed to a method argument, the value is copied to the parameter for use within the method. However, when a variable is declared within a certain method and then placed as an argument to a method, if the parameter is hardcoded within that method, it will use the hardcoded value but the variable declared will not be effected. Here is an example:



    This will print the number 5 (not 3). In the Main() method, however, numberArg is 3.

  • jalves61 12:31 pm on March 12, 2020 Permalink | Reply
    Tags: ,   

    Advanced Electronics and Optoelectronics: The MESFET 

    One of the more common FET transistor typologies is the MESFET (Metal Semiconductor field effect transistor). This active device is the oldest FET device concept. The MESFET is similar in  structure to a JFET (Junction Field effect transistor) but includes a Schottky junction instead of a P-N junction.

    The MESFET’s channel depends on three parameters: the velocity of the charge carriers, the density of these charge carriers, and the geometric cross section the carriers flow through. The gate electrode is connected directly to the semiconductor material, creating a Schottky diode. The MESFET is generally constructed from the compound semiconductor GaAs (Gallium Arsenide) to provide higher electron mobility. As shown, the substrate is semi-insulating to decrease parasitic capacitance.


    The device works by limiting the electron flow from source to drain, similar to a JFET. The Schottky diode controls the resistance of the channel (size of depletion region). Varying the voltage across the Schottky gate changes the channel size. Similar to other FETs, there is a certain pinch off voltage that causes the current to be very small, making the MESFET a switch or variable resistor. MESFETs can be depletion mode or enhancement mode. The MESFET is often used in high frequency wireless communication devices such as cell phones or military radars.

    (All information and photos obtained from “High Speed Electronics and Optoelectronics Devices and Circuits” by Sheila Prasad)

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc