Short story: “Death”, “Hat”, “Gene”

Sasaki knew nothing would change if she begged for help. She had been there. Weak kids had weak parents who would blame their own child to appease the other kid’s parents. Her parents were weak but she was not. Thus, when Sasaki broke the glass with her satchel and waved a glass fragment at the bullies, she received no sympathy.

There was no such a thing as self-defense in schools. In a fight, there would be no victims. All parties were equally at fault. She knew the consequences and she accepted them. A week before, the idea would have been unfathomable and yet there she was, clutching a bloody shard in her bare hand, watching her classmates backing off as she walked through.

At that moment, her only thought was to kill the other girls and in the end, she only managed to stab her teacher who was trying to stop her.

The police took her into custody. There were no barred cells for children of her age, there were no steel handcuffs. She was attended by a female officer and the worst restraint she had to endure was from a zip tie; even this was only for a brief time between transits. The police and the schools were being courteous, so she heard. They took every measure to cover up the incident.

The police brought in a psychiatrist to assist in the case. The man was twice as tall as she was and he wore thick beards with a pair of round glasses. There was a white-and-pink scarf wrapped around his head. From head to toe, the man was Arabian and he appeared to speak fluent Japanese. He introduced himself as Abu-Jamal, Mahmud Al-Alem Saifu Abu-Jamal upon her insistence.

Their conversation were not without conditions; the first of which was that he must answer one of her questions for every question he wanted answer, second was that he  not overstep his boundaries. “Sasaki-chan” was fine for her but not “Aiko” or “Aiko-chan”, and in exchange, she would call him “Abujama” as he insisted; by his given name and not his doctor title. And the third, she licked her dry lips.

“I’m thirsty…”

Abu-Jamal chuckled. “Well, me too, Sasaki-chan. Do you want orange or peach juice?”

“Milk!” she perked up on her feet, “Milk with sugar, please”, she said.

They were off to a good start. The Arabian got her talking about her family. She had an elder sister, a mother and a father–a more normal family than her actions that day would have suggested. They were all alive and well, she emphasized, but sometimes, she wished they were not.

“Why? Why do you hate them so much?” Abu-Jamal asked.

At this question, she shrank and looked down at her bandaged hands. The answer came under her breath: “They are unfair.”

It was then that Abu-Jamal noticed something unusual about her way of speaking.

“Say, how old are you, Sasaki-chan?”

“Don’t you already know?”

“Just want to hear it from you directly. After this, you can ask me anything.”

“Fourteen. It’s fourteen. And I don’t have any questions for now.”

She averted her eyes from his gaze.

“Am I making you uncomfortable?”

She hesitated. She opened her mouth for an instance then chose to close it and had a better thought of the answer. Finally, she spoke up:

“No, not in particular.”

“You are a good liar, Sasaki-chan, but hesitance can be as telling as silence.”

Following this, he raised a few questions regarding the girls who picked on her, as well as the teacher. But, the conversation had reached the point where she no longer wanted to participate. Then, he stood up and excused himself.

Her father heard of the event.

For this, her father slapped her. They went through a heated argument which concluded with her flinging her satchel at him, missing his face and hitting the family’s altar. The photo of her mother fell to the floor and cracked. Both of them froze at the instance; their faces twisted in agony. Afterward, she bolted out of the house and ran, and ran.

“Sasaki-chan!”

She ran into Abu-Jamal.

“D-Doctor!”

“That’s no good, Sasaki-chan. It’s Abu-Jamal. Oh my…your noses are running–he produced a handkerchief and gently wiped her tears–Tell me what happened.”

Perhaps it was the expectation that the psychiatrist could give her the approval she sought, Sasaki spoke at length how she had been picked on for her fear of sharp things, her anemia and nonstop bleeding, how her father had not been as supportive to her as he had been to her sister, and how powerless she had been.

“Had I not been born…”

The words caught in her throat.

“That’s hardly true, Sasaki-chan. It takes great courage to give one’s life for another. You are a smart girl, Sasaki-chan, can you be as unfair as casting away the life she has given you so easily?”

“B-But…I didn’t ask for this.”

“Indeed, Sasaki-chan. It is unfair to be given something you didn’t ask for and to be demanded gratitude in return. And beside…”

It was then that he took the white-and-pink scarf from his head and put it on hers.

