0% found this document useful (0 votes)
249 views

Arduino FDP PPT PDF

The document discusses the Arduino IDE and programming environment. It states that the Arduino language is based on C/C++ and is case sensitive. Programs in Arduino are called sketches which must be saved in the sketchbook directory. The Arduino IDE uses concepts like sketches, the sketchbook directory, and sketches are saved with a .ino file extension.

Uploaded by

Apurv Gaikwad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
249 views

Arduino FDP PPT PDF

The document discusses the Arduino IDE and programming environment. It states that the Arduino language is based on C/C++ and is case sensitive. Programs in Arduino are called sketches which must be saved in the sketchbook directory. The Arduino IDE uses concepts like sketches, the sketchbook directory, and sketches are saved with a .ino file extension.

Uploaded by

Apurv Gaikwad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

Arduino IDE

• The Arduino language

is based on C/C++.

• It links against AVR


Libc and allows the
use of its functions
• • Code
Code is
is case
case sensitive

sensitive
• Statements are
commands and must
end with a semi­colon
• Comments follow a //
or begin with /* and
end with */
See: http://arduino.cc/en/Guide/Environment for more information

Arduino IDE : Important Icons

Presented By: Mr. Shridhar Dudam 25


Sketch and Sketchbook

� Programs in Arduino called as sketches


� Sketches must saved in the directory.
� Arduino IDE uses the concept of a sketchbook:

� A standard place to store programs (or sketches).


� IDE automatically
IDE automatically creates
creates directory
directory for for the
the
sketchbook.
� Sketches were saved with a .ino file extension.

Presented By: Mr. Shridhar Dudam 26


Arduino IDE

• The Arduino language

is based on C/C++.

• It links against AVR


Libc and allows the
use of its functions
• • Code
Code is
is case
case sensitive

sensitive
• Statements are
commands and must
end with a semi­colon
• Comments follow a //
or begin with /* and
end with */
See: http://arduino.cc/en/Guide/Environment for more information

Arduino IDE : Important Icons

Presented By: Mr. Shridhar Dudam 25


Sketch and Sketchbook

� Programs in Arduino called as sketches


� Sketches must saved in the directory.
� Arduino IDE uses the concept of a sketchbook:

� A standard place to store programs (or sketches).


� IDE automatically
IDE automatically creates
creates directory
directory for for the
the
sketchbook.
� Sketches were saved with a .ino file extension.

Presented By: Mr. Shridhar Dudam 26


Arduino IDE : Sketch Structure

Arduino Software Architecture

� Bootloader is the
hardware's software
� bootloader provides
services such as
firmware upload and
serial monitoring.
serial monitoring.
� Firmware is the user's
software.
� Arduino Tool Chain
� Avr­gcc
� Avr­g++
Presented By: Mr. Shridhar Dudam � Java Virtual Machine 28
Arduino Programming Environment

� Arduino uses Object Oriented Programming.


� Arduino is programmed with C and C++.
� All Arduino libraries are made using C++ in
order to be easily reusable
� The native
The native library
library is
is designed
designed for
for a
a very
very
elementary and global purpose.
� Arduino programs can be divided in
� Structure
� Values (variables and constants)
� Functions.
Presented By: Mr. Shridhar Dudam 29
Structure (1)

� From global conditional control structures to


more specific ones.
� Basic Structure
� setup()


� loop()
loop()

� Control Structures (Conditional Statements)


� if , if...else and switch case
� for, while and do... while
� break and continue
� return

� goto

Presented By: Mr. Shridhar Dudam 30


if …. else statement

Presented By: Mr. Shridhar Dudam 31


Switch case and break

Presented By: Mr. Shridhar Dudam 32


Loop statement : for loop

� Syntax

� example

Presented By: Mr. Shridhar Dudam 33


While loop structure

� Syntax

� Example

Presented By: Mr. Shridhar Dudam 34


do … while loop structure

� Syntax

� Example
Example

Presented By: Mr. Shridhar Dudam 35


Structure : Operatores

Arithmetic Operators Comparison Operators


= (assignment operator) == (equal to)
+ (addition) != (not equal to)
­ (subtraction) < (less than)
* (multiplication) > (greater than)
/ (division) <= (less than or equal to)
% (modulo) >= (greater than or equal to)

Bitwise Operators Compound Operators


