You are on page 1of 31

MEDICAL EQUIPMENT

LAB III & IV

30 OCT 2014 M.Attia

Serial vs Parallel communication

Serial communication
It

is the process of sending data one bit at a


time, sequentially, over a communication
channel or computer bus.

Parallel communication
where

several bits are sent as a whole, on a


link with several parallel channels.

Basic types of serial interfaces:


Synchronous interfaces have the data
transmitted with its timing relative to an explicit
clock, which is also provided. The classic
example of this is SPI, I2c.
Asynchronous interfaces have the timing
encoded in the data stream itself.

For

"serial ports" and related standards such as


RS232, the timing of the word is relative to the
start bit ,and stop bit. And the receiver merely
samples the line at the right intervals thereafter.

UART

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.

UART (continue)

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.

RS-232

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 1" and -12 V for a 0". The
data format remains the same.

SPI

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

SPI (continue)

I2C

I2C (Inter-Integrated Circuit, pronounced "I squared


C") is also a synchronous protocol.
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 (continue)

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 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.

MPU-6050

MPU-6050 (continue)

The MPU-6050 is the worlds first


integrated 6-axis MotionTracking device
that combines
a

3-axis gyroscope,
3-axis accelerometer,
Digital Motion Processor (DMP) is able to
do complex calculations with the sensor
values.

all in a small 4x4x0.9mm package.

MPU-6050 (continue)

An accelerometer is a device that measures proper


acceleration ("g-force").
Proper acceleration is not the same as coordinate
acceleration (rate of change of velocity).
For example, an accelerometer at rest on the
surface of the Earth will measure an acceleration
g= 9.81 m/s2 straight upwards.
By contrast, accelerating due to the gravity of Earth
will measure zero.

MPU-6050 (continue)

The gyroscope is used to measure angular velocity


which is defined as the rate of change of angular
displacement which specifies the angular speed
(rotational speed) of an object and the axis about
which the object is rotating.
The SI unit of angular velocity is radians per second,
although it may be measured in other units such as
degrees per second, degrees per hour, etc.
Angular velocity is usually represented by the
symbol omega (, rarely ).

MPU-6050 (continue)

The direction of the angular velocity vector is


perpendicular to the plane of rotation, in a
direction which is usually specified by the right-hand
rule.

MPU-6050 (continue)

It is very accurate, since it contains 16-bits analog to


digital conversion hardware for each channel.
Therefor it captures the x, y, and z channel at the
same time.
Also, it is accurate because you have the 3 axis
gyro and 3 axis accelerometers on single chip so
you do not need to align them.

MPU-6050 (continue)

For power supply flexibility, the MPU-6050 operates


from VDD power supply voltage range of
2.375 V - 3.46 V.
Additionally, the MPU-6050 provides a VLOGIC
reference pin (in addition to its analog supply pin:
VDD), which sets the logic levels of its I2C interface

MPU-6050 (continue)

Connection with arduino UNO


Connect

the sensor VDD & VIO with Arduino 3.3 V

pin.
Connect the sensor GND with Arduino GND pin.
Connect the sensor SDA with Arduino SDA (pin A4).
Connect the sensor SCL with Arduino SCL (pin A5).

MPU-6050 (continue)

Understanding raw values of


accelerometer and gyrometer

MPU-6050 (continue)

MPU-6050 (continue)

The scale of each depends on the sensitivity settings


chosen
Digital-output

triple-axis accelerometer with a


programmable full scale range of 2g, 4g, 8g and
16g
Digital-output X-, Y-, and Z-Axis angular rate sensors
(gyroscopes) with a user-programmable full-scale
range of 250, 500, 1000, and 2000/sec

Integrated 16-bit ADCs enable simultaneous


sampling of gyros & accelerometers.

MPU-6050 (continue)

The output scale for any setting is [-32768, +32767]


for each of the six axes.
The default setting in the I2Cdevlib class is

+/- 2g for the accel


+/- 250 deg/sec for the gyro.
2
32768
250
32768

for accelorometer
for gyroscope

MPU-6050 (continue)

See Arduino Code Example

Wireless Module Serial UART

Wireless Module Serial UART (continue)

This is a serial UART wireless module, 200 m


distance range and 433 Mhz frequency.
This module is very similar to zigbee but much
cheaper, we call it poor man Zigbee.
It is easy to use with micro-controller/Arduino
through TX and RX pins, just like Zigbee and using
serial commands.

Wireless Module Serial UART (continue)

Features
Serial

UART, Can work directly with your Microcontroller or Arduino TX/RX.


Easy to use (as easy as Zigbee)
3.3V-5V operation so it can operate directly with
USB power.
Default 9600 baud. Can operate at higher speed
but with the expense of more error and shorter
range.

Wireless Module Serial UART (continue)

Pin Definition
1.

Power, 3.3 V to 5 V. (this pin is marked by white


square)
2. Gnd.
3. RX
4. TX
5. PIN5 is the AT Control mode, Pull up to high or NC
will make module work as normal, When connect to low,
it will enter the AT Command mode. ( High level enter
AT mode)

Wireless Module Serial UART (continue)

How to use with Arduino and Code


Connect

wireless module Pin1 to Arduino VCC


Connect wireless module Pin2 to Arduino GND
Connect wireless module Pin3 (RX) to Arduino
digital pin 1 (TX)
Connect wireless module Pin4 (TX) to Arduino
digital pin 0 (RX)
Pin5 not connected

SoftwareSerial Library

The Arduino hardware has built-in support for serial


communication on pins 0 and 1 (which also goes to
the computer via the USB connection).
The SoftwareSerial library has been developed to
allow serial communication on other digital pins of
the Arduino, using software to replicate the
functionality (hence the name "SoftwareSerial").
It is possible to have multiple software serial ports
with speeds up to 115200 bps.

Wireless Module Serial UART (continue)

See Arduino Code Example

You might also like