Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[51] counter to display the count when 2Hz frequency is applied on on 3.5 port

Status
Not open for further replies.

poojaghorpade

Newbie level 4
Newbie level 4
Joined
Feb 24, 2014
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
71
Actually i want to display the count when 2Hz frequency is applied on 3.5 port of 89LV51....
Below i am attaching my code...
I am not getting output for code plz help me out .........
 

Attachments

  • counter.txt
    1.3 KB · Views: 76
Last edited:

How long do you open the time window to examine the incoming waveform?

2 Hz frequency means one cycle per 1/2 second. Therefore your code must watch the incoming signal for at least 1/2 second, to count one cycle.

The code does not need to watch uninterrupted all that time, but it needs to sample the incoming signal often enough so it can notice crests, troughs, zero transitions, etc.

----------------------

Also you need to make sure your signal's amplitude reaches a high enough and low enough voltage, so that your device recognizes its crests and troughs.

----------------------

Edited to change interrupted to uninterrupted, and to add last paragraph.
 
Last edited:

Once input reading is not being done through interrupt service, I believe the delay command you posted at line #27 - presumably scaled for 1s - could yield some problem:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include<reg51.h>
#include<stdio.h>
#include<string.h>
 
#ifdef reg51.h
 
sbit rs=P2^2;
sbit rw=P2^1;
sbit en=P2^0;
sbit busy=P0^7;
 
void lcdready();
int lcdcmd(unsigned int a);
int lcddata(unsigned char a);
int delay(unsigned int x);
int display(unsigned char);
void ascii(unsigned char value);
unsigned char msg[]={"counter"};
 
int lcdcmd(unsigned int a)
{
    lcdready();
    P0=a;
    rs=0;
    rw=0;
    en=1;
    delay(1);
    en=0;
    return;
}
 
int lcddata(unsigned char a)
{
lcdready();
    P0=a;
    rs=1;
    rw=0;
    en=1;
    delay(1);
    en=0;
    return;
}
 
void lcdready()
{
    busy=1;
    rs=0;
    rw=1;
    while(busy==1)
    {
        en=0;
        delay(1);
        en=1;
    }
    return;
}
 
int display(unsigned char msg[])
{
    unsigned char i=0;
    while(msg[i]!='\0')
    {
        lcddata(msg[i]);
        i++;
    }
    i=0;
    return;
}
    
 
int delay(unsigned int x)
{
    unsigned int i,j;
    for(i=0;i<=x;i++)
    {
        for(j=0;j<=125;j++)
    }
}
 
void main()
{
    lcdcmd(0x38);
    lcdcmd(0x0e);
    lcdcmd(0x01);
    lcdcmd(0x06);
    
    lcdcmd(0x80);
    display(msg);
    
    T1=1;
    TMOD=0x60;
    TH0=0;
    while(1);
    {
        do
        {
            TR0=1;
            value=TL0;
            ascii(value);
        }
        while(TF0==0);
        TR0=0;
        TF0=0;
    }
}
    
    
    void ascii(unsigned char value)
{
    unsigned char x,d1,d2,d3;
    x=value/10;
    d1=value%10;
    d2=x%10;
    d3=x/10;
    P0=30|d1;
    P1=30|d2;
    P2=30|d3;
}




+++
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top