3a_arduino

Topic 3a: Sensors


Humans survive throughout history by using their senses to react with the surrounding environment. This can be seen in our daily life by seeing people preparing for the coming winter. As humanity progresses, sensory elements embedded in humans' body are copied to electrical and electronic devices. The application of sensors can be seen in traffic lights, toasters, cars, etc.

Definition

A sensor is a device that responds to a physical stimulus such as heat, light, sound, pressure, magnetism, or a particular motion and transmits a resulting impulse for measurement or operating a control.

(Merriam Webster)

In short, a sensor is a device that detects and responds to particular measurable changes. Changes can be any physical quantity like temperature, resistance, force, pressure etc. Up to this moment, humans have not invented sensors that are used for immeasurable changes beyond physical quantity.

Basic sensors:

1. Potentiometer


Definition

An electrical device that changes its internal resistance when moved to a specified point; most commonly found in electronic control panels.

(Engineering Dictionary)

Common use of potentiometer is in Audio Signal and Volume Control because the application do not involve high voltage as efficiency of potentiometer is low.

Mechanics

A potentiometer uses the concept of a voltage divider. A potentiometer is a resistor of known or unknown resistance along which a contact is placed, often called a slider or wiper. As the slider moves from one end to the other, the value of the resistance between contact 1 and 2 changes. The same happens at the same time between 2 and 3.

As a result, the output voltage across contact 2 and 3 changes.

Application

Potentiometers are rarely applied in to control high power applications. Instead they are used for analog signals. An everyday application which can be seen is the radio volume and frequency dial, which are controlled using a rotary potentiometer. Tube televisions used potentiometers to adjust the contrast and brightness.

Arduino


Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists and anyone interested in creating interactive objects or environments.

— The Arduino Homepage

The Arduino board allows the user to program a microcontroller using the Arduino programming language. The Arduino board can be self-constructed to fulfill one's needs or purchased ready to run.

Sensors and Arduino

A typical Arduino board has six Analog and 14 Digital input/ output ports (I/O ports). Multiple sensors and indicators (eg: LEDs, liquid crystal displays (LCDs), speakers) can be connected to these ports.

The Arduino Analog port as an input reads the voltage across the sensor and then converts it to a 10 bit value ranging from 0 to 1023. This information can be sent to the serial ports to which the Arduino is connected to.

A basic Arduino code example:
  int analogPort = A0;          // analog sensor is connected to port A0
  int analogReading = 0;        // reading at port A0

  void setup()                  // this method is called once
  {
    Serial.begin(9600);         // initialize the serial port with baudrate 9600
    pinMode(analogPort, INPUT);
  }
  
  void loop()                   // this method is called repeatedly
  {
    analogReading = analogRead(analogPort);
    Serial.println(analogReading);
    delay(100);                 // a delay is added to prevent overload
  }

The code above reads the value of the sensor (eg: potentiometer, microphone, temperature sensor, etc) and converts it to a 10 bit number from 0 to 1023. The setup() method is run once to set the ports to INPUT mode or OUTPUT mode.

The loop() method is called repeatedly. The value of analogReading is overwritten with that of the Analog reading at port analogPort. The value is shown at the Serial Monitor.

vvvv


vvvv us a hybrid graphical/textual programming environment for easy prototyping and development. It is designed to facilitate the handling of large media environments with physical interfaces, real-time motion graphics, audio and video that can interact with many users simultaneously

-vvvv.org

vvvv allows the user to use 'nodes' - basic building blocks to make visualizations. This is useful to display data graphically.

vvvv and Arduino

The Arduino board uses a serial interface to communicate with the PC. vvvv's RS232 node is able to communicate with a COM port to retrieve the data being sent by the Arduino board.

Arduino to vvvv example:

There are four primary components for vvvv to receive data from an Arduino board

  • the Arduino board setup and circuit
  • the Arduino source code
  • the vvvv patch
  • the RegExpr node

The vvvv patch shown here uses an RS232 node to communicate to the COM port 6. The value is then converted to a String, and split according to the predefined token (a linebreak in this case, Ascii 10). The value is then 'cleaned' to remove unwanted spaces. The value is then passed on to the RegExpr nodes. The function of the RegExpr node is to extract information between predefined expressions, which can be assigned using the HErr Inspektor.

Here the tokens used are <poti1> -value- </poti1> for the left RegExpr and <poti2> -value- </poti2> for the right node. This must correspond with what is written in the Arduino source code. The values are then filtered to remove Null values, and converted from String to type Value.

This example can be further expanded to receive signals from additional inputs by declaring more inputs in the Arduino source code, and adding more RegExpr branches with different expressions.

My project "SlideShow"

The SlideShow

