About Serial,USART, UART, RS232, SPI, I2C, TTL..how to relate  each other?


 



Serial is an umbrella word for all that is "Time Division Multiplexed", to use an expensive term. It means that the data is sent spread over time, most often one single bit after another. All the protocols you're naming are serial protocols.

UART, for Universal Asynchronous Receiver Transmitter, is one of the most used serial protocols. It's almost as old as I am, and very simple. Most controllers have a hardware UART on board. It uses a single data line for transmitting and one for receiving data. Most often 8-bit data is transferred, as follows: 1 start bit(low level), 8 data bits and 1 stop bit(high level). The low level start bit and high level stop bit mean that there's always a high to low transition to start the communication. That's what describes UART. No voltage level, so you can have it at 3.3 V or 5 V, whichever your microcontroller uses. Note that the microcontrollers which want to communicate via UART have to agree on the transmission speed, the bit-rate, as they only have the start bit's falling edge to synchronize. That's called asynchronous communication.
For long distance communication (That doesn't have to be hundreds of meters) the 5 V UART is not very reliable, that's why it's converted to a higher voltage, typically +12 V for a "0" and -12 V for a "1". The data format remains the same.

RS-232 (which you actually should call EIA-232, but nobody does.)
The timing dependency is one of the big drawbacks of UART, and the solution is USART, for Universal Synchronous/Asynchronous Receiver Transmitter. This can do UART, but also a synchronous protocol. In synchronous there's not only data, but also a clock transmitted. With each bit a clock pulse tells the receiver it should latch that bit. Synchronous protocols either need a higher bandwidth, like in the case of Manchester encoding, or an extra wire for the clock, like SPI and I2C.
SPI (Serial Peripheral Interface) is another very simple serial protocol. A master sends a clock signal, and upon each clock pulse it shifts one bit out to the slave, and one bit in, coming from the slave. Signal names are therefore SCK for clock, MOSI for Master Out Slave In, and MISO for Master In Slave Out. By using SS (Slave Select) signals the master can control more than 1 slave on the bus. There are two ways to connect multiple slave devices to one master, one is mentioned above i.e. using slave select, and other is daisy chaining, it uses less hardware pins(select lines), but software gets complicated.

I2C (Inter-Integrated Circuit, pronounced "I squared C") is also a synchronous protocol, and it's the first we see which has some "intelligence" in it; the other ones dumbly shifted bits in and out, and that was that. I2C uses only 2 wires, one for the clock (SCL) and one for the data (SDA). That means that master and slave send data over the same wire, again controlled by the master who creates the clock signal. I2C doesn't use separate Slave Selects to select a particular device, but has addressing. The first byte sent by the master holds a 7 bit address (so that you can use 127 devices on the bus) and a read/write bit, indicating whether the next byte(s) will also come from the master of should come from the slave. After each byte receiver must send a "0" to acknowledge the reception of the byte, which the master latches with a 9th clock pulse. If the master wants to write a byte the same process repeats: the master puts bit after bit on the bus and each time gives a clock pulse to signal that the data is ready to be read. If the master wants to receive data it only generates the clock pulses. The slave has to take care that the next bit is ready when the clock pulse is given. This protocol is patented by NXP(formerly Phillips), to save licensing cost, Atmel using the word TWI(2-wire interface) which exactly same as I2C, so any AVR device will not have I2C but it will have TWI.
Two or more signals on the same wire may cause conflicts, and you would have a problem if one device sends a "1" while the other sends a "0". Therefore the bus is wired-OR'd: two resistors pull the bus to a high level, and the devices only send low levels. If they want to send a high level they simply release the bus.
TTL (Transistor Transistor Logic) is not a protocol. It's an older technology for digital logic, but the name is often used to refer to the 5 V supply voltage, often incorrectly referring to what should be called UART.
mean Transistor-Transistor-Logic and has its level for logical zero near 0V and for logical one near 5V. Often any 5V logic is called TTL, although most circuits nowadays are built as CMOS. Today there are also many circuits that work at 3.3V, which is no longer TTL.
With respect to the internal levels the levels on the RS-232 line are inverted, +12V corresponds to logical low and -12V corresponds to logical high, which can be confusing.
For describing the data format one usually shows the logical signal. When the line is idle it is high. A transmission starts with a low start bit, the data bits, an optional parity bit and one to two stop bits (logical 1). This is called asynchronous transmission, because the start bit synchronizes the data for each byte separately.

 



The best projects to try with the Raspberry Pi

        Raspberry Pi has floored the tech community yet again, with the launch of the raspberry pi zero.The newest member of the Pi family, the Zero costs £4 and measures just 65mm across while still remaining just as capable as earlier models. 
With similar specs to the Raspberry Pi B+, the latest iteration of the hobby computing line will allow users to make their microcomputing projects even more micro without sacrificing performance.It's not just experienced hobbyists and hackers who have made excellent use of the Pi.
We’ve rounded up all the best things you can do with a Raspberry Pi to give budding makers some ideas. Most of these are designed with the larger old-school models in mind, but many of them can be adapted (or even improved) to feature the Raspberry Pi Zero.
Below we take a look at of our favourite Raspberry Pi projects to date:
 Virtual Desktop for Raspberry Pi
Thanks to RealVNC's partnership with the Raspberry Pi Foundation, the latest versions of the Raspbian distro all include pre-installed versions of VNC Server and VNC Viewer.
This can be used to create a virtual desktop, which is excellent for providing a graphical desktop interface to Pis that wouldn't otherwise have one, such as headless devices running IoT or robotics projects.To activate this, first ensure that VNC Server is set up and enabled on the target Raspberry Pi - you can find out how to do that here. Then, use either your Raspberry Pi's terminal or an SSH connection to run the 'vncserver' command.Note down the IP address and display number that VNC Server shows, and input that information into VNC Viewer. After that, you should be free to remotely operate the Pi as if it had a full graphical desktop.
Stratux
Raspberry Pi is the heart of hundreds of useful projects, but as this gadget shows, it can also help you satisfy your idle curiosity, too.Stratux is a project devised to tell you information about the various aircraft in the sky around you, and it’s wonderfully simply to build.
By receiving and translating the ADS-B broadcasts from airplanes in the sky nearby, Stratux gives you information such as the planes’ altitudes, speeds, locations and callsigns.
It runs on the Raspberry Pi 3 Motherboard, and the decoding software can be downloaded onto a Micro SD card that you simply slot into the chip. This Page has a few alternative lists of parts, ranging in cost from a budget $95, to a common $145 package, up to a $260 list that’s quick to build.
Xbox Zero
The Raspberry Pi Zero is so small that it could fit into just about anything, as this hack demonstrates. Programmer and maker Terence Eden was lucky enough to get his hands on one of the devices, and with a bit of tinkering, was able to put it inside an original Xbox controller.
Using the RetroPie emulation software, he was able to make a retro games console that's entirely contained in the controller. The controller itself loops back into the Pi, so all you need to play your favourite old-school games is an HDMI display and a power source. There's even enough space to fit in a portable power pack for those that want to take it out and about.

 Tea-Pi
A quarter-finalist in the 2014 Hackaday Prize, this project by James Pavur is designed to automate the process of making a nice loose-leaf cuppa.
Tell the Raspberry Pi for how long and at what temperature you want your tea brewed, and the Pi will activate the connected kettle, measure the temperature, and lower the tea in with a servo motor. 
Once the tea leaves have been in for the desired time, it’ll lift them out again, ready to be made into a lovely cup of tea.
Raspberry Tor Router
Anonymising network Tor is beloved of privacy advocates everywhere, as well as Dark Web users with more nefarious purposes in mind. 
              This project turns the Raspberry Pi into a router to send all your network traffic through Tor, rather than just browser sessions. Best of all, you can even slap a battery pack into it to take it wherever you go!
Pi Multi-Room Music Player
Buying a bespoke multi-room sound system can be costly - but thanks to Jezsinglespeed at Instructables, you can now do it yourself for under £100. It’s a simple four-step project, which is perfect if you want to introduce children the power of the Raspberry Pi.
All you need is one wireless streamer, wireless receivers (no. depends on how many rooms) and of course your trusty Pi.
The Pi Musicbox software is used to make the magic happen and the results are just as good as any off the shelf product.
Get Whatsapp on your Raspberry Pi
Whatsapp has become one of the most popular cross-platform messaging service with over 600 million users. Now you can send messages directly from the Pi thanks to a tutorial from emmeshop.
All you need to do is to install the latest version of Raspbian, enter a few lines of code and confirm registration using your mobile.
Customised picture frame
Digital picture frames are becoming increasingly common but there are ways you can customise them. If you’ve got a spare monitor or an existing digital picture frame with a USB connection, the chances are you can connect your Raspberry Pi to it with a USB-HDMI adaptor.
Cameron Wiebe has come up with some scripts which allow the Pi to automatically download pictures from Deviant Art everyday and display them in a slideshow.

Treasure Box
Another superb project to work on with kids is the Treasure Box which, can be opened with facial recognition.
Tony Dicola has created comprehensive instructions to bring this to life. You’ll need to invest in a Raspberry Pi camera, servos and also box.
Power Cat Feeder
We all love our animals, but sometimes an automated pet feeder sounds like a pretty nifty thing to have around the house.

That's what David Bryan did when he found himself going out of town without a cat-sitter, contemplating just leaving a big bowl of food out.With his Power Cat Feeder project, however, he could make sure they didn't overeat before going hungry. Presumably, too, it can be used to feed any animal - including humans.

Industrial Instrumentation and Control 

 An Introduction to the Basic Principles:

In part one of this instrumentation and control (I & C) series, we'll go over the fundamental terminology and concepts used when working with industrial plants.
This is the first of a series of technical articles about instrumentation and control. In this series, we will discuss the basic concepts and principles that govern the operation of industrial plants. Concepts associated with measurements of flow, level, temperature and pressure, electronics and pneumatics instrumentation, control loops, PID control, and others will be addressed.

What is a measurement instrument?

A measurement instrument is a device capable of detecting change, physical or otherwise, in a particular process. It then converts these physical changes into some form of information understandable by the user.

Figure 1: An example of a measurement instrument

When the switch is closed, the resistor generates heat, increasing the temperature of the liquid in the tank. This increase is detected by the measurement instrument and shown on the scale of that instrument.
We can get the information on the physical changes in a process using direct indication or a recorder.

Indication

This is the simplest form of measurement; it allows us to know the current state of the variable.

Figure 2: Monitoring a variable via indication

Recorder

A device that can store data allows us to observe the current state of the variable and how it behaved in the past. A recorder provides us with the history of the variable.
Elements of a Measurement Instrument
Measurement instruments consist primarily of the following parts:
  • Sensor: This element is a device that experiences changes in its physical properties as a result of changes in the process it's measuring.
  • Amplifier / Conditioner: Changes detected by the sensor may be very small, so they must be amplified and then conditioned such that they can be properly displayed.
  • Display: The measured data should be presented in an understandable way. This can be done using a graduated instrument or an electronic display. Sometimes the display additionally acts as a recorder in order to convey the measurement's history or trends.

Figure 4:  Elements of a measurement instrument

Usually, the measurement information generated by an instrument must be sent to a control center (or control room) that is physically distant from the instrument. In general, this information must conform to established specifications.

Figure 5:  Measurement information is sent from the instrument to the control room

When an instrument has the ability to send information, we call it a transmitter (XMTR).
Classification of Instruments
There are different classifications for measurement instruments. We can classify them, for example, as in-field instruments or panel instruments. The in-field instrument is installed close to the process or measuring point. It must be physically robust if it will be exposed to harsh environmental conditions. Panel instruments are in a controlled-environment room (often a clean space with air conditioning and controlled humidity).
Another classification is pneumatic instruments vs. electrical/electronic instruments.
Pneumatic Instruments
As the name suggests, these are devices that are powered by air.
One of the advantages of these instruments is that they do not consume electricity, so they can be used in areas where it would be dangerous or inconvenient to use electrical power. They work with a single variable, are imprecise instruments, are affected by vibrations and temperature changes, and have high maintenance requirements. The output signal of the transmitters is between 3 and 15 psi, and the maximum transmission distance is approximately 200 meters.

Figure 6:  Basic diagram of a pneumatic instrument

Electrical / Electronic Instruments

Electronic instruments can be divided into three general categories: analog, smart analog, and digital.

Analog:

  • Output signal: 4 - 20 mA
  • Transmission distance: 1200 m (typical)
  • Data for one variable is transmitted
  • Good accuracy
  • Easy maintenance

Figure 7:  Basic diagram of an electronic instrument (XMTR)

Smart Analog:

  • Characterization of the sensor as measuring temperature, static pressure, etc.
  • Excellent accuracy
  • Self-diagnosis (i.e., the sensor can analyze problems in its own functionality)
  • One variable

Digital:

  • Multiple instruments can use a single cable
  • Transmission of multiple values for each instrument (process variables, calibration, diagnostics, range)
  • Distance: approximately 1900 m without a repeater
  • Data capacity is influenced by the mode of transmission (cable, fiber optic, wireless)

Figure 8:  Digital transmitters

General Concepts

Range: The region between the limits within which a variable is measured. It indicates the minimum and maximum values that limit the region. The range is expressed with two numbers, e.g., 10 to 20 °C, 10 to 150 V, 0 to 100%
Span: Calculated as the maximum value of the range minus the minimum value of the range. Span is expressed with a single number in process units, e.g., 120 °C, 30 V, 150 liters per second.
Elevation: If the lower limit of the range is a positive value, this lower limit is the elevation. Example: If the range is 50 °C to 200 °C, we can say that the elevation is 50 °C or 33.3% of the span.
Depression (also referred to as suppression): If the lower limit of the range is negative, the absolute value of this lower limit is the depression. Example: If the range is -10 °C to 80 °C, we can say that the depression is 10 °C or 11.1% of the span.
Overrange: When a device is calibrated to operate within a certain range but may be subjected to values above or below that range, then it requires a protection mechanism to prevent damage to the instrument or to prevent the indicator from exceeding its upper or lower limit. When the measured values are above the maximum value, we have positive overrange. When the measured values are below the minimum value, we have negative overrange.

Figure 9:  Examples of range, span, elevation, and depression

Error: The difference between the measured value and the actual (or expected, or desired) value of a physical variable. The error can be positive or negative. When the measured value is greater than the actual value, the error is positive. When the measured value is less than the actual value, the error is negative.
                        If measured > actual, error > 0
                        If measured < actual, error < 0
The error can be expressed
  • in engineering units (e.g., °C, psi)
  • as a percentage of the span (e.g., +/- 3% of the span)
  • as a percentage of the measurement (e.g., +/- 5% of the measurement)
Reference value: In a general sense, this refers to the actual, expected, or desired value of a variable. In the context of a feedback control system, the measured value is fed back and subracted from the reference value in order to generate the error signal.
Accuracy: A number that defines the limits of the error. When we say that an instrument has an accuracy of 0.1% of the span, this means that anywhere within the range, the readings do not differ from the actual value by more than 0.1% of the span.
An Example
For a better understanding of the concepts expressed above, consider the following example.
We have an oil tank where we are required to continuously measure the temperature. The operating conditions for this process are as follows:
  • Minimum temperature: -10 °C
  • Maximum temperature: 90 °C
  • The measurement accuracy must be 1% of the span or better
  • The temperature measurement must be displayed locally and remotely

Figure 10: Our example system
 
First, we must select a measuring instrument that allows us to measure the temperature of the liquid in the tank. Since the information should be available locally and remotely, we will choose a temperature transmitter.
This transmitter must have the following characteristics:
  • Range: -10 °C to 90 °C
  • Span: 90 °C - (-10 °C) = 100 °C
  • Depression: 10 °C or 10% of the span
  • Accuracy: 1% of the span = 1% × 100 °C = 1 °C
    • This accuracy of 1% ensures that, in each measurement or temperature reading, variation or errors will not exceed +/- 1 °C
On an additional note, we must ensure a proper relationship between the range and the standardized transmitter output. To calibrate the instrument, we must associate the minimum value of the range (-10 °C) with the minimum value of the output (4 mA) and the maximum value of the range (90 °C) with the maximum value of the output (20 mA).

Transimpedance amplifier       

  In electronics, a transimpedance amplifier (TIA) is a current-to-voltage converter, most often implemented using an op-amp. The TIA can be used to amplify the current output of Geiger–Müller tubes, photo multiplier tubes, accelerometers, photo detectors and other types of sensors to a usable voltage. Current-to-voltage converters are used with sensors that have a current response that is more linear than the voltage response. This is the case with photodiodes where it is not uncommon for the current response to have better than 1% linearity over a wide range of light input. The transimpedance amplifier presents a low impedance to the photodiode and isolates it from the output voltage of the operational amplifier. In its simplest form a transimpedance amplifier has just a large valued feedback resistor, Rf. The gain of the amplifer is set by this resistor and because the amplifier is in an inverting configuration, has a value of −Rf. There are several different configurations of transimpedance amplifiers, each suited to a particular application. The one factor they all have in common is the requirement to convert the low-level current of a sensor to a voltage. The gain, bandwidth, as well as current and voltage offsets change with different types of sensors, requiring different configurations of transimpedance amplifiers.
                                  VOUT = -(IIN × RF)

Difference b/w  USART, UART, RS232, USB, SPI, I2C, TTL 

UART - Universal Asynchronous Receiver Transmitter:
  • It is one of the most used serial protocols.
  • Most controllers have a hardware UART on board.
  • It uses a single data line for transmitting and one for receiving data.
  • Most often 8-bit data is transferred, as follows: 1 start bit(low level), 8 data bits and 1 or 2 stop bit(high level).
  • The low level start bit and high level stop bit mean that there's always a high to low transition to start the communication.That's what describes UART.
  • No voltage level, so you can have it at 3.3 V or 5 V, whichever your microcontroller uses.
  • Note that the microcontrollers which want to communicate via UART have to agree on the transmission speed, the bit-rate, as they only have the start bit's falling edge to synchronize.That's called asynchronous communication.
  • For long distance communication (That doesn't have to be hundreds of meters) the 5 V UART is not very reliable, that's why it's converted to a higher voltage, typically +12 V for a "0" and -12 V for a "1".
  • The data format remains the same. Then you have RS-232 (which you actually should call EIA-232, but nobody does.)
  • The timing dependency is one of the big drawbacks of UART, and the solution is USART, for Universal Synchronous/Asynchronous Receiver Transmitter.
USART - Universal Synchronous/Asynchronous Receiver Transmitter:
  • This can do UART, but also a synchronous protocol.
  • In synchronous there's not only data, but also a clock transmitted.
  • With each bit a clock pulse tells the receiver it should latch that bit.
  • Synchronous protocols either need a higher bandwidth, like in the case of Manchester encoding, or an extra wire for the clock, like SPI and I2C.
SPI - Serial Peripheral Interface:

  • It is another very simple serial protocol.
  • A master sends a clock signal, and upon each clock pulse it shifts one bit out to the slave, and one bit in, coming from the slave.
  • Signal names are therefore SCK for clock, MOSI for Master Out Slave In, and MISO for Master In Slave Out.
  • By using SS (Slave Select) signals the master can control more than 1 slave on the bus.
  • There are two ways to connect multiple slave devices to one master, one is mentioned above i.e. using slave select, and other is daisy chaining, it uses less hardware pins(select lines), but software gets complicated.

I2C - Inter-Integrated Circuit (pronounced "I squared C"):

  •  It is also a synchronous protocol, and it's the first we see which has some "intelligence" in it; the other ones dumbly shifted bits in and out, and that was that. I2C uses only 2 wires, one for the clock (SCL) and one for the data (SDA). 
  • That means that master and slave send data over the same wire, again controlled by the master who creates the clock signal.
  • I2C doesn't use separate Slave Selects to select a particular device, but has addressing.
  • The first byte sent by the master holds a 7 bit address (so that you can use 127 devices on the bus) and a read/write bit, indicating whether the next byte(s) will also come from the master of should come from the slave.
  • After each byte receiver must send a "0" to acknowledge the reception of the byte, which the master latches with a 9th clock pulse. If the master wants to write a byte the same process repeats: the master puts bit after bit on the bus and each time gives a clock pulse to signal that the data is ready to be read.
  • If the master wants to receive data it only generates the clock pulses. The slave has to take care that the next bit is ready when the clock pulse is given.
  • This protocol is patented by NXP(formerly Phillips), to save licensing cost, Atmel using the word TWI(2-wire interface) which exactly same as I2C, so any AVR device will not have I2C but it will have TWI.
  • Two or more signals on the same wire may cause conflicts, and you would have a problem if one device sends a "1" while the other sends a "0".Therefore the bus is wired-OR'd: two resistors pull the bus to a high level, and the devices only send low levels.If they want to send a high level they simply release the bus.
TTL - Transistor Transistor Logic:

  • It is not a protocol. It's an older technology for digital logic, but the name is often used to refer to the 5 V supply voltage, often incorrectly referring to what should be called UART.
Source : Electrical Engineering Stack Exchange 

Sleep Mode

Sleep mode is a power-saving state that is similar to pausing a DVD movie. All actions on the computer are stopped and any open documents and applications are put in memory. You can quickly resume normal, full-power operation within a few seconds. Sleep mode is basically the same thing as “Standby” mode.
The Sleep mode is useful if you want to stop working for a short period of time. The computer doesn’t use much power in Sleep mode.

Hibernate

The Hibernate mode saves your open documents and running applications to your hard disk and shuts down the computer, which means once your computer is in Hibernate mode, it uses zero power. Once the computer is powered back on, it will resume everything where you left off.
Use this mode if you won’t be using the laptop for an extended period of time, and you don’t want to close your docum