## Wednesday, 1 July 2015

### FET component:

Pins:
(D)rain - Electrical current enters here
(G)ate - This pin controls the size of the FET "gate", how much current is able to pass through.
(S)ource - Electrical current exits here

### Comparison of BJT and FET:

As an analogy, the FET transistor can be compared to the BJT
BJT:

• (B)ase pin acts as input
• Current flows from (C)ollector to (E)mitter
• Input voltage V_b must be above 0.2V for the device to work in an operable region (a.k.a active region)

FET:

• (G)ate pin acts as input
• Current flows from (G)ate to (S)ource
• Input voltage V_GS must be above a certain threshold, V_TO for the device to work in an operable region (a.k.a saturation region)

### Comparison of voltage graphs:

Note that the FET voltage graph is not unlike that of the BJT
BJT

FET

Note that while the output current of the BJT (emitter) is dependant on the input current, the output current of the FET (source) is dependant on the input voltage. This is an important point to consider when analysing the small signal properties of the transistors.

## Introduction to Operational Amplifiers (Op-Amps)

In summary, the op-amp is a voltage amplifier, typically with two inputs, and a single output. For the sake of simplification, most op-amps can be simplified into the following model. http://en.wikipedia.org/wiki/Operational_amplifier
There are 5 pins;
V+ This is the noninverting input
V- This is the inverting input
Vout This is the output terminal
Vs+ This pin is attached to a high voltage source
Vs- This is the grounding pin

However, usually they are drawn as follows http://hyperphysics.phy-astr.gsu.edu/

We do not explicitly show the power-supply connections (Vs+ and Vs-) in circuit diagrams.
It is assumed that the Vout voltage is made in relation to the circuit's ground.

The op-amp multiplies the difference between V+ and V-, and multiplies it by Aol, the open loop gain.
i.e. Vout = |(V+ - V-)| x Aol

This gain parameter, Aol is very large, and is assumed to be infinite, in the case of an ideal op-amp.
For the simplicity of calculation, we simply assume that, because Vout is real,
Vout/Aol = |V+ - V-|

i.e. V+ = V-

This concept is known as the summing point constraint.
This is the default assumption we make whenever calculating feedback loops for ideal op-amps.
By making this assumption, we can apply standard circuit analysis principles.
While there is a difference between V+ and V-, we have to assume that they are the same value for the sake of calculation, such as the following cases demonstrated below.

## Using the Op-Amp in circuits

Inverting amplifiers - negative feedback
Inverting amplifiers - positive feedback
Noninverting amplifiers
Non inverting amplifiers always have negative feedback.

## Amplifier models:

There exist four amplifier models;
1. Voltage Amplifier Model
2. Current Amplifier Model
3. Transconductance Amplifier Model
4. Transresistance Amplifier Model Simplified amplifier model

To begin, we need to understand the voltage amplifier model.

### Voltage amplifier model

Consider the image above. In the case of the voltage amplifier model, the internal components can be modelled as the following;

Where
Vi = input voltage
Vo = output voltage
Ii = input current
Io = output current
Ri = input resistance/impedance
Ro = output resistance/impedance

The gain property of this model is represented by a voltage-controlled voltage source.

Note:
By definition, voltage gain, Av = Vo/Vi

Open-circuit voltage gain = Avo
(if the load is an open circuit, as shown above, there is no drop across the output resistance, and Vo = Avo*Vi)

Given a model with external loading (i.e. with external components attached), the model can be simplified as follows, for analysis. Aside from voltage gain. there also exists current gain, Ai, which can be calculated as follows;
Ai = Io/Ii = (Vo/Rl)/(Vi/Ri) = Av*(Ri/Rl)

### Current amplifier model

Another method of modelling the amplifier is the current amplifier model.
This can be modelled as the following;

The gain property of this model is represented by a current-controlled current source.

Note:
By definition, current gain Ai = Io/Ii

Open-circuit current gain = Aisc
(If the load is a short circuit, no current flows through resistor Ro, and Io/Ii is short-circuit current gain.)

### Transconductance amplifier model

Another method of modelling the amplifier is the transconductance-amplifier model.
This can be modelled as the following;

The gain property of this model is represented by a voltage-controlled current source.

Observe that while the transconductance-amplifier and current-amplifier models use the Norton equivalent circuit, the voltage-amplifier model uses the Theverin equivalent circuit, as will the transresistance model, as will be demonstrated below.

### Transresistance amplifier model

Another method of modelling the amplifier is the transresistance-amplifier model.
This can be modelled as the following;

The gain property of this model is represented by a current-controlled voltage source.