“This is a hat called pagri, Sasaki-chan. It is a symbol of honor and respect in our religion and receiving one means you’re an important guest and that you’re welcome.”

He too was very unfair.

“But I–”

At that instance, she caught his downcast eyes. Was this the right thing to do? Listening to his sigh and seeing him folding the handkerchief and putting it into his pocket, she made up her mind and bowed her head.

“I’m sorry. Thank you.”

“It’s slow, Sasaki-chan. Remember, hesitance can be as telling as silence. So, which one makes you feel better? Before or after you say “thank you”?”

“After.”

This time, she managed to reply without hesitation.

“That’s right, Sasaki-chan. You turned your fear and your weakness into your greatest weapons. I dare say the girls you tried to kill the other day have learned to fear sharp things and blood a little bit more than you do now.”

She grinned and nodded.

“Not that I would recommend you do this sort of things everyday but, surely, you can turn a little unfairness in this world to your advantage too, can’t you?”

She nodded again.

Madmud Al-Alem Saifu Abu-Jamal had a secret. So did Sasaki Aiko.

After their conversation on the street, the man returned her to her home. She did not know what they were discussing in English but it appeared he managed to persuade her father to forgive her. She was afraid her father was only pretending in front of a guest to save face but even after the Arabian had left, he did not turn on her. He merely gestured at the kitchen; a sign that dinner was in the microwave.

It was rice balls again; it was always rice balls from the convenience store.

The next day, Abu-Jamal came by early in the morning. He asked her to put on her black-and-white sailor uniform even though she had no class all day–she had been suspended for a week.

“Your father and I have been discussing about transferring you to a new school. We have a few options on the table. I want you to see the schools for yourself and tell me which one you like best. Isn’t it right, Sasaki-san?”

Her father quietly nodded, confirming the story. Then, he knelt down on one knee and hugged her. “Remember, Aiko. No matter where you go, no matter what you do, I’ll always love you.”

“Eh…ah…thank you, dad. I’ll see you again tonight, right?”

“Yeah, I’ll cook something good for you tonight”, he answered, patting her head.

Once they were on the road, Abu-Jamal let out a sigh and remarked.

“You still have much to learn, Sasaki-chan.”

She smiled the bravest smile she could put up.

“You are a good liar too, Abujama-san. But, dad is nothing like you.”

“It’s okay to cry when hurt, Sasaki-chan. It’s a perk of girls at your age.”

And she did make good use of that perk. Abu-Jamal’s words had been full of deception and unfairness but they were ones she could not help but let herself be deceived.

Their destination was Fukuoka Prefecture, home to Kyushu University Hospital. A group of scientists there were researching a cure for hemophilia–a genetic disorder that leads to nonstop bleeding–and they needed her assistance. She was far too young to understand the finer points of genetics but one thing she could understand: she was exceedingly unfortunate to be born with hemophilia.

The chance for females to be afflicted with the condition is one-in-twenty-five-million. When she hit puberty, hemophilia could lead to fatal internal bleeding during periods if not discovered and properly taken care of. The earlier she started the treatment, the lower the chance of incurring long-term health risks.

“That’s not all, Sasaki-chan. I’m inclined to believe you’re also–ah, never mind.”

“I am also what? Tell me, tell me!”

“Now, now, I can’t give any spoiler, can I? You’ll have to figure out yourself if you want to be a great heroine.”

“So…am I a psychic? A blood wizard?”

The man laughed. Rubbing her hair and putting the white-and-pink pagri from her hands on her small head, he said:

“We’ll test that too but, don’t hold your breath just yet.”

“Now that we’re so much closer, can I call you Abujama?”

“At home–ehem, at the new home, you can call me Abujama, Yama, Abu, whatever suits you. Though here, you should call me Dr. Mahmud.”

“Can I have milk with sugar, Dr. Mamu…Mamudu?”

“Sure you can, Aiko.”

Advertisements

Memo: Active frequency filters

Frequency filters attenuate signals outside its band-pass thresholds. There are two flavors of frequency filters: active and passive. Active filters have op-amps and offer amplification, as well as impedance matching functionality, of the output signal. Passive filters are simple R-C-L networks without any op-amp.

Band-pass and Band-stop construction

Band-pass filter is defined as follow:

band-pass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.

Band-stop filter is the opposite of Band-pass filter.

Both band-pass and band-stop filters can be created from low-pass and high-pass filters via the corresponding arrangement as shown below:

