Showing posts with label Electronics. Show all posts
Showing posts with label Electronics. Show all posts

Initial setup for microcontroller project



Before starting to learn 8051 microcontroller we need an initial setup like an environment in which we have basic requirement to learn 8051 like programmer board to program a microcontroller,simulator to write our codes,driver support the hardware etc.So here are some short of steps you have to follow to prepare your computer for 8051.



  1. Install the KeilUvision3 software in your system if you do not have the keil then dont worry you can download it from here Download

  2. Now install the serial to usb driver in your system if you are using a serial to usb cable well it is come with your serial cable driver cd but if you don't have then download.

  3. After this you are able to write your codes in C and assembly languages and can check your codes are working or not by your simulator.

  4. Now for transferring those codes into the microcontroller Install Flash magic in your computer or download it form here download.

  5. Buy an 8051 Development board it may cost you around 800 rupee and also a microcontroller of nxp  series p89v51rd2.

  6. you can also make your own programmer kit for 8051 microcontroller. programmer kit 

  7. Now you have all necessary things to learn 8051 lets start if having any doubt or facing any problem then can contact me on my mail id.

                                                           @BEST OF LUCK@



Smart 8051 Board


In this Board, Microcontroller interfaced with MT8870 DTMF IC, decoder ic, L293D, ULN2803, & segment, LED, LCD, and many more.

In this board every interfacing is done through male buck strip via jumper wires of 8 pins.....

so it is a complete board which provides u each and every interfacings which u need,...

Its cost is just INR 895

ASK Transmitter and Receiver Module

Since ASK (Amplitude Shift Keying) Technology is a kind of Wireless Communication from Transmitter to Receiver end, as you all know this type of Technology is suitable for One way Transmission i.e, Half Duplex Communication.
                         Here we use ASK Rx and Tx Modules of 434 MHz which is suitable for 20 meters of distance. As you all know for long range wireless transmission we require Carrier Signal for effective transmission of Information Bits.

Thus the function of these ASK Modules is to provide Carrier Signal to our Data Signal which is 30KHz, thus the distortions are undertook under 434MHz and Data (30KHz) Signal remains safe or Un-Disturbed.
Here in this technology we use Decoder and Encoder, which is used to decode and encode the data signals, as 4 Bit Data is Converted into 1 Bit Data and Vice Versa.

In Electronics Market both 4 Bit and 8 Bit Encoder and Decoder are Available, Namely
HT12D (4 Bit Decoder IC) (HT- HolTek, 12- 8 Bit Address 4 Bit Data, D- Decoder)
HT12E (4 Bit Encoder IC) (HT- HolTek, 12- 8 Bit Address 4 Bit Data, E- Encoder)
HT640 (8 Bit Encoder IC)
HT648 (8 Bit Decoder IC)


                                       ASK Receiver using HT12D with use of Microcontroller


                                                   ASK 4 Bit Transmitter using HT12E

Applications: -

 1) Home Automation
 2) Wireless Robot
 3) Industrial Purpose

AVR Programmer


this is the circuit diagram or PCB Latyout of AVR Programmer uses DB9 Connector
i am going to upload 1 more image later which is used to show Component places....

Interfacing Temperature Sensor – LM35 with AVR Microcontroller

By interfacing different types of sensors with our MCU we can sense the environment and take decisions, in this way we can create "smart" applications. There are wide variety of sensors available. In this tutorial we will learn about a popular sensor LM35 which is precision centigrade temperature sensor. It can be used to measure temperature with accuracy of 0.5 degree centigrade. We can interface it easily with AVR MCUs and can create thermometers, temperature controller, fire alarms etc.

LM35

LM35 by National Semiconductor is a popular and low cost temperature sensor. It is also easily available. It has three pins as follows.
The Vcc can be from 4V to 20V as specified by the datasheet. To use the sensor simply connect the Vcc to 5V ,GND to Gnd and the Out to one of the ADC (analog to digital converter channel). The output linearly varies with temperature. The output is
10MilliVolts per degree centigrade.
So if the output is 310 mV then temperature is 31 degree C. To make this project you should be familiar with the ADC of AVRs and also using seven segment displays. Please refer to following articles.
  • Using the ADC of AVRs.
  • Using Seven Segment Display.
  • Using Seven Segment Display in Multiplexed Mode.
