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

Embedded C

The ATmega16 is a low-power 8-bit microcontroller based on the AVR RISC architecture that can achieve throughput of up to 16 MIPS. It uses a Harvard architecture to separate program and data memories and buses. It has 32 general purpose registers, 3 PWM channels, and internal and external interrupt sources. Programming and debugging of AVR projects can be done using AVR Studio through writing C code, compiling to a hex file, simulating, and programming the chip. Common algorithms for robots include blinking an LED, line following, edge avoiding, and light searching.

Uploaded by

Anant Verma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Embedded C

The ATmega16 is a low-power 8-bit microcontroller based on the AVR RISC architecture that can achieve throughput of up to 16 MIPS. It uses a Harvard architecture to separate program and data memories and buses. It has 32 general purpose registers, 3 PWM channels, and internal and external interrupt sources. Programming and debugging of AVR projects can be done using AVR Studio through writing C code, compiling to a hex file, simulating, and programming the chip. Common algorithms for robots include blinking an LED, line following, edge avoiding, and light searching.

Uploaded by

Anant Verma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

AVR ATMEGA 16

ATmega16 is a lowpower CMOS 8-bit microcontroller based on the AVR RISC architecture.

By executing powerful instructions in a single clock cycle, the ATmega16 achieves throughput 6/11/12 approaching 1 MIPS

Contd....

In order to maximize performance and parallelism, the AVR uses a Harvard architecture- which separates memories and buses for program and data. Instruction in program memory are executed with single level pipelining. This concept enables instructions to be executed in every clock cycle.
6/11/12

FEATURES

High-performance, Low-power 8-bit Microcontroller. Up to 16 MIPS Throughput at 16 MHz. 32 x 8 General Purpose Working Registers. 3 PWM Channels. Internal Calibrated RC Oscillator. External and Internal Interrupt Sources.
6/11/12

MEMORY SEGMENTS

High Endurance Non-volatile Memory segments. 8K Bytes of In-System Self-programmable Flash program memory. 512 Bytes EEPROM (Electrically Erasable Programmable Read Only Memory). 1K Byte Internal SRAM (Static Random Access Memory).
6/11/12

PIN OUTS

6/11/12

EMBEDDED SYSTEM

An Embedded system is combination of computer hardware and software, and perhaps additional mechanical or others parts, designed to perform a specific task. Example: microwave oven, AC etc

6/11/12

INTRODUCTION TO EMBEDDED C

Development process of AVR projects Control structures in C Algorithms to be studied AVR studio

6/11/12

WHAT IS EMBEDDED C?

Embedded C is nothing but a subset of C language which is compatible with certain microcontrollers. Some features are added using header files like <avr/io.h>, <util/delay.h>. scanf() and printf() are removed as the inputs are scanned from the sensors and outputs are given to the ports. Control structures remain the same like ifstatement, for loop, do-while etc. 6/11/12

DEVELOPMENT PROCESS OF EMBEDDED C PROJECTS

Write C programs in AVR Studio. Compile them into a .hex file using the AVRGCC compiler (which integrates into AVR Studio). Simulate the target AVR program and debug the code within AVR Studio. Program the actual chip using the AVRISP mkII USB device, which is attached to our target board with a special 6-pin cable.
6/11/12

Once programmed, the chip runs the program

IF- STATEMENT

Syntax: if( condition) { statement. }

else { statement.. 6/11/12

PROGRAM FOR IF-STATEMENT


Int a=4; Int b=5; If(a>b) printf( a is largest); else printf( b is largest);

6/11/12

PROGRAM FOR DO WHILE STATEMENT Int a=4; Do { a++; } while(a>5);

6/11/12

ALGORITHMS FOR ROBOTS


1. 2. 3. 4.

Blinking LED Line follower robot Edge avoider robot Light searching robot

6/11/12

BLINKING LED
Program: main() { DDRB=0XFF; while(1) { PORTB=0XFF; _delay_ms(255); 6/11/12

LINE FOLLOWER ROBOT


Step 1: PORT B is acting as the output port connected to the motors. Step 2: PORT C is acting as a input port connected to the sensors. Step 3 : masking of left and right sensors as follows:

Left_sensor=PINC&0b0010000, i.e.. Masking PC4 bit of PORT C Right_sensor=PINC&0b0100000, i.e.. 6/11/12 Masking PC5 bit of PORT C

EDGE AVOIDER ROBOT


Step 1: DDRB=0xFF Step 2: DDRC=0b0000000 Step 3: start a infinite loop Step 4: Step 3 : masking of left and right sensors as follows:

Left_sensor=PINC&0b0010000, i.e.. Masking PC4 bit of PORT C Right_sensor=PINC&0b0100000, i.e.. Masking PC5 bit of PORT C

Step 5: condition 1: if(left_sensor= off and right_sensor=off) move backward, and after some delay move right Step 6: condition 2: if(left_sensor= on and right_sensor=on) move forward. Step 7: condition 3: if(left_sensor= off and right_sensor=on) move backward, and after some delay move right

6/11/12 Step 8: condition 4: if(left_sensor= on and right_sensor=off)

LIGHT SEARCHING ROBOT


Step 1: DDRB=0b11111111; PORTB is acting as output Port connected to motors Step 2:DDRC=0b0000000; PORTC is acting as Input port connected to Sensors Step 3: Masking :

left_sensor=PINC&0b0010000 PC4 bit of PORT C right_sensor= PINC&0b0100000 PC5 bit of PORT C

6/11/12

DELEVOPMENT TOOLS
HOME SCREEN FOR OF AVR STUDIO

6/11/12

NEW PROJECT WINDOW

6/11/12

NAMING PROJECT AS LINE FOLLOWER

6/11/12

SELECTING PLATFORM AND DEVICE

6/11/12

CODING WINDOW

6/11/12

BUILDING THE CODE

6/11/12

BULID AND RUN THE CODE

6/11/12

THANK YOU
Click to edit Master subtitle style

6/11/12

You might also like