band stop filter configuration
Band-stop filter construction: Summing low-pass and high-pass filter
band pass filter design
Band-pass filter construction: cascading low-pass and high-pass filter

On a related note, there exists a special form of band-stop filter called notch filter and it is defined as follow:

notch filter is a band-stop filter with a narrow stopband (high Q factor).

with Q factor is, in turned, defined as:

The Q-factor is the reciprocal of the fractional bandwidth. A high-Q filter will have a narrow passband and a low-Q filter will have a wide passband. These are respectively referred to as narrow-band and wide-band filters.

Frequency filters conversion

There are a total of four frequency filters and they can be combined with other electronics and one another to create a new filter. Their second order relationships are described by the following equations:

(1) Low-pass filter = ∫(Band-pass filter)

(2) Band-stop filter = X(t) – Band-pass filter

(3) Band-pass filter = ∫(High-pass filter)

For first order systems, derivations from Band-stop and Band-pass constructions permit the following:

(4) High-pass filter = Low-pass filter – Band-stop filter

(5) Band-pass filter = Low-pass filter (High-pass filter)

IMPOTANT: Anything that works in first order also works in second order.

First order active filters

For the first order filters, a resistor and capacitor bridge is employed. The use of feedback eliminates the need for inductors as used in first order passive filters.

Low-pass filter has the resistor near the source while high-pass filter has the capacitor. In high-pass filters, a small resistor might be included between the source and the capacitor to prevent overloading the capacitor.

Non-inverting low-pass filter
Non-inverting high-pass filter

The difference between inverting and non-inverting filters is the input terminal the input source is connected to. If Vin is connected to the inverting terminal, it’s an inverting filter.

Inverting low-pass filter
Inverting high-pass filter

In any cases, the feedback should always be negative for filters and amplifiers alike. Positive feedback will result in hysteresis circuits (Schmitt triggers).

Second order active filters

Second order filters offer more drastic attenuation (steep roll-off). The simplest kinds are based off Sallen-Key topology

Generic Sallen-Key topology

Second order filters are designed around a non-inverting amplifier with equal resistor and capacitor values. The specific values are determined by the cut-off frequency desired by the designer. As with first-order filters, low-pass filters have a resistor near the source and high-pass filters have a capacitor.

second order low pass filter
Second order active low-pass filter
second order high pass filter
Second order active high-pass filter
Second order universal active filter (Conglomerate filters)

The all the filters above are “section”, meaning, they standalone and are not dependent on any other filters. The opposite of section filters are “conglomerate” filters. Every component of the conglomerate filter must be in order for the entire filter to work correctly. They offer reduced circuitry at the cost of reliability due to high dependency on other components of the system.

At the core, the universal filter is one such conglomerate. Each output of the four op-amps provides a different second order filter behavior:

Notch-filter

2nd order high-pass filter

Band-pass filter

2nd order low-pass filter

The universal filter is based on cascading two inverting amplifiers blocks and two inverting integrators blocks with additional, second order feedback loops from each integrator back to the input of the amplifier furthest from it.

Second order universal active filter circuit

Tow-Thomas biquad filter is another conglomerate filter offering low-pass and band-pass characteristics depending on where the input is taken.

Read more

http://www.electronics-tutorials.ws/filter/band-stop-filter.html

https://en.wikipedia.org/wiki/Band-stop_filter

https://www.quora.com/What-is-the-difference-between-a-Low-pass-filter-and-Integrator-Circuit-Why-two-different-names

http://www.electronics-tutorials.ws/filter/filter_2.html (Passive low pass)

http://www.electronics-tutorials.ws/filter/filter_3.html (Passive high pass)

http://www.electronics-tutorials.ws/filter/filter_4.html (Passive band pass)

http://www.electronics-tutorials.ws/filter/filter_5.html (Active low pass)

http://www.electronics-tutorials.ws/filter/filter_6.html (Active high pass)

http://www.electronics-tutorials.ws/filter/filter_7.html (Active band pass)

http://www.electronics-tutorials.ws/filter/second-order-filters.html

http://www.learningaboutelectronics.com/Articles/Active-op-amp-bandpass-filter-circuit.php

https://en.wikipedia.org/wiki/Sallen%E2%80%93Key_topology

https://en.wikipedia.org/wiki/Electronic_filter_topology#Tow-Thomas_Biquad_Example