### Ideal amplifiers

If the reasons for the above table remain unknown, consider the following

Inputs:
The voltage and transconductance models are voltage controlled.
Thus, the input impedance Ri is ideally large, this maximises the voltage drop Vi to be maximised over Ri. (See earlier diagrams)

The current and transresistance models are current controlled.
Thus, to maximise the input current Ii, Ri is minimised.

Outputs:
The voltage and transresistance models are voltage sources.
Thus, to maximise the output Vo, the output impedance Ro is minimised. By doing so, the voltage drop over Rl is maximised.

The current and transconductance models are current sources.
Thus, to maximise the output current Io, the output impedance Ro is maximised, allowing the current to flow out of the amplifier (Ro becomes akin to an open circuit).

(Note that this logic holds because for the voltage sources, a Theverin equivalent circuit is used, while for the current sources, a Norton equivalent circuit is used. More information on Theverin and Norton can be found here.)

Hopefully, this provides an introduction to amplifier models. If you feel that any part of this post needs improvements, feel free to contact us at engyfun@gmail.com

References:
Kroll, (2009). 1st ed. [ebook] Available at: http://surf.hep.upenn.edu/~kroll/p364_fall09/handouts/simple_voltage_amplifier.pdf [Accessed 5 Mar. 2015].

### Electronics notes

We understand that the electronics courses I've taken with my friends are a little overcomplicated, and as such, we will attempt to post simplified explanations on this blog.

Look for the following label(s):
ElectronicsI, ElectronicsII

## Saturday, 7 February 2015

### Arduino library for 28BYJ48 Stepper motor and ULN2003 driver.

Here is the source code for our 28BYJ48 stepper motor, ULN2003 driver library, as well as an implementation. Check out the diagram for the wiring.

__________________________________________________________________

#ifndef Stepper_h
#define Stepper_h

class StepperMotor {
public:
StepperMotor(int In1, int In2, int In3, int In4);    // Constructor that will set the inputs
void setStepDuration(int duration);    // Function used to set the step duration in ms
void step(int noOfSteps);    // Step a certain number of steps. + for one way and - for the other

int duration;    // Step duration in ms
int inputPins;    // The input pin numbers
};

#endif

___________________________________________________________________

The cpp file:
___________________________________________________________________

#include <Arduino.h>
#include <StepperMotor.h>

StepperMotor::StepperMotor(int In1, int In2, int In3, int In4){
// Record pin numbers in the inputPins array
this->inputPins = In1;
this->inputPins = In2;
this->inputPins = In3;
this->inputPins = In4;

// Iterate through the inputPins array, setting each one to output mode
for(int inputCount = 0; inputCount < 4; inputCount++){
pinMode(this->inputPins[inputCount], OUTPUT);
}
duration = 50;
}

void StepperMotor::setStepDuration(int duration){
this->duration = duration;
}

void StepperMotor::step(int noOfSteps){
/*
The following 2D array represents the sequence that must be
used to acheive rotation. The rows correspond to each step, and
the columns correspond to each input. L
*/
bool sequence[] = {{LOW, LOW, LOW, HIGH },
{LOW, LOW, HIGH, HIGH},
{LOW, LOW, HIGH, LOW },
{LOW, HIGH, HIGH, LOW},
{LOW, HIGH, LOW, LOW },
{HIGH, HIGH, LOW, LOW},
{HIGH, LOW, LOW, LOW },
{HIGH, LOW, LOW, HIGH}};

int factor = abs(noOfSteps) / noOfSteps;    // If noOfSteps is +, factor = 1. If noOfSteps is -, factor = -1
noOfSteps = abs(noOfSteps);    // If noOfSteps was in fact negative, make positive for future operations

/*
The following algorithm runs through the sequence the specified number
of times
*/
for(int sequenceNum = 0;  sequenceNum <= noOfSteps/8; sequenceNum++){
for(int position = 0; ( position < 8 ) && ( position < ( noOfSteps - sequenceNum*8 )); position++){
delay(duration);
for(int inputCount = 0; inputCount < 4; inputCount++){
digitalWrite(this->inputPins[inputCount], sequence[(int)(3.5 - (3.5*factor) + (factor*position))][inputCount]);
}
}
}
}

_______________________________________________________________________

An implementation:
_______________________________________________________________________

#include <StepperMotor.h>

StepperMotor motor(8,9,10,11);

void setup(){
Serial.begin(9600);
motor.setStepDuration(1);
}

void loop(){
motor.step(1000);
delay(2000);
motor.step(-1000);
delay(2000);
}

_________________________________________________________________________

Wiring diagram: 