Discussion in "Project Doubts" started by    isha    Jul 13, 2007.
Thu Jul 19 2007, 05:57 AM
#21
sir, plz guide me how to start programming the project "digital visitror counter " in C language??????????

 tienduhieu like this.
Thu Jul 19 2007, 01:20 PM
#22
hm... before starting that.. i want to ask you some questions.. which IDE (software for compiling) you are using? and are you familiar with that IDE? if yes then how much...
because understanding the IDE is the first important thing.
 ishatienduhieu like this.
Fri Jul 20 2007, 12:42 PM
#23
sir , i'm using keil uvision for the project, and i m familiar with that , i've used that for a counter(0-30) project.....
 tienduhieu like this.
Sat Jul 21 2007, 06:10 AM
#24
hi isha
please refer the book "Embedded C"
it is used c for programming 8051 with some useful examples suited to your requirement
and most good thing is that it use same keil
the book is already posted in the e-book download section or
click this link
http://www.8051projects.net/forum-t1260.html



[ Edited Sat Feb 16 2008, 09:13 AM ]
 tienduhieu like this.
Sat Jul 21 2007, 06:32 AM
#25
Thats good if you have already worked on it oce..
so.. simply define the ports which you are using in your project. you can define in two ways...
Fitst:
#include #define port_name port
e.g. #define abc P1
and pin can de defined as..
#define def P2_1

Second:
defining bit-
sbit abc=0x81;
defining port or other sfr
sfr def = 0x90;

after that you start writing your program in C as you write normally. you can make fuctions or simply write the whole program in a single function called main()
please start writing something afterwards i will explain you.. as you go on. :-)
 tienduhieu like this.
Tue Jul 24 2007, 06:19 PM
#26
i've defined the ports which are used in the project,
plz tell me how to initialize the timer?
and how to program the ports where transistors are attatced and the ports where ldrs are attatched????
plz reply soon
 tienduhieu like this.
Wed Jul 25 2007, 09:19 AM
#27
ok... setting up the timer is very simple. putting value in register is same like moving value to a variable. you can open the file you included "AT89X51.H" and see how the registers have defined in it.
so timer can be set like this way...
TMOD = 0x20; // timer mode setting
TH1 = 20; // put value in Timer 1 high byte
TL1 = 3; // put value in Time 1 low byte
TR1 = 1; // run the timer

this way you can do the same for timer 0 you can do.
you can enable the timer interrupt as..
ET1 = 1; // Timer 1 interrupt
EA = 1; // global interrupt

writing interrupt routine..
void timer1_isr() interrupt 3
{
// your code
TF1 = 0; // clrear Timer overflow flag
//other code
}

Interrupt numbers..
Exter. int 0 - 0
timer int 0 - 1
Exter. int 1 - 2
timer int 1 - 3
RX/Tx int - 4

similar with the ports..
P1 = 0x40; //some value
port... pin..
P1_1 = 1 or 0; // setting or clearing a pin..

checking pin is set or cleared..
if(P1_1){ //execute the code if Port 1 pin 1 is set
//code
}
else{ //execute the code if Port 1 pin 1 is clear
//code
}

or you can sometime have this way too..

if(!P1_1){ //execute the code if Port 1 pin 1 is clear
//code
}
else{ //execute the code if Port 1 pin 1 is set
//code
}

making a port o/p
P1 = 0;

making a port i/p
P1 = 0xFF;

making a port pin i/p
P1_1 = 1;

making a port pin o/p
P1_1 = 0;

Please you can move on with your code now.. if any problem tell me..
 tienduhieu like this.
Tags programming 8051 microcontroller in Cport programming in Ctimer programming in C
Thu Aug 02 2007, 07:23 PM
#28
sir, i 've started programming in C language but i'm having problems ...
why four seven segments have been used and why they are all connected to the same port? and what about their common cathodes where transistors are attathed?? how current pass through??? how to program those pins???
plz reply soon...
 tienduhieu like this.
Thu Aug 02 2007, 09:45 PM
#29
welcome back isha you came back after a long time..