http://www.beis.de/Elektronik/AudioMeasure/UniversalFilter.html

Windows Phone’s music player error 8007003 fix

Some people are still getting this in 2017 and myself included. There are a few possible causes to this issue. I have narrowed down the list of likely culprits as follow:

The song itself can be corrupted.

The song can be in the wrong format.

There exists a duplicate of the song somewhere in Phone memory and SD card.

There exists a glitched object reference to a copy of the song stored in the cloud.

Path length of the file / scan depth limit.

Corrupted files

The first cause can be tested easily using “File” explorer app or another music player. If the song can be played at all then the file (at least its content) is not corrupted. In the event this is indeed the problem, replace the song with a fresh copy (playable on a different device) should do the trick.

Incompatible format

If the problem persists, try copy the song via USB cable connected to a Windows 8.1 and above PC. Any song that’s recognized as audio file by Windows and is incompatible to Windows Phone OS will be reformatted upon copying via USB connection. A dialog box will appear with this option.

Duplication conflict

The third and fourth causes are also quite simple to test. Simply rename the file and (possibly) the track title using a tag editor software such as Mp3tag. If the song works again, track down those duplicates and delete them. Then, check all playlists for any references to the song and delete them too.

Path length / Scan depth

Finally, the last addressable cause is path length. I have a fair bit of experiences working with Nodejs on Windows and I’m well aware of the path length limit of the OS. It is safe to assume that as Windows Phone is the younger sibling of Windows, it should possess the same limitation (and possibly worse).

Given how Groove Music, the default Microsoft’s music player, works on Windows, the “shortcut” reference of the song its scan function created in an app storage as lengthy as “C:\Users\<username>\AppData\Local\Packages\Microsoft.ZuneMusic_<random hash>\LocalState\Database” can potentially hit Windows Phone’s limit with just a little nudge.

In any cases, this is my problem and shortening the path length by moving all files up one level in the hierarchy did it for me. So, instead of SD/Music/Album/song.mp3, it’s SD/Album/song.mp3 after the move. I suspect it has more to do with arbitrary depth scan limit in the programming code and not the path length limit but meh, who knows what the interns at Microsoft did to produce such a broken piece of software.

At least it’s free and not full of fitness ads.

Memo: One-shot timer and op-amp filters

Integrators and Differentiators are basic building blocks of analog computers. They enable summation and subtraction operations (hence, the core component of them is called “operational” amplifier). For multiplication, multiple integrators are used in parallel, along with exponential and logarithmic elements (non-linear op-amp circuits), to achieve the effect via the following transformation:

ln(ab) = ln(a) + ln(b) = c

e^(c) = ab 

This is why analog multiplicators are expensive, costing up to $20 a pop.

All the circuits below require very specific values for their components. Changing the value of the components will do more than changing the properties of the output, it can cause instability and disrupt the circuit’s operation. As an oscilloscope is required to diagnose these circuits, some preset values that have been tested in the lab are also included in this memo for DIY projects at home.

Monostable multivibrator (one-shot timer)

Monostable multivibrator has one stable state and it will change to the unstable state for a period of time when a trigger pulse (negative edge) is introduced as input.

The circuit can be derived from astable multivibrator circuit; the only new addition is the grounded diode in parallel to the output capacitor. If all values are appropriate, connecting the diode will dampen all output and (negative) feedback generated by the powered astable multivibrator without any input. After this dampening characteristic has been achieved, negative edge trigger input can be introduced to complete the circuit.

The basic circuit is as seen below:

basic op amp monostable
Basic monostable multivibrator: R1 = 10K, R2 = 2.2K, R = 1K, C = 1uF
op amp monostable waveforms
Measuring the voltage behavior across the capacitor C yields a shark-fin waveform

The timing period T is the amount of time it takes for the circuit to return switch from unstable back to stable state. The timing period is given by

T = RC ln[1 / (1-B)]

where B is the regenerative feedback as described in Memo: Schmitt trigger. The units of the remaining variables are as follow:

T: seconds (s)

R: ohms (Ω)

C: farad (F).

Cheat sheet: when R1 = R2, the timing period T = 0.693 RC

Similarly, the charging period is the amount of time the circuit must wait before it can be triggered again. This is given by

T(charging) = RC ln[(1+B) / B]

