Monday, 25 November 2013

/*
 * SERVOS_EXECUTION.c
 *
 * Created: 25-Nov-13 11:37:32
 *  Author: avrnarm
 */

#define F_CPU 16000000ul
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRC=0xFF;
DDRD=0xFF;
char i ;
    while(1)
    {

_delay_ms(2000);
for (i=0;i<2;i++)
{
PORTC=0xFF;
PORTD=0xFF;
_delay_us(1000+5.55*10) ;
PORTC=0x00;
PORTD=0x00;
_delay_us(2010) ;
}

Friday, 15 November 2013

/*
Interfacing Ultra Sonic Module (4 PIN HCSR04) with Atmega16
Hardware Pin Configuration: Vcc, Gnd, Trigger input pulse, echo output pulse.

LCD Connected to port A.
Sensor to PORTD.

Sensor |

Trig   --> PD0
Echo   --> PD1
Vcc   --> Vcc
Gnd   --> Gnd

 Programmer: Raj Prajapati
 rajatmelavr@gmail.com

 For any query

*/

//Header File
#include <avr/io.h>
#include <util/delay.h>
#include "ilcd.h"
//Macros
#define US_PORT PORTD
#define US_PIN PIND
#define US_DDR DDRD
#define US_TRIG PD0
#define US_ECHO PD1
//Globle Variable
int distance;
//Calculating width of high pulse in micro second.
#define US_Time_out -12
#define US_NO_OBSTACLE -13
void US_init();
void US_trig();
void US_init()
{
US_DDR|=(1<<US_TRIG);
}

void US_trig()
{
//Send a 10uS pulse on trigger line

US_PORT|=(1<<US_TRIG); //high

_delay_us(15); //wait 15uS

US_PORT&=~(1<<US_TRIG); //low

Basic Interfacing GLCD with ATmega16

Posted by Unknown On 10:13 | No comments
Following is the program to Generate the basic verticle line on the glcd at and 0th Column.
Connection is shown in the Image. PORTC is reserved for the Control Port and PORTB for data Port.
Here we had not used any Library for this purpose.

/*
 * GLCDpattern1.c
 *
 * Created: 14-Nov-13 23:27:35
 *  Author: avrnarm
 *  Description: To print the simple verticle line on the Display.
 */

#define F_CPU 8000000ul

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


//Macros

//for controlling on portC
#define EN 0
#define RW 1
#define RS 2
#define CS1 3
#define CS2 4
#define RST 5
#define dataport PORTB
#define ctrlport PORTC

//Function Declaration
void GLCD_init(void);
void enable (void)
{
ctrlport|=(1<<EN);
_delay_us(100);
ctrlport&=~(1<<EN);
}

Monday, 28 October 2013

AVR: Stopwatch With Interrupt Timer and Multiplexed 7 segment Display

Here we are connecting the 7 segment display with PORTA, i.e. Multiplexing of six-7segment display, with the control lines to PORTB. Following is the program to Interface the 7segments.

Crystal : 8MHz
Time: 0.125uSec
Prescaler: clk/1025
Timer Interrupt : 25mSec.
For 1sec , run this timmer for 40 times.

We can achieve max delay of appx. 35000uSec or 35mSec with 8MHz crystal frequency and prescaler (clk/1024).

Program: 

/*
 * two_7seg.c
 *
 * Created: 27-Oct-13 19:08:04
 *  Author: avrnarm
 */ 

/* PROGRAM to execute the counter with the multiplexed 7 segent display */
#define FUSE_CKSEL0 0
#define FUSE_CKSEL1 0
#define FUSE_CKSEL2 1
#define FUSE_CKSEL3 0

#include<avr/io.h>
#define F_CPU 8000000Ul
#include<util/delay.h>
#include<avr/interrupt.h>

unsigned int j,ss=0,mm=0,hh=0;
char ssd[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; // Hexadecimal values for the 7 Segment display generated by the look up table
char ssd_dec[]={0xbf,0x86,0xdb,0xcf,0xE6,0xEd,0xFd,0x87,0xff,0xEf}; // Hexadecimal values for the 7 Segment display generated by the look up table

int main(void)
{
DDRA=0xFF;
DDRB=0xFF;
//*********************TIMER***(8MHz crystal....clk/1024 prescaler......Obtained 25ms delay
TCNT0=61;
TCCR0=0x05;
TIMSK=(1<<TOIE0);
//*********************
sei();
while(1)
    {
// for seconds
PORTB=0xFF;
PORTA=ssd[(ss)/10];

Friday, 25 October 2013

NotePad Design with Atmega16/32 on 16x2 LCD with UART


Here in this program we are designing the notepad by using Atmega16/32 as a controller and LCD for displaying the typed that we will be sending from the help of  UART. In Proteus, with the help of the Virtual Terminal , we will send the data to the uC and the same data will be displayed on the 16x2 LCD in the same way we type in the Notepad. Once you had written the max 32 character, Lcd will get clear and go back again to home position to provide you the space of the further character you will be sending from the UART.


Hardware Connection : -


***************************PROGRAM*****************************


//Program to interface the LCD, Uart and Keyboard

#include<avr/io.h>
#define F_CPU 1000000ul
#include<util/delay.h>
#include<stdlib.h>

//Flag to moniter no of bit received
char flag=0;


//Setting Fuse Bit

#define FUSE_CKSEL0 0
#define FUSE_CKSEL1 0
#define FUSE_CKSEL2 1
#define FUSE_CKSEL3 0

//**********************************LCD START************************************
/* LCD bit connection

Lcd Interfacing in 8-bit mode
PA0 --> D0
PA1 --> D1
PA2 --> D2
PA3 --> D3
PA4 --> D4
PA5 --> D5
PA6 --> D6
PA7 --> D7

PB0 --> RS
PB1 --> RW
PB2 --> EN

*/

//Macros For Lcd
#define LCD_PORT PORTA
#define rs (1<<0)
#define rw (1<<1)
#define en (1<<2)

Blogroll

Copyright © 2013 RAJ PRAJAPATI (raj@electronicsrj.com)

Comments

About Projects

We also Provide support in making Electronics Projects at different level at Cheapest price. Contact Us for the further help.