OSC

OSC is a content format developed at CNMAT by Adrian Freed and Matt Wright comparable to XMLWDDX, or JSON.[2] It was originally intended for sharing music performance data (gestures, parameters and note sequences) between musical instruments (especially electronic musical instruments such as synthesizers), computers, and other multimedia devices. OSC is sometimes used as an alternative to the 1983 MIDIstandard, when higher resolution and a richer parameter space is desired. OSC messages are transported across the internet and within local subnets using UDP/IP and Ethernet. OSC messages between gestural controllers are usually transmitted over serial endpoints of USB wrapped in the SLIP protocol

A short movie on OSC.

Some Theory:

Transistors theory

The invention of the transistor in the 1950’s changes the electronic world for ever. The transistor is a so called ‘semiconductor’ and is capable of amplifying signals. The transistor has a Collector (C), a base (B) and an emitter (E). It can be seen as a current controlled switch. A small current from the base to the emitter creates a bigger current (Ic) from the collector to the emitter. Take a look at this video-page, for a detailed explanation.

Imagine the transistoras the following setting: a large tube connected to a big pool of water. Halfway the tube there is a valve that can be changed position by a small tap on the side. Check figure 1.

If there’s no base current (ib=0) the transistor is closed and there’s no collector-current. If the base current Ib is increasing (we turn the small tap on the side – Ib > 0), the water-flow (=current or Ic) will increase as well. Check figure 2. If the Ib is maximum, the collector current Ic is at its maximum as well. The proportion between Ib and Ic is called the Hfe. This number represents the amount of current amplification.

Some transistor package examples.

Some circuit examples

EMITTER FOLLOWER

MORE HISTORICAL INFO:

Timed Processes

When movement is detected, this thing needs to go on for three seconds after which it should not be triggered for ten seconds. But if nothing happens in two minutes, it should trigger by itself. How?

Question posed by a random colleague student

The global behaviour of an installation based on a microcontroller, often includes timed processes. For instance, after a trigger, the input is blocked for a certain amount of time; if nothing happens for a while, generate an event; if within a certain time span a second trigger is sensed, change the behaviour; etc.

The most fundamental blink example suggests that timing can be controlled with a delay() function. However, the delay() has a fundamental issue which renders it useless in all of the situations described above: the program will proceed to the next line of code only when the wait is finished. In other words, during a delay(), all processing comes to a standstill. The function delay() could as well have been called holiday(). Therefore, ditch the delay().

The blink without delay and debounce examples introduce an approach to timing using the millis() function. It is an approach in which the passing of time is measured based on an onboard clock. When multiple overlapping time units are involved, this approach tends to become complex and difficult to manage. An alternative solution can be found in using the millisDelay statement, which is part of an external library. This library can be found and installed through the Manage Libraries… menu option.

Detecting State Change

In order to connect an action to sensor input, it is important to be clear about what is the difference between a sensor measurement—e.g. a value from digitalRead()—and a state changement—e.g. when a button is pressed, while before it wasn’t. Sensor measurement produces a stream of values, while a state change should be able to detect the moment at which a button is pressed. A stream of values is what is produced in the Digital Read Serial example.

In order to detect a state change, the code needs to be extended in such a way that the current state can be compared with the previous. When considering that what is defined in the loop() routine represents a single lifespan of the loop, something needs to be handed to the collective unconsciousness—or, in terms of Arduino code, a global variable—before the current run of the loop dies in order to be retained.

Here the order of things can be explained as follows. At the moment the button is pressed—nowClosed is true—while before it wasn’t—beforeOpen is true as well—the if statement checking these two booleans will execute the first section. The LED turns on and the serial monitor prints “switch closed”. At the moment the button is released, momentarily the else if sees it’s conditions met and will execute the connected block. All other cases are neither of these two options and are disregarded.

The last line—beforeOpen = !nowClosed—although it appears a bit cryptic is the crucial bit of information that becomes available the next time the loop runs: beforeOpen will become true if nowClosed is not true. We could consider this the will of the current loop that dictates the heritage of the next loop.

const int ledPin = 13;
const int switchPin = 2;
bool beforeOpen = true;