In some circuits, an additional RC differentiator circuit can be connected to the input (sometimes, only a single 0.01uF capacitator is sufficient). The purpose of this extra circuit is to transform rectangular signal into trigger pulse signal as seen below

rc differentiator circuit
RC differentiator

The complete monostable circuit is as follow:

op amp monostable circuit
Final monostable multivibrator with RC differentiator
Integrator

Integrator functions like an average filter, it’s often used as a low-pass filter.

Inverting integrator: C = 0.01uF, R = 1K

The output of the integrator is given by

V_{{{\text{out}}}}(t_{1})=V_{{{\text{out}}}}(t_{0})-{\frac  {1}{RC}}\int _{{t_{0}}}^{{t_{1}}}V_{{{\text{in}}}}(t)\,\operatorname {d}t

or in Laplace domain, it is

Vout = -Vin/(sRC)

If the integrator starts from zero (no charge in the capacitor), the output is simply given by

-{\frac  {1}{RC}}\int _{{t_{0}}}^{{t_{1}}}V_{{{\text{in}}}}(t)\,\operatorname {d}t

where Vout(t0) represents the output voltage of the circuit at time t = t0.

Op-amp integrator suffers from the same frequency response limitation as other closed-loop op-amp circuits. It has a cut-off frequency at -3 dB and a decreased output at high frequencies. In addition to this, the integrator also has run-away output issue where it can drift to either power rail due to constant noises and it must be reset periodically to prevent this problem.

The drift is caused by any of the three conditions:

The input Vin has a non-zero DC component,

Input bias current is non-zero,

Input offset voltage is non-zero.

A more complex, grounded integrator circuit prevents this drift

100pxl
Grounded integrator circuit

A simple switch in parallel to the negative feedback capacitor allows resetting the integrator to zero.

For the grounded integrator circuit, the output is given by

V_{{{\text{out}}}}(t_{1})=V_{{{\text{out}}}}(t_{0})-{\frac  {1}{R_{{i}}C_{{f}}}}\int _{{t_{0}}}^{{t_{1}}}V_{{{\text{in}}}}(t)\,\operatorname {d}t

Differentiator

Differentiator, in contrast, is a high-pass filter. It has poor high frequency response and any sudden disturbance at the input will cause it to ring at natural frequency

Op-Amp Differentiating Amplifier.svg
Inverting differentiator: C = 1F, R = 1K

The transfer function of the above circuit is as follow:

V_{{{\text{out}}}}=-RC\,{\frac  {\operatorname {d}V_{{{\text{in}}}}}{\operatorname {d}t}}\,\qquad {\text{where }}V_{{{\text{in}}}}{\text{ and }}V_{{{\text{out}}}}{\text{ are functions of time.}}

or in Laplace domain:

Vout = -sVinRC

Bonus: Non-inverting integrator

Like closed-loop amplifiers, non-inverting integrators and differentiators circuits are easily achievable by switching GND and Vin. A possible circuit for non-inverting integrator is as shown below and it makes use of an RC passive low pass filter circuit at the non-inverting input.

integrater29
Non-inverting integrator: one extra passive low pass filter at the non-inverting input
Read more

https://en.wikipedia.org/wiki/Analog_computer

https://en.wikipedia.org/wiki/Monostable

http://www.electronics-tutorials.ws/opamp/op-amp-monostable.html

https://en.wikipedia.org/wiki/Integrator

https://en.wikipedia.org/wiki/Op_amp_integrator

https://en.wikipedia.org/wiki/Differentiator

https://en.wikipedia.org/wiki/Operational_amplifier_applications

http://www.electronics-tutorial.net/analog-integrated-circuits/op-amp-integrator/non-inverting-integrator/index.html

https://www.researchgate.net/publication/245316727_A_non-inverting_differentiator_using_a_single_operational_amplifier

Memo: Schmitt trigger

Hysteresis definition is as follow:

the phenomenon in which the value of a physical property lags behind changes in the effect causing it, as for instance when magnetic induction lags behind the magnetizing force.

The horizontal and vertical axes are input voltage and output voltage, respectively. T and −T are the switching thresholds, and and −M are the output voltage levels.

In asymmetric bipolar power supply (such as those created by elevating a virtual ground from unipolar power source), the hysteresis can be skewed along the horizontal axis of the above transfer function.

Schmitt triggers vs. Closed-loop amplifiers