The resolution of AVRs ADC is 10bit and for reference voltage we are using 5V so the resolution in terms of voltage is
5/1024 = 5mV approx
So if ADCs result corresponds to 5mV i.e. if ADC reading is 10 it means
10 x 5mV = 50mV
You can get read the value of any ADC channel using the function
ReadADC(ch);
Where ch is channel number (0-5) in case of ATmega8. If you have connected the LM35's out put to ADC channel 0 then call
adc_value = ReadADC(0)
this will store the current ADC reading in variable adc_value. The data type of adc_value should be int as ADC value can range from 0-1023.
As we saw ADC results are in factor of 5mV and for 1 degree C the output of LM35 is 10mV, So 2 units of ADC = 1 degree.
So to get the temperature we divide the adc_value by to
temperature = adc_value/2;
Finally you can display this value in either the 7 segment displays by using the Print() function we developed in last tutorial or you can display it in LCD Module. To know how to display integer in 7 segment displays and LCD Modules see the articles.
  • Multiplexed Seven Segment Display.
  • Using LCD Modules with AVRs.
In this tutorial I have used three 7 segment displays to show the temperature. I have used the xBoard MINI - ATmega8 board to make the project. The complete program is given below.

Program (AVR GCC)


#include
#include
#include
#define SEVEN_SEGMENT_PORT PORTD
#define SEVEN_SEGMENT_DDR DDRD
uint8_t digits[3]; //Holds the digits for 3 displays
void SevenSegment(uint8_t n,uint8_t dp)
{
/*
This function writes a digits given by n to the display
the decimal point is displayed if dp=1
Note:
n must be less than 9
*/
if(n<10)
{
switch (n)
{
case 0:
SEVEN_SEGMENT_PORT=0b00000011;
break;
case 1:
SEVEN_SEGMENT_PORT=0b10011111;
break;
case 2:
SEVEN_SEGMENT_PORT=0b00100101;
break;
case 3:
SEVEN_SEGMENT_PORT=0b00001101;
break;
case 4:
SEVEN_SEGMENT_PORT=0b10011001;
break;
case 5:
SEVEN_SEGMENT_PORT=0b01001001;
break;
case 6:
SEVEN_SEGMENT_PORT=0b01000001;
break;
case 7:
SEVEN_SEGMENT_PORT=0b00011111;
break;
case 8:
SEVEN_SEGMENT_PORT=0b00000001;
break;
case 9:
SEVEN_SEGMENT_PORT=0b00001001;
break;
}
if(dp)
{
//if decimal point should be displayed
//make 0th bit Low
SEVEN_SEGMENT_PORT&=0b11111110;
}
}
else
{
//This symbol on display tells that n was greater than 9
//so display can't handle it
SEVEN_SEGMENT_PORT=0b11111101;
}
}
void Wait()
{
uint8_t i;
for(i=0;i<10;i++)
{
_delay_loop_2(0);
}
}
void Print(uint16_t num)
{
uint8_t i=0;
uint8_t j;
if(num>999) return;
while(num)
{
digits[i]=num%10;
i++;
num=num/10;
}
for(j=i;j<3;j++) digits[j]=0;
}
void InitADC()
{
ADMUX=(1<
ADCSRA=(1<
}
uint16_t ReadADC(uint8_t ch)
{
//Select ADC Channel ch must be 0-7
ch=ch&0b00000111;
ADMUX|=ch;
//Start Single conversion
ADCSRA|=(1<
//Wait for conversion to complete
while(!(ADCSRA & (1<
//Clear ADIF by writing one to it
ADCSRA|=(1<
return(ADC);
}
void main()
{
uint16_t adc_value;
uint8_t t;
// Prescaler = FCPU/1024
TCCR0|=(1<
//Enable Overflow Interrupt Enable
TIMSK|=(1<
//Initialize Counter
TCNT0=0;
//Port C[2,1,0] as out put
DDRB|=0b00000111;
PORTB=0b00000110;
//Port D
SEVEN_SEGMENT_DDR=0XFF;
//Turn off all segments
SEVEN_SEGMENT_PORT=0XFF;
//Enable Global Interrupts
sei();
//Enable ADC
InitADC();
//Infinite loop
while(1)
{
//Read ADC
adc_value=ReadADC(0);
//Convert to degree Centrigrade
t=adc_value/2;
//Print to display
Print(t);
//Wait some time
Wait();
}
}
ISR(TIMER0_OVF_vect)
{
static uint8_t i=0;
if(i==2)
{
i=0;
}
else
{
i++;
}
PORTB=~(1<
SevenSegment(digits[i],0);
}

How to interface keypad with AVR microcontroller (ATmega16)



Keypad is most widely used input device to provide input from the outside world to the microcontroller. The keypad makes an application more users interactive. The concept of interfacing a keypad with the ATmega16 is similar to interfacing it with any other microcontroller. The article of Interfacing keypad with 8051 can be referred for detailed description of the methodology used here. This article explains the interfacing of a 4x3 keypad with AVR Microcontroller (ATmega16) and displaying the output on a LCD.
The algorithm and detailed explanation for keypad interfacing is given in above mentioned article. The brief steps to interface the keypad with AVR are written below:
1. Configure the row pins or column pins.
2. Make all output pins to low and input pins to high.
3. Keep monitoring the port value, where the key pad is connected.




Program related to this Project: -


// Program to get input from keypad and display it on LCD.
#include
#include
#define pad PORTD
#define r1 PD0
#define r2 PD1
#define r3 PD2
#define r4 PD3
#define c1 PD4
#define c2 PD5
#define c3 PD6
void check1(void);
void check2(void);
void check3(void);
void check4(void);
#define LCD_DATA PORTA //LCD data port
#define ctrl PORTB
#define en PB2 //enable signal
#define rw PB1 //read/write signal
#define rs PB0 //resister select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
unsigned int press;
int main()
{
unsigned char value;
DDRA=0xff; //LCD_DATA port as output port
DDRB=0x07; //signal as out put
DDRD=0x0F;
pad=0xf0;
init_LCD(); //initialization of LCD
LCD_write_string("press a key");
LCD_cmd(0xc0);
while(1)
{
PORTD=0xF0; //set all the input to one
value=PIND; //get the PORTD value in variable “value”
if(value!=0xf0) //if any key is pressed value changed
{
check1();
check2();
check3();
check4();
}
}
return 0;
}
void check1(void)
{
//DDRD = 0xf0;
pad =0b11111110;
//pad &= (0<
_delay_us(10);
if(bit_is_clear(PIND,c1))
LCD_write('1');
else if(bit_is_clear(PIND,c2))
LCD_write('2');
else if(bit_is_clear(PIND,c3))
LCD_write('3');
}
void check2(void)
{
pad=0b11111101;
/pad &= (0<
_delay_us(10);
if(bit_is_clear(PIND,c1))
LCD_write('4');
else if(bit_is_clear(PIND,c2))
LCD_write('5');
else if(bit_is_clear(PIND,c3))
LCD_write('6');
}
void check3(void)
{
pad=0b11111011;
//pad &= (0<
_delay_us(10);
if(bit_is_clear(PIND,c1))
LCD_write('7');
else if(bit_is_clear(PIND,c2))
LCD_write('8');
else if(bit_is_clear(PIND,c3))
LCD_write('9');
}
void check4(void)
{
pad =0b11110111;
//pad &= (0<
_delay_us(10);
if(bit_is_clear(PIND,c1))
LCD_write('#');
else if(bit_is_clear(PIND,c2))
LCD_write('0');
else if(bit_is_clear(PIND,c3))
LCD_write('*');
}
void init_LCD(void)
{
LCD_cmd(0x38); //initializtion of 16X2 LCD in 8bit mode
_delay_ms(1);
LCD_cmd(0x01); //clear LCD
_delay_ms(1);
LCD_cmd(0x0E); //cursor ON
_delay_ms(1);
LCD_cmd(0x80); // ---8 go to first line and --0 is for 0th position
_delay_ms(1);
return;
}
void LCD_cmd(unsigned char cmd)
{
LCD_DATA=cmd;
ctrl =(0< // making RS and RW as LOW and EN as HIGH
_delay_ms(1);
ctrl =(0< // making RS, RW , LOW and EN as LOW
_delay_ms(50);
return;
}
void LCD_write(unsigned char data)
{
LCD_DATA= data;
ctrl = (1< // making RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1< // making EN and RW as LOW and RS HIGH
_delay_ms(50); // give a 10 milli second delay to get thigs executed
return ;
}
void LCD_write_string(unsigned char *str) //take address vaue of the string in pionter *str
{
int i=0;
while(str[i]!='\0') // loop will go on till the NULL charaters is soon in string
{
LCD_write(str[i]); // sending data on CD byte by byte
i++;
}
return;
}
while(1)
{
PORTD=0xF0; //set all the input to one
value=PIND; //get the PORTD value in variable “value”
if(value!=0xf0) //if any key is pressed value changed
{
check1();
check2();
check3();
check4();
}
}
4. If there is any change in port value, make one of the output pin of port to zero and rest all high.
void check1(void)
{
//DDRD = 0xf0;
pad =0b11111110;
//pad &= (0<
_delay_us(10);
if(bit_is_clear(PIND,c1))
LCD_write('1');
else if(bit_is_clear(PIND,c2))
LCD_write('2');
else if(bit_is_clear(PIND,c3))
LCD_write('3');
}
5. If any of input pin found zero, write the particular pin data to LCD, else continue with the step (4).


 
Copyright Electronics Projects And Details All Rights Reserved
ProSense theme created by Dosh Dosh and The Wrong Advices.
Blogerized by Alat Recording Studio Rekaman.