motor and sensor ppt (4)

26
1 www.buildingblocks.in | www.bulo.in | 9818403093 Corporate Excellence Program In Electronics & Communication Motor and sensor Building Blocks

Upload: abhishek-singh

Post on 20-Apr-2017

262 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Motor and Sensor Ppt (4)

1www.buildingblocks.in | www.bulo.in | 9818403093

Corporate Excellence ProgramIn Electronics & Communication

Motor and sensor

Building Blocks

Page 2: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 2

Page 3: Motor and Sensor Ppt (4)

3www.buildingblocks.in | www.bulo.in | 9818403093

Corporate Excellence ProgramDevelopment Board: Interfacing Motors (DC)

Motor : - is an electrical device.- converts electrical energy into mechanical energy.

Principle and working :- works on Farad law of electromagnetic induction.

Law:-- A current -carrying conductor generates a magnetic field.- When a current carrying conductor is placed in the external magnetic field, it will experience a force proportional to the current in the conductor, and to the strength of the external magnetic field.

Application - Motor is applied where the motion is needed. - Used in car, used in washing machine, fans etc.

Page 4: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 4

What is H-bridge?- An electronic circuit.- Make enable a voltage to be applied across load in either direction. - It exists in IC and can be formed from discrete Components.

Where are they applied?- Used in Robotics- To allow DC motors to run forwards and backwards. - In any device where motion is needed.

How they work?-is built with four switches

Corporate Excellence ProgramElectronic Components: H-bridge

S1 S2 S3 S4 Result

1 0 0 1 Motor moves right

0 1 1 0 Motor moves left

1 0 1 0 Motor breaks

0 1 0 1 Motor break

Page 5: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 5

What is IC used as H-bridge?- IC L293D or L298N is used as H- bridge

Question 1. How can we make the circuit to move 12 v motor when the input voltage is less than 5 volt.

Pin diag-L293d

Circuit diag-L293d

Corporate Excellence ProgramElectronic Components: H-bridge

Page 6: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 6

Motorized Robot:There are two DC motors are used in this motorized Robot. The motion of the motorized Robot is of two dimensional. Principle & Working of Motorized Robot The motion of the motorized Robot or Robotics car having two motors is based on the movement of both motors only. 

Corporate Excellence ProgramElectronic Components: Motorized Robot

Page 7: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 7

Robot Movement

Motor(M1)(T1)

Motor(M1)(T2)tor (M1) T2

Motor(M2)(T1)o) T3

Motor(M2)(T2)4

Forward 1 0 1 0

Backward 0 1 0 1

Left Turn 0 1 1 0

Right Turn 1 0 0 1

Stop 0 0 0 0

Corporate Excellence ProgramElectronic Components: Motorized Robot

Page 8: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 8

Corporate Excellence ProgramElectronic Components: Robotic Crane

Page 9: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 9

Corporate Excellence ProgramDevelopment Board: Robotics Car

#include <avr/io.h>#include<util/delay.h>