It is easy to convert a closed-loop amplifier into Schmitt trigger by swapping the input terminals. Standard closed-loop amplifiers have negative feedbacks while Schmitt triggers have positive feedbacks as defined by Wikipedia:

In electronics, a Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier.

One important note when converting negative feedback comparators into Schmitt triggers is the direction of the output. As seen below, non-inverting amplifiers will yield inverting Schmitt triggers when the input terminals are swapped, and vice versa.

Non-inverting amplifier (negative feedback)
Inverting Schmitt trigger (positive feedback)

Fortunately, changing the output direction of a comparator circuit (any feedback) is quite simple. Swapping Vin and GND terminals inverses the output direction of the circuit.

Non-inverting Schmitt trigger, practically identical layout with the inverting counterpart except Vin and GND positions
Schmitt trigger’s characteristics

Schmitt triggers are commonly used for switch debouncing and noise filtering for digital signals. In digital circuits, noisy signals are often fed to a low-pass filter to create a smoother signal before passing through a Schmitt trigger to recreate the sharp digital signal. Despite its importance in digital circuitry, the trigger itself is an analog component and is sometimes omitted in digital circuit simulation libraries.

Due to open-loop nature of the circuit, the gain of Schmitt trigger is infinity. Impedance values follow normal op-amp characteristics.

The regenerative feedback refers to the portion coming out of the voltage divider and into the non-inverting input. It’s denoted with beta symbol and defined as follow:

B = R1 / (R1 + R2)

The switching thresholds are calculated as the regenerative feedback times the positive or negative supply rail voltage Vs as seen below

V_\mathrm{+} = \frac{R_1}{R_1+R_2} \cdot V_\mathrm{s}

Please note that despite the formula, in reality, the Vs value in this calculation experiences some voltage drops (around 15%) due to internal impedance; hence the switching thresholds might be lower than calculated.

Astable multivibrator (Relaxation oscillator)

With a few extra components (a capacitor and a resistor), a Schmitt trigger can be adapted into an astable multivibrator. From inverting Schmitt trigger, add an additional negative feedback using a resistor, a capacitor and ground to create the astable multivibrator.

Astable multivibrator adapted from inverting Schmitt trigger circuit

The multivibrator does not take in any input signal. When powered up, it creates a full-range square waveform across the op-amp’s output and a half-range waveform across the non-inverting input (some documents denote this waveform as reference voltage). At the same time, it creates a half-range ramp waveform across the capacitor.

Transient analysis of a comparator-based relaxation oscillator.

The time period of the multivibrator is given by

T = 2 RC ln[(1+B)/(1-B)]

with B is the regenerative feedback, R and C are the value of the resistor and the value of the capacitor across the negative feedback respectively.

The amplitudes of half-range voltages are calculated using the same formula as the switching thresholds of normal Schmitt triggers.

When using an asymmetric bipolar supply, the switching thresholds of the multivibrator will be skewed and it will produce waveform of adjustable duty cycles. The duty cycle is dependent on the offset; left offset produces shorter duty cycle and right offset produces longer duty cycle. However, the device can only accept so much power supply offsetting before it cannot operate (under load) or overloaded.

Read more

https://en.wikipedia.org/wiki/Schmitt_trigger

https://en.wikipedia.org/wiki/Switch#Contact_bounce

https://en.wikipedia.org/wiki/Relaxation_oscillator

https://en.wikipedia.org/wiki/Multivibrator

https://www.allaboutcircuits.com/textbook/semiconductors/chpt-8/positive-feedback/

 

Memo: Op-amp’s gain factor and noise problems

First, here’s a quick cheatsheet on closed-loop gain factor for inverting and non-inverting amplifiers. The gain of inverting amplifier is given by the resistance R2 across the feedback loop divided by the resistance R1 across the forward input.

A = R2/R1

Meanwhile, the gain of non-inverting amplifier is given by

A = 1 + R2/R1

as calculated in the previous note. Kirchhoff’s current law is applied.

Gain factor and cut-off frequency relationship

Cut-off frequency is not only affected by the properties of a given component but it is also dependent on the gain factor of the amplifier circuit. Higher gain amplifiers have lower cut-off frequencies and this can be charted as an exponential decay function.

To easier express this function in linear terms, the relationship is converted to logarithmic terms:

20 log(0.5) = -6.02 [dB]

with 0.5 is the approximated V/Vref value from experimentation.

