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.

[SOLVED] frequency counter using 16f84a

Status
Not open for further replies.

Ajay_sho

Junior Member level 1
Joined
Oct 19, 2010
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,430
Hi sir
i m new for this forum, i m making project freq. counter based on weedr technology,i hav take schamatic from weeder , i hav one problem when i was connecting 74hc132 output pin to microcontroller rtcc pin then drtamatically voltage of signal goes down from 2.5 to .5 v and hence no pulse entering through rtcc.pls tell why amplitude of input signal goes down when i m connecting with rtcc pin of 84a.
rgds
ajay singh:cry:
 

yes that is T0ckl
Thx
Ajay

---------- Post added at 16:44 ---------- Previous post was at 15:02 ----------

hi brian
pls reply ,my problem is same as it is, can anyone help me .
rgds
ajay
 

Assuming you are using the correct pins, the most likely reason is that you have not made the T0CKI pin an input and it is pulling the output of the 74HC132 low.
Check that bit 4 of the TRISA is set to '1' to make the pin an input. Incidentally, why are you using the 74HC132 when the pin has Schmitt trigger anyway?

Brian.
 

thx for reply
i have make the pin input pls look at my code, i have one dought that i hav connected mclr pin with10k resistoris it o.k. or their is problem in my code
void main()
{
asm clrwdt ;

TRISB = 0;
// PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 1, text); // Print text to LCD, 2nd row, 1st column
asm BSF STATUS,RP0 ;
OPTION_REG= 110000;
TRISA=00010000;
PORTA=00010000;
asm BCF STATUS,RP0;
TMR0=0;
while(1)
{
porta.f3=0;
porta.f2=0;
j=0;
cnt=0;
porta.f2=1;
porta.f2=0;
tcc=0;
tmr0=0;

porta.f3=1;

for(a=0;a<=20;a++)
{

for(b=0;b<=250;b++)
{
if(tcc>tmr0)
{
cnt++;
tcc=tmr0;
}
else
{
tcc=tmr0;
}

}
}
porta.f3=0;
j=tmr0;
dec_ascii(j);


}

}
 

10K between MCLR and +5 is good.

In your code, you may not be setting the registers correctly. For example, are you sure that "TRISA=00010000;" is using the binary number 00010000 and not the decimal equivalent 10,000 ?
I am not sure which compiler you are using but check if binary numbers need a prefix like "b" in front of them. Alternatively, use hexadecimal so it would be TRISA=0x10;

Brian.
 

i m using mikroelectronika compiler ,after making input T0CKI ,i m not getting 5 v on that pin,it is showing 0v, might that pin got damaged, that's why it is not receiving pulses,i will check after changing microcontroller,what do u think.

ajay
 

The IC could be faulty but I still think your code is not using binary so you are setting the registers to the wrong values.
Quote from the Mikro help file:
Binary
All constants starting with 0b (or 0B) are taken to be binary. In the absence of any overriding suffixes, the data type of an binary constant is derived from its value, according to the rules presented above. For example, 0b11101 will be treated as short.

Try placing '0b' in front of the binary numbers you use or use hexadecimal instead.

You should read 0V on the TOCKI pin unless you drive it high externally. Try disconnecting the 74HC132 and connect a 10K resistor to +5V instead. If you then have 5V on the pin it is probably OK.

Brian.
 
my problem has been solved ,problem is in binary numbers which you have stated,thx a lot,i want one more question when i m writing asm code status equ 03H then error showing 03H not found pls advise i hav to define address somewhere in header files ,pls help how i can make header file ,have u any example of header file ,in which i can define constant and address of resistors,can u pls help me
 

I think Mikro C automatically includes the header for you, based on the processor you select for the project. I do not use Mikro C so perhaps someone else can give better advice.
The actual definition files are held in the "defs" folder. On my system they are here: C:\Program Files\Mikroelektronika\mikroC PRO for PIC\defs

Brian.
 

hi brian can you tell me how i can use absolute directive in mikroc also pls advise how i can count m/c cycle in c statement ,so i can give 1 sec delay accurately.pls look at above post for my code.
Rgds
Ajay
 

If you click on 'Help' in the MikroC menu bar and then 'index' it will list all the commands and directives, there is an entry for 'absolute' with code examples.
For delays, again look in the help file for an explanation and examples. You can use a command to set a delay in cycles, uS or mS. For 1 second, the example suggests Delay_ms(1000).

You should be careful in C programming if you build delays out of instructions being executed. The language has optimizations which may rearrange the code being produced without your knowledge. For example, you might find that changing a line of code somewhere else in your program makes the optimizer change the number of m/c instructions in your delay routine, making it inaccurate. If you need to accurately time how long a routine takes, use "View › Debug Windows › Stopwatch".

Brian.
 

dear brian as you no i m making freq. counter based on weeder tech. i want weeder asm code in c , so need your help how i can convert that asm code in mikroc.their i m finding too much difficulty .
first: timing calculation is based on no of instruction(no. of m/c cycle), which i m unable to access in c how many m/c cycle is their in one c statement, and
second: if i m going to copy that asm code in my c code then their is problem of variables, which is used in asm .
 

I do not think the Weeder asm file will convert easily to MikroC. You would have to wrap the whole asm code inside an "asm{ }" statement.
The biggest problem is not the timing, it is the LCD interface. The 74HC132 is arranged as a latch and it is triggered by one of the LCD control lines. If you substitute MikroC code it will change the latch timing and give a wrong frequency reading. By all means use the electrical design but I would strongly advise you to make a flow chart of the original weeder code and then make a completely new program in C to do the same job.
I would also advise you to use a 16F628A instead of the 16F84A. It costs less and if you configure it so MCLR is internally tied high, it gives you an extra pin to use to drive the 74HC132, this will make the code much easier to write.

Brian.
 

hi brian i m at the last stage of project my all problem has been solve my next project will be LC meter using 16f628. i will back to you sooner.
thanks/rgds
ajay
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top