This is my project showing slide show where i used VVVV patch and Arduino and Two potentiometer to control the slideshow.

Arduino and VVVV_patch

The Arduino has to be connected and the code has to be uploaded for the patch to work correctly. Two potentiometers are connected as Analog inputs at ports A0 and A2. Please visit the Arduino website for tutorials on how to setup a potentiometer.

The picture aboves shows the circuit setup.

To make the white boxes appear as pictures, the first input of the FileTexture must be RightClicked. Select a number of pictures which is the same as the number of Pillow nodes used. This will fill the pictures.

You can download a video showing a working slideshow here.

2 Temperature Sensor


Temperature is the measure of kinetic energy of particles of a substance. This is however difficult to directly measure. Therefore temperature sensors are designed to indirectly measure the temperature by measuring a property which is proportional to temperature, such as the Resistance Temperature Detectors (RTD) which measures the change of voltage across a resistance.

Mechanics

Temperature sensors are divided into two categories:

1. Contact Sensors

Contact sensors use contact to measure the temperature of an object or medium. This type of sensors use the concept of (thermal equilibrium) to determine the temperature. The heat flow between the sensor and the object is then monitored.

Examples of contact sensors are:

Resistance Temeprature Detectors (RTDs)

RTDs use an electrical approach to measure the temperature, using the correlation of temperature and resistance. Using an electrical approach allows an easy set up of this sensor to a computer system. These sensors are applied due to their high accuracy but are unable to withstand high temperatures (~700°C) which damage the outer layer. At low temperatues however, the sensors are accurate and reliable.

RTDs are further divided into two types:

  • the traditional RTD measures the current across a metal to determine the temperature. Collisions hinder the movement of electrons as the kinetic energy of molecules increase.
  • a thermistor utilizes a semiconductor sensor to deduct the temperature.
Thermocouples

Thermocouples are the most widely used temperature sensor used in the industry. This sensor also uses an electrical approach similar to the RTD.

As the name suggests, a thermocouple compares the conductivitiy of two wire materials at a given temperature. At lower temperatures the difference of conductivity becomes less noticeable thus making thermocouples unreliable at low temperatures (less than -150°C).

Bimetallic Thermometers

These sensors compare the expansion of two metals, usually copper and steel. The expansion of the two different materials which possess distinct expansion coefficients cause the strip of metal to deflect. The deflection is proportional to the temperature. The strips of metals are wound into coils which are applied in thermostats.

2. Noncontact Sensors

Noncontact sensors such as optical pyrometers measure radiated waves (visible light or infra-red) which is emitted from an object or another reference point.

Example Patch

To get a better feeling of the shown sensors (potentiometer and temperatur sensor) a littel patch was created in the side projects. See temperatur_led_poti for more details.

3 Acceleration Sensor


Acceleration sensors also known as accelerometers are found in many devices and play an important role in stabilising a body. They can be found in many household devices such as smartphones and video game devices. This electromechanical device is able to detect static acceleration due to the earth's gravity, and thus used for detecting movement and vibrations.

Mechanics

Acceleromaters do not measure acceleration but proper acceleration. Proper acceleration or g-force acceleration is the weight experience by a body in the frame of reference of the sensor. An accelerometer resting on the earth's surface will measure g=9.81 m/s² upwards due to its weight. In free fall it will measure 0.

An accelerometer is basically a body of mass on a spring which pushes the feder backwards when it is accelerated. The displacement is measured to calculate the proper acceleration. In commercial devices the motion of the body is converted into an electric input signal by using piezoceramics.

The pictures shows the combination of two elements: an accelerometer and a potentiometer, that forms a linear accelerometer. The body of mass is connected to the wiper of the potentiometer. When the body of mass experiences positive or negative acceleration, it shifts from left to right or vice versa. This results in a change of voltage along the potentiometer.

The sensor can be placed vertically or horizontally. When both are applied, rotation can be calculated.

Application

Accelerometers are used in an array of fields to measure movement, rotation, and vibration.

Sport Science

Accelerometers can be used to analyze body movement to improve an athlete's performance and also help understand the human anatomy. Sensors are placed in a balloon with dehydrating substance to absorb condensation. The acceleration detected by the sensor is stored and transferred to a computer for analysis.

These sensors can also be placed in soccer balls to analyze the movement of the ball. In archery small sensors are placed on arrows to analyze the movement, acceleration and flight.

Vibration Analysis

Accelerometers are used domestically and also in the industry for detecting vibrations. A sensor can be placed outside of a wall, on which an air conditioning unit is mounted. Air conditioning units The image above shows a comparison of vibrations given off by two different air conditioning units.

This approach can also be applied for machines in the industry.

Example Patches

Preperation