On a side note, below are two commonly seen decibel functions in electronics for power and voltage respectively.

{\displaystyle G_{\mathrm {dB} }=10\log _{10}\left({\frac {1000~\mathrm {W} }{1~\mathrm {W} }}\right)=30.}

{\displaystyle G_{\mathrm {dB} }=20\log _{10}\left({\frac {31.62~\mathrm {V} }{1~\mathrm {V} }}\right)=30.}

Naturally, the gain factor for op-amps is expressed in terms of voltages (the second formula).

Differential amplifier

A useful circuit using op-amps to amplify and de-noise a weak signal is differential amplifier. The basic circuit uses one op-amp in the arrangement below:

V1 and V2 inputs are the same signal, one of which is inverted. This can be done using an inverting amplifier with gain factor of 1 (inverting unity gain amplifier) but this arrangement is subjected to high-frequency quirks as stated in the previous memo, especially phase shifting property.

If the inputs are identical and not phase-inverted, the output will be zero.

The output of this particular circuit is an amplified signal with transmission line noise suppressed. Note that the transmission line noise being suppressed is the one common on both inputs after the inversion. Noises occurred before inversion cannot be suppressed this way.

Instrumentation amplifier (three op-amps)

Normally, to ensure proper signal flow, the inputs are tunneled through two additional voltage followers (two more op-amps) in order to reduce the impedance. The full circuit (called “instrumentation amplifier) would then look like the following:

with all R values are the same except for Rgain.

Rgain can be of any value. It serves as a “common ground” connector and it also tweaks the voltage gain of the full circuit. Increasing the value of Rgain decreases the gain of the differential amplifier.

In reality, the gain of the above circuit can be tweaked further, following this function

{\frac {V_{\mathrm {out} }}{V_{2}-V_{1}}}=\left(1+{2R_{1} \over R_{\mathrm {gain} }}\right){R_{3} \over R_{2}}

Instrumentation amplifier (two op-amps)

An alternative instrumentation amplifier design using two op-amps can be seen below:

Though this setup saves on component costs, it does have a few disadvantages, notably, the lack of support for unity gain (not a problem for most scenarios but can be if the instrumentation amplifier is used solely for noise canceling).

Furthermore, the circuit is unbalanced. The leftmost amplifier increases the input slightly and introduces some signal delay. This unbalance leads to reduced noise canceling capability. The output can saturate if the common-mode noise of the input signal here is too high and race condition can lead to a much lower cut-off frequency (compared to three op-amps version).

The gain factor here is controlled by RG in the same manner as Rgain in the other circuit.

G = 1 + R2/R1 + (2*R2)/RG

Bonus: Choosing the base resistance

When calculating the resistance of an analog system, the first resistor (base resistor) is chosen as a compromise between power consumption and noise tolerance. Low resistance (or impedance for AC systems) allows more current draw. This is welcome when loads are concerned but it is a waste of energy when sensors are concerned. The higher the base resistance, the lower the power consumption will be.

On the other hand, high resistance circuits are more susceptible to noise. The relationship between resistance and noise is given by Johnson-Nyquist noise voltage function

{\overline {v_{n}^{2}}}=4k_{\text{B}}TR

where kB is Boltzmann constant 1.38 x 10^-23 [J/K], T is the absolute temperature in Kelvin [K], and R is the system’s resistance. In other words, a small increase in resistance increases in Johnson noise voltage by the power of two.

TL;DR:

Increase R, increase noise, decrease current consumption

Decrease R, decrease noise, increase current consumption

Choose the right compromise for the application.

Bonus: Using op-amp with a unipolar power source

Unipolar or single-rail power sources that only have GND and VCC terminals need to offset the ground terminal to create a -VCC source. This offset can be done using a voltage divider circuit in conjunction with a voltage follower. Be mindful that the with only half of the voltage range, the op-amp might experience unexpected floating values.

The voltage follower (or unity gain amplifier) must be connected in series to the middle point of the voltage divider in order to create a new, offset virtual ground. This eliminates the added impedance from the voltage divider, ensuring sufficient current draw power devices using the virtual ground.

For example, such a system of voltage divider and voltage follower can be employed to create +2.5V and -2.5V bi-polar supply from Arduino’s 5V and 0V unipolar supply. In this case, the op-amp will produce 5V (relative to the Arduino’s true ground) as HIGH signal and 0V as LOW signal. Inversely, it will see 0V from the Arduino as -2.5V (relative to the virtual ground) and 5V as +2.5V.