& (bitwise and) ++ (increment)
| (bitwise or) ­­ (decrement)
^ (bitwise xor) += (compound addition)
~ (bitwise not) ­= (compound subtraction)
<< (bitshift left) *= (compound multiplication)
>> (bitshift right) /= (compound division)
%= (compound modulo)
&= (compound bitwise and)
|= (compound bitwise or)
Presented By: Mr. Shridhar Dudam 36
Structure : Operatores

Boolean Operators Pointer Access Operators


&& (and) * dereference operator
|| (or) & reference operator
! (not)

Presented By: Mr. Shridhar Dudam 37


Values: Variables

Presented By: Mr. Shridhar Dudam 38


Values: Variables

Presented By: Mr. Shridhar Dudam 39


Values: Constants

� HIGH | LOW
� INPUT | OUTPUT | INPUT_PULLUP

� LED_BUILTIN
� true | false
� integer constants
integer constants
� floating point constants

Presented By: Mr. Shridhar Dudam 40


Values : Type Conversion

� Type conversion is the process that changes


an entity data type into another.
� Type conversion can be implicitly done or
explicitly made.

� Explicit Type Conversion
� char()
� byte()
� int()
� word()
� long()
� float()
Presented By: Mr. Shridhar Dudam 41
The Scope Concept

� The scope can be defined


as a particular property of
a variable.
� A variable can be global
and then is visible and
usable everywhere
usable everywhere in in the
the
source code.
� But a variable can also be
local, declared inside a
function, for instance, and
that is visible only inside
this particular function.
Presented By: Mr. Shridhar Dudam 42
Qualifiers

� Qualifiers are the keywords that are used to change


the processor's behavior considering the qualified
variable.
� static
� When you use the static qualifier for a variable inside a
f uncti on, this
function, thi s makes
mak es the
th e variable
variabl e persistent
persistent between
bet ween two
two
calls of the function.
� volatile
� When you use the volatile qualifier in a variable declaration
statement, this variable is loaded from the RAM instead of
the storage register memory space of the board.
� const
� The const qualifier means constant.
Presented By: Mr. Shridhar Dudam 43
Functions (1)

� Digital I/O � Math


� pinMode() � min()
� digitalWrite() � max()
� digitalRead() � abs()
� constrain()

� Analog I/O
� map()
� analogReference() � pow()
� analogRead()
� sqrt()
� analogWrite() ­ PWM
� Trigonometry
� Due & Zero only � sin()
� analogReadResolution() � cos()
� analogWriteResolution()
Presented By: Mr. Shridhar Dudam
� tan() 44
Functions (2)

� Advanced I/O � Characters


� tone() � isAlphaNumeric()
� noTone() � isAlpha()
� isAscii()
� shiftOut()
� isWhitespace()


� shiftIn()
shiftIn()

� isControl()
isControl()

� pulseIn() � isDigit()
� isGraph()
� Time � isLowerCase()
� millis() � isPrintable()
� isPunct()
� micros()
� isSpace()
� delay()
� isUpperCase()
� delayMicroseconds() � isHexadecimalDigit()
Presented By: Mr. Shridhar Dudam 45
Functions (3)

� Random Numbers
� randomSeed()
� random()
� Bits and Bytes

� lowByte()
� highByte()

� bitRead()

� bitWrite()

� bitSet()

� bitClear()

� bit()
Presented By: Mr. Shridhar Dudam 46
Arduino UNO: GPIO

� 14 Digital pins used as Input/ Output port pins

� Referred to as 0,1,2 …… 13
� 6 analog input pins can be used as digital pins,

� Referred to as A0, A1, ….. A5



� Library Functions:
Library
� pinMode(), digitalWrite(), and digitalRead()
� Some pins have specialized functions:
� Serial: 0 (RX) and 1 (TX).
� External Interrupts: 2 and 3

� PWM Outputs: 3, 5, 6, 9, 10, and 11

� SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).

� LED: 13.
Presented By: Mr. Shridhar Dudam 47
pinMode()

� Configures the specified pin to behave either


as an input or an output.
� Syntax: pinMode(pin, mode)
� Parameters:
� Pin
Pin :: pin
pin number
number whose
whose mode
mode you
you wish
wish to
to set
set
� Mode : INPUT, OUTPUT, or INPUT_PULLUP.
� Example
� pinMode (11, OUTPUT)