void setup() {
  pinMode(switchPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
}

void loop() { // loop is (re)born
  bool nowClosed = digitalRead(switchPin) == 0;
  if (nowClosed && beforeOpen) {
    digitalWrite(ledPin, HIGH);
    Serial.println("switch closed");
    delay(5); // lazy debounce
  }
  else if (!nowClosed && !beforeOpen) {
    digitalWrite(ledPin, LOW);
    Serial.println("switch open");
    delay(5); // lazy debounce
  }
  beforeOpen = !nowClosed; // update global variable for next loop
} // loop dies

Temporarily Block Sensor Input

The state change introduced in the previous example, will be used here to connect specific actions. When the button is pressed, it will activate a timer that blocks the detection of the on state for a certain amount of time. Releasing the button will have no meaning in this context and the action connected to that can be removed.

The timer is created using the millisDelay.h library, and a delay is created using the millisDelay ledDelay statement. This ledDelay becomes a reference to a mechanic that is running in the background, that can measure time. A trigger is sent using ledDelay.start(LED_time), where LED_time specifies the amount of milliseconds it will take before ledDelay returns the trigger, signaling the end of the delay. This end trigger needs to be queried using the ledDelay.justFinished() statement, which will become true when this is the case. Until this happens, input by the button will be blocked.

#include <millisDelay.h>

const int ledPin = 13;
const int switchPin = 2;
bool beforeOpen = true;
bool blocked = false;
int LED_time = 2000;
int switchCount = 0;

millisDelay ledDelay;

void setup() {
  pinMode(switchPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  bool nowClosed = digitalRead(switchPin) == 0;
  if (nowClosed && beforeOpen && !blocked) {
    Serial.print("switch closed ");
    switchCount += 1;
    Serial.println(switchCount);
    digitalWrite(ledPin, HIGH);
    ledDelay.start(LED_time);
    blocked = true;
//    delay(5);
  }
//  else if (!nowClosed && !beforeOpen) {
//    Serial.println("switch open");
//    delay(5);
//  }
  if (ledDelay.justFinished()) {
    digitalWrite(ledPin, LOW);
    blocked = false;
  }
  beforeOpen = !nowClosed;
}

Auto-Trigger

A second millisDelay is added in order to automatically trigger the process—following the requirements posed in the top section, although for testing the time for this is reduced to 10 seconds.

When the Arduino starts up, this second delay, which refers to the autoMode flag, is triggered. Now there are two options, either the button is pressed before ten seconds pass, or isn’t. In the first case the autoDelay will be stopped; only when the button was pressed autoDelay.isRunning() will be true. Since later on in the code we will check whether the autoDelay.justFinished(), the autoReset flag is used to indicate that a reset has happened because of an activation, instead of time running out.

In the second case, the autoMode flag is raised so an activation can take place. The overview below shows how these flags are raised and lowered either because of a button pressed or the ten seconds auto trigger.

#include <millisDelay.h>

const int ledPin = 13;
const int switchPin = 2;
bool beforeOpen = true;
bool blocked = false;
bool autoMode = false;
bool autoReset = false;
int LED_time = 2000;
int auto_time = 10000;
int switchCount = 0;

millisDelay ledDelay;
millisDelay autoDelay;

void setup() {
  pinMode(switchPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
  autoDelay.start(auto_time);
}

void loop() {
  bool nowClosed = digitalRead(switchPin) == 0;
  if (nowClosed && beforeOpen && !blocked || autoMode) {
    digitalWrite(ledPin, HIGH);
    ledDelay.start(LED_time);
    if (autoDelay.isRunning()) {
      autoDelay.finish();
      autoReset = true;
    }
    switchCount += 1;
    if (Serial) {
      Serial.print("switch closed ");
      Serial.println(switchCount);
    }
    blocked = true;
    autoMode = false;
  }
  if (ledDelay.justFinished()) {
    digitalWrite(ledPin, LOW);
    blocked = false;
    autoDelay.start(auto_time);
  }
  if (autoDelay.justFinished()) {
    if (!autoReset) {
      autoMode = true;
    }
    autoReset = false;
  }

  beforeOpen = !nowClosed;
}

RMS calculation

RMS Voltage Calculator (/calculators/rms-voltage- calculator)

This RMS Voltage calculator helps to 4nd the RMS voltage value from the known values of either peak voltage, peak- to-peak voltage or average voltage. It calculates the RMS voltage based on the given equations.

RMS (Root Mean Square) Voltage (Vrms)

Every waveform’s RMS value is the DC-equivalent voltage. Let’s take an example, if the RMS value of a sine wave is 10 volts then it means you can deliver the same amount of power via DC source of 10 volts. Do not confuse in between Average voltage and RMS voltage, as they not equal.

Peak Voltage (Vp)

Peak voltage of a sine wave is measured from the horizontal axis (which is taken from the reference point 0) to the crest (which is the top or maximum voltage level) of the waveform. Peak voltage shows the amplitude of the waveform.

Vp = √2 * Vrms

By, this formula we can get the value Vrms of with respect to peak voltage.

Vrms = 0.7071 * Vp

Peak-to-Peak voltage (Vpp)

The difference between maximum peak voltage and minimum peak voltage, or the sum of the positive and negative magnitude of peaks is known as the Peak-to-Peak voltage.

Vpp = 2√2 * Vrms

By, this formula we can get the value of Vrms with respect to peak-to-peak voltage.

Vrms = 0.35355 * Vpp

Average voltage (Vavg)

The average value of a sine wave is zero because the area covered by the positive half cycle is similar to the area of the negative half cycle, so these value cancel each other when the mean is taken. Then the average value is measured by the half cycle only, generally we take the positive half cycle part for measuring.

The average voltage de4ned as “the quotient of the area under the waveform with respect to time”.

Vavg = 2√2/π * Vrms

By, this formula we can get the value of Vrms with respect to peak-to-peak voltage.

GROUNDING

Grounding has a number of functions, a.o. safety, zero reference etc.. The combination of these functions can cause problems in the the audio chain when groundloops occur. This problem will be discussed in the underlying PDF.

OP-AMPS

Op Amps are easy to use building blocks for electronic circuits and consist of a number of transistors and fets packed in an IC.

Here some examples of circuits that can be build with Op Amps:

FET

FET stands for Field Effect Transistor. It doesn’t behave like a BJT, it doesn’t amplify a base current. Instead a voltage on the gate (that hardly demands current) opens or closes the current in the source-drain. Hence, the input impedance of a FET can be very high (GOhm). It resembles therefore the behaviour of an electronic tube.

The PDF on FET’s

Transistors

This chapter deals with a very important active component used in electronics. Since the implementation of the BJT (Bipolar Junction Transistor), sizes of electronic devices and computers could be shrinked enormously. e.g. In a modern CPU chip a few billion transistors are integrated. Basically a transistor is a (base)current amplifier. It can be used as a switch, a current amplifier , a voltage amplifier and many more things.

A PDF ON TRANSISTORS:

See also here.

Passive RC-filters

How does a basic RC filter work?

If we know that a capacitor act’s as a blockade (huge resistor) for DC ánd that the capacitor is a conductor (low resistance) for AC, we can make voltage ‘dividers’ that changes resistance and thus output voltage, at different frequencies.

If we combine a resistor and a capacitor in a series connection (the voltage divider for example), the behavior of that circuit changes because a time-constant is introduced.

R x C = time constant [seconds]

Low Pass Filter (LPF)

Take a look at the figure below. If we connect DC on the input of this RC-circuit, the capacitor will act a ‘infinite’ big resistor. The output will be equal to the input. If we change the input to AC, the resistance of the capacitor will change – it becomes lower. This means, the amplitude of the output will go down as well.

Passive Low Pass Filter

If we would give this filter a frequency ‘sweep’ (= change the frequency from low to high values), the voltage parallel to the capacitor (=output) will drop.

The frequency at which the output is half of the value of the input (this equals -3dB) is called the ‘cutoff frequency, F -3dB

High Pass Filter (HPF)

If we change the position of the R and the C in this simple circuit, the behavior will change as well. Take a look at the picture below.

Passive High Pass Filter

If we start with DC as an input voltage (frequency = 0Hz), the capacitor acts as a very high resistance again. The output will therefor be low. Adding a sweep from low to high frequency will increase the output value. We introduced a High Pass Filter.

Digital Electronics

The fundamental digital ports

In the digital-electronics world it all is about ‘ones’ and ‘zeroes’. It’s about ‘Yes’ or ‘No’. There is no ‘Maybe’! Computers work with digital data that only consists of bits and combination of bits, called bytes. A bit can only have two values: ‘0’ or ‘1’. In electronics this means 0V or 5V (TTL). Since the development of mobile technology, nowadays lots of computers (e.a. phones) work with 3.3V logic.

The fundamentals of digital electronics starts with the different logic ports called NOT, AND, NAND, OR, NOR , XOR and XNOR. With combinations of logic ports, complex logic function’s can be created. If a lot of these ports are combined (millions…) in one chip, microprocessors and computers are created.


AND port

Let’s start with the basic port called AND. An AND port can be seen as two switches that are connected in series. See the figure below, the left side. If both switches ‘a’ and ‘b’ are OFF (also referred to as 0), the lamp (the circle with the cross) will not light up – it’s also OFF (= 0). If switch ‘a’ is ON (= 1), and switch ‘b’ is OFF (= 0), the lamp is still OFF. We can put these different values in a so called truth table, see the tabel in the middle.
On the right side the European symbol of an AND port is shown.


OR port

An OR-port is a combination of two switches connected parallel. See the left side of the figure. This gives another truth-table. If only one switch ‘a’ or ‘b’ is in the ON position ( = 1), the outcome will be 1. See the figure below:


XOR-port

The XOR-port is also called an ‘Exclusive OR’ port. This port consists of two switches both with two poles. The setup of this two switches is that with both of you can switch the light ON or OFF. This circuit is often applied in rooms where you can switch the light ON at the door and switch the same light OFF on the other side of the room – it’s practical. Take a look at the figure below. In the XOR-port the light is only ON when both switches ‘a’ and ‘b’ are in the oposite position. In case of the picture below the switches are in the same position (upside down) – thus the result is “0”.


A port overview

All the ports mentioned above also have their ‘INVERSE’. This means the opposite of the values in the normal state. For an AND the inverse is called a NAND. An OR port inverted version is called a NOR and a XOR inverted is a XNOR.

There are also ports that only invert – so called inverters. A logic ‘one’ on the input creates a logic ‘0’ on the output and vice versa – always the inverse. There are even ports that do not change the state of a signal. In other words, a logic ‘0’ on the input creates also a logic ‘0’ on the output. These ports are called buffers.

And below an overview of all the symbols of the logic ports. In Europe and the USA they use different kind of symbols – for the same logic ports. This can be confusing.


Binairy counting and resolution

With the logic ports mentioned above a lot of great functions can realized. Like decimal counters, dividers, binary counters, shift registers and much more.

So what is counting in the digital world? How can we count and make big numbers with with only 2 bits? First of all we need to use the binary counting system. This system only has two symbols (binary) a ‘0’ and a ‘1’. Our decimal system has 10 symbols (dec). We start with 0 and count till 9. After 9 we combine the first two symbols 1 and 0 , making 10. The same mechanism we apply to binary counting. Starting with 0, 1 and the combine the first two: 10. After that we get 11 and then we combine again: 100.

Take a look at the table below. On the left side the decimal numbers 0 – 15. In the middle the equivalent binary numbers starting with 0000 (=0 decimal) and ending with 1111 (= 15 decimal). So with a 4 bit ‘resolution’ (= 4 bits = 24) we can make numbers from 0 to 15 (equal to 16 numbers, zero included). If we double the amount of bits (=8 bits = 28) we can make numbers between 0 and 256. The higher the resolution, the higher number-range can be made. If we talk about 8 bits, we could also call this one byte.

When we take a closer look at the binary series in the table above, you can see that the most right ‘bit’ constantly changes between 0 and 1. We also call this bit the LSB (= Least Significant Bit). The next row is changing every two numbers: 00 11 00 11 … (division by two). The third row is again divided by two: 0000 1111 0000 1111. The fourth again, etc etc. The row on the most left side we call the MSB (most significant Bit). When we create ‘dividers’ with the logic ports, we can create binary counting. Take a look at the figure below.

The upper row is the LSB, changing constantly between 0 and 1. The row below (A1) is divided by two resulting in 00 11 00 11… If we look at the numbers on the right side, from top to bottom, we see 0000 (=dec 0). One pulse to the left we see 0001 (=dec 1). Completely on the left side we see 1111 (=dec 15).

There are a lot of different digital ‘chips’ available with already pre-made logic functions. The most common range is the 7400 range and the 4000 range. The 7400-series is so called Transistor Transistor Logic (TTL) and can only with +5V (=1) and 0V (=0). The HEF4000 series is based on MOS (Metal Oxide Semiconductor) and can handle a voltage range between 3 and 18V (depending in the specifications).

More information about digital electronics, check this.