At first we need an acceleration sensor. We know that in nower days nearly every smartphone contains at least one.

Connection

To begin with we will start a connetion between a smartphone and the VVVV software.

OSCDecoder * To do so we use a vvvv-node called OSCDecoder.
* This node needs a port and a protocol (UDP in this case) as input.


OSC Software

OSC-software

Before we can connect our smartphone we also need a software that is able to transfer the acceleration data to the computer.
In this case I used OSC Touch for android. But you could use any other OSC software, too.
To build up the connection you have to insert the ip-adress of your pc and the previosly entered port into the software.


normalization step

Normalization

After we have the connection, we will get the output data of our acceleration sensor out of the OSCdecoder node.
Before we can use that data we will first filter some of the data points because we do not need all of them. Therefore we use the S+H node that is connected to the OnReceive of our OSCdecoder node.
Then we normalize the values due to the standard acceleration of g=9,81 m/s^2 so that we get values from -1 to 1. This can easily realized by dividing the data with 9,81.


mapping step

Mapping

Now we use a map node to map the range of -1 to 1 to the the values between -0,25 and 0,25.
That will give us a better control of the values if the phone is rolled.


output

Ouput

To get the a usefull output we at first use a damper node to prevent the data to jump from one value to an new one and get a smooth shift instead.
The unzip node is used to split the values that we get. We have one connector for the x-axis one for the y-axis and one for the z-axis.
In the first example we only need the x-axis.
Now we want to recognize the roll of the smartphone to the left or to the right so we create a Threashold that must be overcome to get an output.
To shirnk the senibility a little bit we use a Counter node that gives an output every time it has counted to 10 and is jumping back to 0.

By labeling the output nodes Turn left and Turn right we will enable them to be displayed on the resulting node if we import our patch later on into another patch.

The basis of the patch was taken by the book Prototyping Interfaces.

To see the whole patch klick here.


Slide-Show

My first example contains a slide show.
This example was inspired by the v4tutorial.


Import Files At first we need to import some pictures. Therefore we use the FileTexture node. For later use we count the amount of imported Elements and we connect the Texture node with the Pillow node to use them as input.
The Pillow node is used to get a smooth fade out on the edges of the pictures.


Import Files Then we include the previously created patch into one Accelerometer_X-Roll_node node that provides us the two outputs: Turn_left and Turn_right
We connect this two outputs to a Counter node that later on will:
-count up every time we turn right and
-down every time we turn left.

The Counter counts till infinity so that there is no jump back to the starting point. This is because the jump back would cause some ugly artifacts in the slide show.
We want to use this counter to get the position in the slide show. Threfore we have to divide by the number of imported Elements which we counted previously.
The resulting number is connected to an Oscillater node.
The oscillater node will enable a soft switch between the pictures later on in the slide show.


Transform and render We use a CircularSpred node to create a circle out of the imported pictures.
To make the circle look good we use some input values to change the x-rotation, with and height. To get the amount of Elements we use the count node from above.
The output is then tranfered to the Tranform node which will provide a nice presentation in the end.
The Group node is used to get the right order in which the pictures are shown.
Finaly we use a Renderer node to display what we have created. Therefore we of cause need a Camera node, too.
The inital distance of the camera is set so that only one Picture at a time is shown on the renderer.

If you now turn your smartphone left and right you are able to slide through the pictures.
To see the whole patch klick here.
To download the whole patch klick here. 4v slide show patch


Box-Transform

perperation For Preperation we will use a simply modified patch.
Here we need more than one axis so we create an output node for every axis to use them later on.


Box For this example I used an existing patch called Fancy Boxes that was created by:

Jonathan Wieland: jonathan.wieland@uni-konstanz.de
and Marcel Borowski: marcel.borowski@uni-konstanz.de.


mapping But before we can use that patch we need to compute the output of our Accelerometer_XYZ-Value_node node to get usefull values.
So we first invert the values by multiplying with -1.
If you read the previous preperation step you know that we mapped the value range of -1 to 1 to the new range from -0.25 to 0.25. Now that we will use a renderer and its range goes from -1 to 1 again we have to change the mapping back.
Our resulting values are now in the range of -1 and 1 and out of the x and y axis.


input change In the last step we now have to use our values instead of the mouse input. So we connect our two input values to the Vector node.

Now we can navigate through the boxens by tilting our smartphone.

To see the whole patch klick here.
To download the whole patch klick here. 4v box transform patch


Presentation

References

*Prototyping Interfaces. Interaktives Skizzieren mit VVVV**, Mainz 2013 (Prototyping Interfaces)
*http://prototypinginterfaces.com/

3a_arduino.txt · Zuletzt geändert: 2018/12/03 09:43 (Externe Bearbeitung)