Presented By: Mr. Shridhar Dudam 48


digitalWrite()

� If the pin has been configured as an OUTPUT


� digitalWrite a HIGH or a LOW value to a digital pin.
� If the pin is configured as an INPUT
� digitalWrite() will enable or disable internal pullup on the
input
� Syntax: digitalWrite(pin,
Syntax: digitalWrite(pin, value)
value)
� Parameters:
� Pin : pin number whose value to be changed
� value : HIGH or LOW
� Example
� digitalWrite (11, HIGH)

Presented By: Mr. Shridhar Dudam 49


digitalRead()

� Reads the value from a specified digital pin,


either HIGH or LOW.
� Syntax: digitalRead(pin)
� Parameters:

� Pin
Pi n : : pin
pi n number
numb er whose
wh ose value
value to
to be
be read
read
� Example
� byte Val = digitalRead (11)

Presented By: Mr. Shridhar Dudam 50


Select Serial Port and Board

Arduino IDE : Sketch Structure

LED Blink : Circuit Diagram

Presented By: Mr. Shridhar Dudam 53


LED Blink : Sketch

// the setup function runs only once

void setup() {

// initialize digital pin 13 as an output.

pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever

void loop() {

digitalWrite(13, HIGH); // turn the LED on

delay(1000); // wait for a second

digitalWrite(13, LOW); // turn the LED off

delay(1000); // wait for a second

Presented By: Mr. Shridhar Dudam 54


LCD Display: Pinouts

Presented By: Mr. Shridhar Dudam 55


LCD Display: Signals

LCD Data Lines


8­bit bidirectional data bus

Used to send information to the LCD

Read the contents of internal registers

LCD Control
LCD Control Lines
Lines
RS: Select Data register or a Command/Status

register.

R/W#: Read/Write select control line.

E: Latches information presented to its data lines.

Presented By: Mr. Shridhar Dudam

LCD Display : Working

� Writing to LCD
� Asserts RS high to select DR
� Writes into LCD by asserting the R/W signal low
� Asserts the E signal high and then low (toggles) to latch a data byte
or an instruction
� Reading from LCD

� Asserts RS low to select IR
� Reads from LCD by asserting the R/W signal high
� Asserts the E signal high and then low (toggles) to latch a data byte
or an instruction
LCD Interface Modes

� 8 bit mode
� Uses all 8 data lines DB0­DB7
� Data transferred to LCD in byte units
� Interface requires 10 (sometimes 11) I/O pins of

� microcontroller (DB0­DB7,
(DB0­DB7 , RS,
RS , E) (sometimes R/W)
� 4­bit mode
� 4­bit (nibble) data transfer
� Each byte transfer is done in two steps: high order
nibble, then low order nibble
� Interface requires only 6 (sometimes 7) I/O pins of
microcontroller (DD4­DB7, RS, E)
Presented By: Mr. Shridhar Dudam 58
LCD Interfacing Diagram

Presented By: Mr. Shridhar Dudam 59


LiquidCrystal.h : Arduino Functions

� LiquidCrystal lcd_object(2, 3, 4, 5, 6, 7);

� lcd.begin(numCols, numRows);
� lcd.setCursor(colNumber, rowNumber);

� lcd.print(Data to be displayed);
� lcd.clear();
lcd.clear();
� lcd.blink(); & lcd.noBlink();
� lcd.display(); & lcd.noDisplay();
� lcd.scrollDisplayLeft();
� lcd.scrollDisplayRight();
� lcd.createChar(charNumber, charArray);

Presented By: Mr. Shridhar Dudam 60


LCD Interface : Algorithm

� Include LCD Library Functions (LiquidCrystal.h)


� Configure the LCD Interfacing pins
� In Setup function
� Set up the LCD's number of columns and rows.
� Print Message on first line of LCD
� Set Cursor of LCD to 2nd line first column.
� Print Message on second line of LCD
� In Loop function
� Turn off the display
� Call the delay
� Turn on the display
� Call the Delay
Presented By: Mr. Shridhar Dudam 61
LCD Sketch

#include <LiquidCrystal.h> // include the library


LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // initialize the library
void setup() {
lcd.begin(16, 2); // set up the LCD‘s

lcd.print(“PICT, Pune"); // Print a message

lcd .setC ursor(0 , 2);


lcd.setCursor(0, 2)
;
lcd.print("LCD Interface");
}
void loop() {
lcd.noDisplay(); // Turn off the display

delay(500);

lcd.display(); // Turn on the display:

delay(500); }

Presented By: Mr. Shridhar Dudam 62


Matrix Keypad

� Vertically arranged
keys are called
scanning line or
columns
� horizontally
arranged keys are
called return line
or rows

Presented By: Mr. Shridhar Dudam 63


Keypad Interface

Presented By: Mr. Shridhar Dudam 64


Keypad.h : Arduino Functions

� char keymap[numRows][numCols]= {
{'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'} };
� byte rowPins[numRows] = {8, 9, 10};
� byte colPins[numCols]= {11, 12, 13};
� Keypad myKeypad=
Keypad myKeypad=
Keypad(makeKeymap(keymap), rowPins,
colPins, numRows, numCols);
� char keypressed = myKeypad.getKey();

Presented By: Mr. Shridhar Dudam 65


Keypad Interface : Algorithm

� Include LCD Library (LiquidCrystal.h)


� Include the Keypad Library (Keypad.h)
� Configure the LCD Pins
� Define the no. of rows and no. of columns
� Define the
Define the keymap
keymap for
for each
each key
key pressed
pressed
� Configure the Keypad Row and Column Pins

� Initialize an instance of the Keypad class by


passing keymap, row pins, column pins,
number of rows and number of columns
Presented By: Mr. Shridhar Dudam 66
Keypad Interface : Algorithm

� In Setup function
� Set up the LCD's number of columns and rows.
� Print Message “Keypad Interface” on first line of LCD
� Set Cursor of LCD to 2nd line first column.

� Print Message “Key
“Key Pressed
Pressed” ” on second line of LCD
� In Loop function
� Declare the Char Variable to hold the key value
� Get the key pressed value using getKey() function
� Display the value of Key on LCD it valid key is

pressed.

Presented By: Mr. Shridhar Dudam 67


Data Transmission (1)

Serial Parallel

Receiver Receiver

1 bit

1 word

Transmitter Transmitter
Data Transmission (2)

Serial Parallel

Cost Cheap Expensive

Speed Slow Fast

Transmission
Transmission Single bit
Single bit 8 bits
8 bits (8
(8 data
data lines)
lines)
Amount Transmitter & Receiver

Transmission One line to transmit 8 lines for simultaneous


Lines one to receive transmission

Transmission Long distance Short distance


Distance (synchronization)

Example Modem Printer Connection

Serial Communication (1)

Presented By: Mr. Shridhar Dudam 70


Serial Communication (2)

� Synchronous
� Synchronous Peripheral Interface (SPI)

� Inter Integrated Circuit Interface (I2C)

� Asynchronous
� Serial Communication Interface (SCI)
Serial Communication Protocol

Image from http://www.fiz­ix.com/2013/02/introduction­to­arduino­serial­communication/

Bit Types

� Start Bit
� Signals the transmission of a word.
� Transition from “1” to “0”. (“Mark­to­space”)

� First bit to be transmitted.


� Data Bits

� Data
D ata bits
bit s to
to be
be transmitted.

t ransmitt ed.
� Sender and receiver have to agree in the number of
data bits. (Usually 8 or 9)
� Least significant bit is sent first.
� Can be low or high.
� Stop Bits
� Bit at the end of a data word.
� Bit set to high “1”.
� Indicates the end of a word.
Bit Types

� Parity bit –
� Works as an error check.
� There are two types: odd and even
� Even: if number of 1’s in the data word is even.
� Odd: if number of 1’s in the data word is odd.
� Bit after the data bits and before the stop bit.


� Can prevent single noise signal,
signal , but does not recognize
when two bits are altered by noise.
� Used to prevent noise.
ATmega328P: USART features

� Full Duplex Operation


� Asynchronous or Synchronous Operation
� High Resolution Baud Rate Generator
� Supports Serial Frames with 5, 6, 7, 8, or 9
data bits
data bits and
and 1
1 or
or 2
2 stop
stop bits
bits
� Odd or Even Parity Generation and Parity
Check Supported by Hardware
� Data Over Run & Framing Error Detection •
� Interrupts on TX Complete, TX Data Register
Empty and RX Complete
Presented By: Mr. Shridhar Dudam 75
ATmega328P: USART SFRs

� USART I/O Data Register 0 (UDR0)


� USART Control and Status Register 0 A (UCSR0A)
� USART Control and Status Register 0 B (UCSR0B)
� USART Control and Status Register 0 C (UCSR0C)
� USART Baud Rate 0 Register Low
� USART Baud Rate 0 Register High

Presented By: Mr. Shridhar Dudam 76


Arduino: Serial Functions

Presented By: Mr. Shridhar Dudam 77


Serial Interface

Presented By: Mr. Shridhar Dudam 78


Serial Communication: Algorithm

� In Setup function
� Initialize the serial port with desired baud rate
(e.g. 9600)
� Transmit the initial messages

� In Loop function
� Declare the Variable with data type integer to hold
the received data
� Check for any data is received on serial port
� If yes read the data into variable and retransmit
the data on serial port
Presented By: Mr. Shridhar Dudam 79
Serial Communication: loopback

void setup() {
Serial.begin(9600); // initialize serial ports:
Serial.println("Serial Communication Demo");
Serial.println("Please send data");
}}
void loop() {

// read from com port, and send it again

if (Serial.available()) {

int inByte = Serial.read();

Serial.write(inByte);

} }

Presented By: Mr. Shridhar Dudam 80


Analog to Digital Converter

Analog Sample and Hold Analog to Digital


Digital Output
Input Circuit Converter

Fig.: Analog to Digital Conversion Block Diagram

To ADC

Fig.: Sample and


Hold Circuit

Successive Approximation ADC

Presented By: Mr. Shridhar Dudam 82


Presented
By: Mr. Shridhar Dudam 83
ADC Parameters

Step Size and Resolution:


� The entire input voltage range (0V to VREF) is
divided into a number of sub­ranges called Step.
� Each step is assigned a single output digital code.

� No. of steps of ADC is given by Vref/2


/2^n
^n
� This n is called as resolution of ADC and it represents

the size of digital output.


� For example, an ADC with Resolution = 3­bits and
VREF= 2V, total number of steps are 8 and the step
size is 250mV.

Presented By: Mr. Shridhar Dudam 84


ADC Parameters : Quantization Error

Presented By: Mr. Shridhar Dudam 85


ADC in Arduino

� Resolution of ADC is 10 bit


� The Arduino uses 1024 states (10 bits)
� Smallest measurable voltage change is 4.8 mV

� 5V/1024 means Vref/no. of states



� Maximum sample rate is 10,000 times a a
second
� 13 ­ 260µs Conversion Time
� Six Multiplexed Single Ended Input Channels

Presented By: Mr. Shridhar Dudam 86


ATmega328P ADC Block Diagram

Presented By: Mr. Shridhar Dudam 87


ADC pins in Atmega 328P

Presented By: Mr. Shridhar Dudam 88


ATmega328P ADC SFR

� ADC Multiplexer Selection Register (ADMUX)

� ADC Control and Status Register A (ADCSRA)

� ADC Data Registers (ADCH,ADCL)

Presented By: Mr. Shridhar Dudam 89


Temperature Sensors

Types of Temperature Sensors:

1. Thermistor
2. Thermocouple
3. RTD
4. LM35
…. Much more

Temperature Sensor
� Popularly Used
� No Signal Condition Circuit
is required
� Output in terms of voltage

� 10mv/degree
Presented By: Mr. Shridhar Dudam 90
LM35 Interfacing to Arduino

� Produces an Analog Voltage directly proportional to


temperature (10mV per degree)

Presented By: Mr. Shridhar Dudam 91


Algorithm for temperature Sensor

1. Initialize the library with the numbers of the


interface pins by using LiquidCrystal lcd() function.
2. Set up the LCD's number of columns and rows by
using function lcd.begin().
3. Print message “Temperature :” on LCD by using
lcd.print() function.
lcd.print() function.
4. Read temperature sensor value by using
analogRead () function.
5. Display the temperature on LCD by using lcd.print()
function.

Presented By: Mr. Shridhar Dudam 92


Temperature Sensor Sketch

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
lcd.begin(16, 2); // set up the LCD's no. of columns and rows:
lcd.setCursor(0, 2);
lcd.print("Temprature: "); // Print a message to the LCD.
}

Presented By: Mr. Shridhar Dudam 93


Temperature Sensor Sketch

void loop()
{
float temp;
//Read Temperature Sensor
temp = = (5.00 *
* analogRead(A4) *
* 100) / 1023.0;

1023.0;
lcd.setCursor(11, 1);

lcd.print(temp);

delay(500);

Presented By: Mr. Shridhar Dudam 94


Analog Output : PWM

� Can a digital devise produce analog output?

Image from Theory and Practice of Tangible User Interfaces at UC Berkley

• Analog output can be simulated using


pulse width modulation (PWM)
Pulse Width Modulation

• Can’t use digital pins 


to directly supply say 
2.5V, but can pulse
the output on and off
really fast to produce
the same
the same effect
effect

• The on­off pulsing


happens so quickly,
the connected output
device “sees” the
result as a reduction
in the voltage
Image from Theory and Practice of Tangible User Interfaces at UC Berkley

PWM Duty Cycle

output voltage = (on_time / cycle_time) * 5V

Image credit: Tod Kurt

Fixed cycle length; constant


number of cycles/sec
PMW Pins

• Command:
analogWrite(pin,value)

• value is duty cycle:
between 0 and 255
255

• Examples:
analogWrite(9, 128)
for a 50% duty cycle

analogWrite(11, 64)

for a 25% duty cycle

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


Controlling the Intensity of LED

void setup() {
pinMode(10, OUTPUT); // initialize pin as an output.
}
void loop() {
for(int x = 0; x <= 255; x=x+10) {
analog Write( 10, x);
analogWrite(10, x);
delay(50);

for(int x = 255; x >= 0; x=x­10) {

analogWrite(10, x);

delay(50);

Presented By: Mr. Shridhar Dudam 99


PMW Pins

• Command:
analogWrite(pin,value)

• value is duty cycle:
between 0 and 255
255

• Examples:
analogWrite(9, 128)
for a 50% duty cycle

analogWrite(11, 64)

for a 25% duty cycle

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


Accelerometer

� Use of Accelerometer
� To detect when something starts or stop moving.
� To detect how something is oriented with respect
to Earths Surface

Presented By: Mr. Shridhar Dudam 101


Principle of Working

� The capacitance accelerometer senses changes in capacitance


between microstructures located next to the device. If an
accelerative force moves one of these structures, the
capacitance will change and the accelerometer will translate
that capacitance to voltage for interpretation

Presented By: Mr. Shridhar Dudam 102


Applications of Accelerometer

� Cost sensitive, low power, motion­ and tilt­


sensing applications
� Mobile devices
� Gaming systems
� Disk drive
Disk drive protection
protection
� Image stabilization
� Sports and health devices

Presented By: Mr. Shridhar Dudam 103


ADXL335: 3­axis Accelerometer

� ADXL335 is one of the popular 3 axis Accelerometer having


3­outputs X, Y & Z.
� Readings from X, Y, Z axis reflects an orientation of an
accelerometer.
� The measured values appear as change in voltage at three
output pins with respect to a common ground.

Presented By: Mr. Shridhar Dudam 104


Accelerometer Interfacing

Presented By: Mr. Shridhar Dudam 105


Accelerometer Sketch

const int xpin = A3; // x­axis

const int ypin = A2; // y­axis

const int zpin = A1; // z­axis

void setup() {

Serial.begin(9600);
Serial.begin (9600); } }
void loop() {
Serial.print(analogRead(xpin)); Serial.print("t");
Serial.print(analogRead(ypin)); Serial.print("t");
Serial.print(analogRead(zpin)); Serial.print("t");
Serial.println();
delay(100); }
Presented By: Mr. Shridhar Dudam 106
DC motor Interface

� Why Motor Driver IC?


� The L293D is a H Bridge type IC and can
control DC motors up to 36V
� 2 motors can be driven with a single L293D

Motor Driver
Arduino DC Motor
Circuit

Presented By: Mr. Shridhar Dudam 107


Controlling Direction

Presented By: Mr. Shridhar Dudam 108


DC Motor Interface

Presented By: Mr. Shridhar Dudam 109


L293D Sketch

const int motor1Pin1 = 8; // pin 2 on L293D

const int motor1Pin2 = 9; // pin 7 on L293D

const int enablePin = 10; // pin 1 on L293D

void setup() {

pinMode(motor1Pin1, OUTPUT); // set all the other pins you're using as outputs:

pinMode(motor1Pin2, OUTPUT);

pinMode(enablePin, OUTPUT);

digitalWrite(enablePin, HIGH); // set enablePin high so that motor can turn on:

void loop() {

digitalWrite(motor1Pin1, LOW); // set pin 2 on L293D low

digitalWrite(motor1Pin2, HIGH); // set pin 7 on L293D high

delay(500);

digitalWrite(motor1Pin1, LOW); // set pin 2 on L293D low

digitalWrite(motor1Pin2, LOW // set pin 7 on L293D low

delay(500);

digitalWrite(motor1Pin1, HIGH); // set pin 2 on L293D high

digitalWrite(motor1Pin2, LOW); // set pin 7 on L293D low

delay(500);

Presented By: Mr. Shridhar Dudam 110


APPLICATIONS

� Stepper Motor Drivers


� DC Motor Drivers
� Latching Relay Drivers

Presented By: Mr. Shridhar Dudam 111


Strain Gauge

� A strain gauge is a device used to measure strain on


an object.
� The gauge is attached to the object by a suitable
adhesive.
� As the object is deformed, the foil is deformed,
causing its
causing its electrical
electrical resistance
resistance to
to change.
change.
� This resistance change, usually measured using a
Wheatstone bridge, is related to the strain by the
quantity known as the gauge factor.

Presented By: Mr. Shridhar Dudam 112


Strain Gauge : Resistance

� Resistance goes up.


� Strain Gauge under tension.
� Resistance goes down.
� Strain Gauge under compression.

l
R ρA =
Wheatstone Bridge

How Does It Work?


R1 R4

­ VEX V0

R2 R3
What is a Load Cell?

� The most common type of a strain gauge is load cell.


� A load cell is a transducer that is used to convert a
force into electrical signal.
� Applications:
� Scales
� Scales
� Weighbridge

� Force Gauges

� Torque Gauges

Signal
Load Cell Conditioning ADC Microcontroller
Circuit
Load Cells: Types

Button
Canister
S Type

Shear Beam
Load Cell Signal Conditioner

� HX711 Load Cell Amplifier


� Used as Signal Condition Circuit for Load Cell
� used to get measurable data out from a load cell
� Has inbuilt precision 24­bit ADC
� Specially designed for weigh scales and industrial control
appli cati ons tto
applications o interface
nt erf ace directly
di rectl y with
with a
a bridge
rid
ge sensor.

HX711
Arduino
Load Cell Load Cell
UNO
Amplifier

Presented By: Mr. Shridhar Dudam 117


Load Cell Interfacing

Presented By: Mr. Shridhar Dudam 118


LVDT

� The Linear Variable Differential Transformer (LVDT)


is a common type of electromechanical, high
resolution, contact based linear position transducer.
� LVDT is one of the best available, reliable and
accurate methods for measuring linear distance.
� LVDTs are
LVDTs are used
used in in computerized
computerized manufacturing,
manufacturing,
machine tools, avionics and robotics.
� LVDT is a position to electrical sensor.

Presented By: Mr. Shridhar Dudam 119


LVDT : Schematic

� An LVDT consists of
three coils, one primary
and two secondary. A
movable magnetic core
is placed as shown in
the
th e fi
figure.
gure.
� The output of the LVDT
is proportional to the
position of the core.

Presented By: Mr. Shridhar Dudam 120


LVDT : Signal Conditioner Circuit

� It consists of additional filtering and amplification


circuit where the absolute values of the two output
signals are subtracted.

Presented By: Mr. Shridhar Dudam 121


References

� Massimo Banzi, Michael Shiloh, “Make: Getting


Started with Arduino”, Maker Media, Inc.
� Michael Margolis, “Arduino Cookbook”, O'Reilly
Media, 2nd Edition.

� Juli en Bayle,
Julien Bayl e, “C programming
programmi ng for
for Arduino”,
Arduino” ,
PACKT publishing
� www.arduino.cc (learning section)

Presented By: Mr. Shridhar Dudam 122


Thank You !!!!

!!!!

Presented By: Mr. Shridhar Dudam 123

You might also like