void main() {DDRD= 0X00;DDRA= 0XFF;If(0b10000000==PIND){ PORTA=0b10100000; // Forward motion}else If(0b01000000==PIND){ PORTA=0b01010000; // Backward motion}else If(0b00100000==PIND){PORTA=0b01100000; // left turn}

Q.1. Write a program to make a Robotic Car which will run in forward when switch 1 is pressed, move in backward when switch 2 is pressed, moves in left when switch 3 is pressed, moves right when switch 4 is pressed, Robot will stop when 5 switch is pressed.

else If(0b00010000==PIND){PORTA=0b10010000; // Right turn}

else If(0b00001000==PIND){PORTA=0b00000000; // stop}}

Page 10: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 10

Corporate Excellence ProgramDevelopment Board: Robotics arm / gripper

Q.1. Write a program to make a robotic arm/Griper which will run in forward when switch 1 is pressed, move in backward when switch 2 is pressed, moves in left when switch 3 is pressed, moves right when switch 4 is pressed, Move arm in upward when 5 is pressed, Moves arm in downward when 6 is pressed & Robot will stop when 7 switch is pressed. #include <avr/io.h>#include<util/delay.h>void main() {DDRD= 0X00;DDRA= 0XFF;If(0b10000000==PIND){ PORTA=0b10100000; // Forward motion}else If(0b01000000==PIND){ PORTA=0b01010000; // Backward motion}else If(0b00100000==PIND){PORTA=0b01100000; // left turn}

else If(0b00010000==PIND){PORTA=0b10010000; // right turn}

else If(0b00001000==PIND){PORTA=0b00001000; // upward motion of arm}else If(0b00000100==PIND){PORTA=0b00000100; // downward motion of arm}

else If(0b00000010==PIND){PORTA=0b00000000; // stop}}

Page 11: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 11

Sensor:

- A sensor (also called detectors) is a device that measures a measurable quantity and converts it into a signal which can be read by an observer or by an instrument. - is a device that measures a physical quantity - converts that physical quantity into a signal which can be read by an observer or by an instrument. Example:- IR sensor, Touch sensor, Mercury –in –glass thermometer, Volt meter, Application: - Sensors are used in everyday objects such as touch-sensitive, elevator buttons (tactile sensor ), lamps which dim or brighten by touching the base. - Applications include cars, machines, aerospace, medicine, manufacturing a robotics.

Corporate Excellence ProgramDevelopment Board: ( sensor)

Page 12: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 12

IR Sensor : There are two part of the sensors 1. Emitter 2. Receiver 1. Emitter: - It is a device which converts the electrical current in the Infra-Red

Radiation. 2. Receiver:- is a device which receive the IR radiation when the radiation

reflect back after the collision from the obstacle and then this IR radiation is converted into electrical current.

Corporate Excellence ProgramDevelopment Board: ( sensor and its kind)

Page 13: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093

13

Corporate Excellence ProgramDevelopment Board: ( sensor and its kind)

IR sensorTouch sensor

Page 14: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 14

SENSOR PROGRAMMING

#include<avr/io.h>#include<inttypes.h>#include <util/delay.h>#define ADC_VREF_TYPE 0b01000000unsigned int read_adc(unsigned char adc_input){ADMUX=adc_input|ADC_VREF_TYPE;ADCSRA|=0x40;while ((ADCSRA & 0x10)==0);ADCSRA|=0x10;return ADCW;}int ADCinit(void){ADMUX=ADC_VREF_TYPE;ADCSRA=0b10000100;return 0;}void main(void){DDRD= 0xFF;DDRA= 0x00;unsigned int Sensor_port1=0;ADCinit();Sensor_port1=read_adc(0);PORTD=0b00000000;if(Sensor_port1>400){PORTD=0b00000001;Delay(100);//produce one second delay}else{PORTD=0b00001000;}}

Void delay(unsigned int j){For(;j>0;j--){_delay_ms(10);}}

Page 15: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 15

SENSOR PROGRAMMING

ATmega16 Input voltage range of 0 to 5 Vcc. Selectable 2.56V of internal Reference voltage source. AREF pin for External Reference voltage. ADC Conversion Complete Interrupt. ADC channels in Atmega16 are multiplexed with PORTA Use pin33 to pin40 with PORTA.

ADC system of Atmega16 microcontroller consists of following pins: i ADC0-ADC7: 8 Channels from Pin 40 to Pin 33 ii. AREF: Pin32 of Atmega16 microcontroller, - the voltage on AREF pin acts as the reference voltage for ADC conversion, -reference voltage is always less than or equal to the supply voltage, i.e., Vcc.

Page 16: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 16

Page 17: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 17

Page 18: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 18

iii. AVCC: -Pin30, -is the supply voltage pin for using PORTA and the ADC; - must be connected to Vcc to use PORTA and ADC. Note: External reference voltage source can be used at AREF pin. However, Atmega16 also has internal reference voltage options of 2.56V and Vref = Vcc.

ADC RegisterTo use the ADC peripheral of Atmega16, certain registers need to be configured.

Page 19: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 19

1. ADMUX(ADC Multiplexer And Selection Register)

1. REFS[0:1] bits determine the source of reference voltage. - whether it is internal or the external voltage source connected to AREF pin. - MUX[4:0] bits are used to select between the channels which will provide data to ADC for conversion. - ADLAR bit when set to 1 gives the left adjusted result in data registers ADCH and ADCL.

Page 20: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 20

2. ADCSRA (ADC Control and Status Register)

ADEN: ADC Enable bit, this bit must be set to 1 for turning ADC on.ADSC: ADC Start Conversion bit, this bit is set to 1 to start ADC conversion, as soon as conversion is completed this bit is set back to 0 by the hardware.ADATE: ADC Auto Trigger Enable, this bit is set to 1 to enable auto triggering of ADC conversion.

Page 21: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 21

ADIF: ADC Interrupt Flag, this bit is set to 1 when ADC conversion gets complete.ADIE: ADC Interrupt Enable, this bit is set to 1 if we want to activate the ADC conversion complete interrupt.ADPS[0:2]:ADC Prescaler bits,- are used to set the ADC clock frequency, - these bits determine the division factor by which the microcontroller clock frequency is divided to get the ADC clock frequency. - The ADC clock frequency must lie somewhere between 50 KHz to 200 KHz.

Page 22: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 22

III. ADCH & ADCL (ADC Data Registers) - When the ADC conversion is complete the data is stored in these two registers.- The data configuration depends on the ADLAR bit value of ADMUX register. - If ADLAR=0, data is right adjusted and if ADLAR=1, data is left adjusted. - Always read ADCL first and then ADCH.

When ADLAR = 0,

When ADLAR = 1,

Page 23: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 23

 Code explanationfollowing steps for programming . Step1: To initialize ADC i. Set the value in ADMUX register according to the ADC channel and the reference voltage. ii. Set the Prescaler bits accordingly in ADCSRA register. iii. Set the ADEN bit to enable the ADC.

void ADC_init(void) // Initialization of ADC{

ADMUX=(1<<REFS0); // AVcc with external capacitor at AREFADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);

// Enable ADC and set Prescaler division factor as 128}

Page 24: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 24

Step2: To read the analog value i. Put the channel value in ADMUX ii. Start the conversion by setting the ADSC bit. iii. Monitor the ADIF bit for conversion complete. iv. Clear the conversion bit ADIF. By writing it 1. v. Digital converted result is now available in ADCH and ADCL registers.unsigned int ADC_read(unsigned char ch){

ch= ch & 0b00000111; // channel must be b/w 0 to 7ADMUX |= ch; // selecting channel

ADCSRA|=(1<<ADSC); // start conversionwhile(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion

completeADCSRA|=(1<<ADIF); // clearing of ADIF, it is

done by writing 1 to it

return (ADC);}

Page 25: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 25

#include<avr/io.h>#include<inttypes.h>

#include <util/delay.h>#define ADC_VREF_TYPE 0b01000000

int ADCinit(void){ADMUX=ADC_VREF_TYPE;ADCSRA=0b10000100;return 0;}

unsigned int read_adc(unsigned char adc_input){ADMUX=adc_input|ADC_VREF_TYPE;ADCSRA|=0x40; // strat conversionwhile ((ADCSRA & 0x10)==0);ADCSRA|=0x10;return ADCW;}

void main(){DDRA=0X00;DDRD=0XFF;unsigned int a,b;ADCinit();while(1){a=read_adc(0);b=read_adc(1);if(a>350){PORTD=0XFF;}else{PORTD=0x00;}}}

Page 26: Motor and Sensor Ppt (4)

www.buildingblocks.in | www.bulo.in | 9818403093 26

Q1. Two sensors, one IR sensor and another Touch sensor is connected to the pin 2 and pin 6 of the port of the microcontroller. If the touch sensor sense something then its will glow the LEDs board pattern as follow: 1. all even lEDs glow one by one 2. All odd LEDs glow one by one 3. All ON & all OFFIf IR sensor sence then its value will increased as the IR value increase on seven segment. Q2. Interface the keypad and display on the seven segment display when the different key is press.

Q3. Do interfacing of the keypad + sensor and display the fuctionality on board.