anyways.. four segments are connected to same port just to save pins. otherwise you need 32 pins to connect four 7-seg but now you are just using 12 pins (4 common control and 8 data).
transistor will switch the seven segments on one by one. As you know the phenomenon "persistence of vision" of human eye.. so the 7-segments are going to be switched one by one so fast that human eye will think all of them as ON!!

this is done in C like this..

    7seg_port = 7seg_decode(digit1);
    7seg1_cathode = 1;
    some_delay();
    7seg1_cathode = 0;
    7seg_port = 7seg_decode(digit2);
    7seg2_cathode = 1;
    some_delay();
    7seg2_cathode = 0;
    7seg_port = 7seg_decode(digit3);
    7seg3_cathode = 1;
    some_delay();
    7seg3_cathode = 0;
    7seg_port = 7seg_decode(digit4);
    7seg4_cathode = 1;
    some_delay();
    7seg4_cathode = 0;


So the above thing is done continuously..
explaination:
7seg(1,2,3,4)_cathode are the pins connected to transistor. making it 1 will activate the transistor and current flows from power via LED of 7-seg to ground.
7seg_port is the port where all 7-segment displays are connected.
7seg_decode(digit variable) this function gets an input digit which is going to be displayed. for example 0 is the digit to be displayed.. but you cannot directly send 0 to the port. so what you need to do is, get which LED has to glow on 7-seg (a,b,c,d,e,f,g) the dot LED is considered usually always off or as per you need..
e.g 0 is displayed on 7-seg like this..
|¯|
|_|
So to get this u need LED a,b,c,d,e,f as on so the decoded value for zero will be
val     a   b  c  d  e  f   g   dot   Decoded
 0      1   1  1  1  1  1   0    0        0x3F

the above value is calculated as.. a is connected to Port pin 0, b with pin 1 and so on.. dot with dot with pin 7 of the port.

So once the decoded value is sent to the port.. switch the 7-seg on by switching the corresponding transistor. and then switch it off after some time.. this delay is provided by some_delay routine and the value of delay is selected according to your need.. just to avoid flickering on the display.
so this step by step switching will display the digits one by one so fast that.. user looking at the display will think that all 7-segments are ON!

I hope i am clear.. how to use 7-segments. If you still have doubt please feel free to ask
 tienduhieu like this.
Tags programming 7-segment display in C7-segment interfacing with microcontroller7-segment display7-seg led display
Fri Aug 03 2007, 05:51 PM
#30
i tried it , but same digit is displayed on all the displays, what should be done if i have to display 11, 12 , or 100 or 1122 etc....
 tienduhieu like this.

Get Social

Information

Powered by e107 Forum System

Conversation

Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html

Downloads

Comments

Istika
Thu Dec 12 2019, 12:04 PM
nabiha_anaya
Sun Dec 08 2019, 09:16 AM
ananyagupta
Tue Dec 03 2019, 07:53 AM
wells
Mon Nov 25 2019, 08:25 PM
auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM

Online

Guests: 98, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38109
Newest member: Istika
Forum Activity
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 02:26 PM
wil do.thank you for your advice!
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Dec 12 2019, 07:13 AM
Something like this ?https://www.bing.com/videos/s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Dec 12 2019, 06:58 AM
The layout is a bit different, but it is the same ...
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 04:38 AM
https://i.imgur.com/6S5FcwF.png right now im follo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Dec 10 2019, 04:49 PM
ilylily07 Avatar
Posted By ilylily07
Sun Dec 08 2019, 01:24 PM
Hi .im humbly ask for your advice as i wrongly pur...
nabiha_anaya Avatar
Posted By nabiha_anaya
Sun Dec 08 2019, 09:19 AM
My teacher assign me a project on "voice control h...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Nov 29 2019, 04:24 AM
" Is it possible to interface a fingerprint scanne...
ilylily07 Avatar
Posted By ilylily07
Thu Nov 28 2019, 03:50 PM
You will not find any code for an 8051 as no one w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 05:44 PM
You will not find any code for an 8051 as no one w...