The previous section on choosing base resistance also applies here, and even more so with the halved voltage range doubling susceptibility to signal distortion.

Read more

https://en.wikipedia.org/wiki/Exponential_decay

https://en.wikipedia.org/wiki/Decibel#Examples

http://www.electronics-tutorials.ws/opamp/opamp_5.html

https://en.wikipedia.org/wiki/Instrumentation_amplifier

http://www.electronicdesign.com/power/what-s-difference-between-operational-amplifiers-and-instrumentation-amplifiers

https://en.wikipedia.org/wiki/Johnson%E2%80%93Nyquist_noise

http://www.talkingelectronics.com/projects/OP-AMP/OP-AMP-1.html

Memo: Op-amp’s analog characteristics

Operational amplifier (op-amp) possesses an open-loop gain factor A0 and a close-circuit gain factor A.

The negative terminal of the op-amp is called “inverting” terminal and the positive terminal is called “non-inverting”. In addition to two input terminals, there are two power terminal V+vcc and V-vcc.

The output Vout is calculated as

Vout = A * (V+in – V-in).

Ideal op-amp has the following characteristics:

Input impedance rin approaches infinity.

Meanwhile, output rout impedance approaches zero.

Unity gain amplifier

These characteristics see applications in voltage follower (also known as unity gain amplifier), which produces an output voltage equal to input voltage but with much lower impedance. Low impedance circuits allows more current draw than high impedance ones.

Voltage follower setup: a simple negative feedback loop without any resistance

This unity gain is possible because the gain factor used here is open loop

Vout / Vin = A/ (1+A0)

as Aapproaches infinity

Vout / Vin = 1

Gain of closed-loop amplifiers

In other cases, the gain is determined by the values of the voltage divider overlaying the feedback loop. For example

A non-inverting amplifier: negative feedback with voltage divider setup

In this case, the gain is determined using Kirchhoff’s law. Since Kirchhoff’s current law states that the same current must leave a node as enter it, and since the impedance into the (−) pin is near infinity, we can assume practically all of the same current i flows through Rf, creating an output voltage

{\displaystyle V_{\text{out}}=V_{\text{in}}+i\times R_{f}=V_{\text{in}}+\left({\frac {V_{\text{in}}}{R_{g}}}\times R_{f}\right)=V_{\text{in}}+{\frac {V_{\text{in}}\times R_{f}}{R_{g}}}=V_{\text{in}}\left(1+{\frac {R_{f}}{R_{g}}}\right).}

Finally, we have the following closed-loop gain (applicable only to the above circuit)

{\displaystyle A_{\text{CL}}={\frac {V_{\text{out}}}{V_{\text{in}}}}=1+{\frac {R_{f}}{R_{g}}}.}

High frequency characteristics

The gains and formulas above are only applicable for low frequency circuits. In high frequencies, the following will happen:

Above certain frequencies, voltage gain and current gain factors become diminished in inverse proportion to frequency increase.

The output signal becomes lagged behind the input signal (phase shifting) as the op-amp cannot react fast enough to the frequency changes.

Very high input amplitude (peak-to-peak voltage swing of electrical signal) causes distortions and the higher the frequency, the lower this upper amplitude threshold is (distortion appears at lower amplitudes at high frequencies).

Cut-off frequency is the frequency at which the voltage gain is 1/sqrt(2) of the low frequency gain, meaning, the power at the output is effectively halved in voltage follower setup. The cut-off frequency is unique to each op-amp component. It can be easier determined using an oscilloscope as the frequency at which the phase shift is 180o.

Textbook definition:

The frequency where the voltage falls to 0.707 of its intended value is the cutoff or -3 dB frequency, fc. (Gain in decibels = 20∙log(0.707) = -3dB.)

As a result of these special high frequency characteristics, op-amps can be unsuitable for high frequency applications.

Read more

https://en.wikipedia.org/wiki/Operational_amplifier

http://www.learningaboutelectronics.com/Articles/Voltage-follower

http://www.ecircuitcenter.com/Circuits/op_bandwidth1/op_bandwidth1.htm

https://www.researchgate.net/post/Please_tell_me_Why_the_cutoff_frequency_is_taken_for_3dB_and_not_other_values_like_1_or_2_db