Free online courses with Free Certificate
Keil c51:
DevC++ compiler(or IDE)
Download link: Click here
step-1: right click on "Keil uvision" and click on "run as administrator"
step-2: now go to project >> new project >> "project_name.uvproj"
step-3: select "at89c51" as shown below
step-3: now file >> new file
step-4: click on save as then save with "file_name.c" i.e. with ".c" extension
step-5: now copy code given below and paste and save it
step-6: to the left side of window right click on "Source group 1" and then click on "add existing file to source group 1"
step-7: now click on project >> build target to compile this code i.e. to check if any error in code
step-8: to generate "hex file" of this code right click on "target 1" tab to the left side of your window and then click on "options for target 'target 1'... " as shown below
step-9: now change frequency to "11.0592MHz" and tick to "use on-chip ROM" as shown below
step-10: now in same window options click on output >> tick to "create hex file" as shown below
step-11: click again on "build target" to create "hex file" as shown below
C code for 7 segment interfacing with 8051:
Code With Comments:
#include<reg51.h> //Library extention to AT89c51 microcontroller in embedded-c
void main() //main program starts from here
{
unsigned char seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//Hex number equivalent of 0 to 9
unsigned x; //declare variable x
unsigned int i; //declare integer variable i
P1=0x00;//configure port-1 as output port by sending 0x00
while(1) //this is infinite loop to see result without breaking operation
{
for(x=0;x<10;x++)//loop to run 10 times to display 0 to 9
{
P1=seg[x];//send segment of 0 to 9 as declared above
for(i=0;i<60000;i++);//delay of certain seconds set between two numbers to be displayed
}
}
}
Code without comments (for simplicity)
#include<reg51.h>
void main()
{
unsigned char seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned x;
unsigned int i;
P1=0x00;
while(1)
{
for(x=0;x<10;x++)
{
P1=seg[x];
for(i=0;i<60000;i++);
}
}
}
Free online courses with Free Certificate
Proteus:
Download link: Click here !
step-1: right click on "Proteus 8 professional"(whichever version available) and "run as administrator"
step-2: now go to project >> new project >> "New Project.pdsprj"
step-2: click on "P" and open window for "pick devices" as shown below
step-3: now type "at89c51" and select microcontroller then press ok
step-4: now type "7 segment display" and select "7 segment display common anode" as shown below
step-5: now draw circuit as shown below
step-6: click on "terminal" icon to left side window and then select "power" label and connect to 7 segment display as shown below
step-7: now double click on microcontroller symbol then "edit component" window will open. then click on "folder symbol" to select ".hex" file and change frequency to 11.0592MHz as shown below
Note- make sure you know path of ".hex" file generated through Keil c51
e.g. - ..\..\..\Keil_v5\C51\Examples\my project\Objects\7segment 8051.hex
step-8: click on "play button" and check output as shown below
Check actual simulation in GIF format as shown below
If you found any difficulty or any suggestions please comment below or contact me on "pangfreelearner@gmail.com".
And also visit my YouTube channel for "Free online courses with Free certificate" on below link.
Free online courses with Free Certificate
Join Facebook group for Free online courses with Free certificate
Thank you.
PANG.
No comments:
Post a Comment