| View previous topic :: View next topic |
| Author |
Message |
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Mon Dec 12, 2005 12:19 am Post subject: The P16F84A simple frequency meter is ready ! |
|
|
The P16F84A simple frequency meter is ready !
It will be discussed here. _________________ BrunoG, Administrator |
|
| Back to top |
|
hugo Guest
|
Posted: Wed Mar 08, 2006 4:26 am Post subject: overflow |
|
|
Hi,
For a 16 MHz crystal we have:
while(ovrflw < 15626) ; //15625 = 16 000 000 / 4 * 256
what will be the right value for a 20MHz crystal:
while(ovrflw < 19532) ; //19531.25 = 20 000 000 /4*256
Thanks |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Wed Mar 08, 2006 9:51 am Post subject: |
|
|
Hi Hugo,
I would better use 19531 which is closer to computed value 19531.25.
By the way, the accuracy should not differ that much between the two values !
Thanks, _________________ BrunoG, Administrator |
|
| Back to top |
|
yylee
Joined: 30 May 2006 Posts: 15 Location: Miri
|
Posted: Sun Jul 09, 2006 1:28 pm Post subject: |
|
|
Why the 256 have to multiply by 4? Where does the '4' come from? Thank. _________________ Look ever forward |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Mon Jul 10, 2006 1:28 am Post subject: |
|
|
| yylee wrote: | | Why the 256 have to multiply by 4? Where does the '4' come from? Thank. |
In a pic, the frequency of the oscillator is divided by 4, so with a 16 Mhz cristal, 16 000 000 / 4 = 4 000 000 instructions par second are done, and the timer is incremented 4 000 000 times per second.
the interrupt is called on each timer overflow,when the timer counter overflows from 255 to 0.
That's why the interrupt is called 16 000 000 / 4 / 256 = 15 625 times per second. _________________ BrunoG, Administrator |
|
| Back to top |
|
yylee
Joined: 30 May 2006 Posts: 15 Location: Miri
|
Posted: Mon Jul 10, 2006 6:25 am Post subject: |
|
|
Thanks! Any suggestion where I can find more info about the theory behind the microcontroller? Thank. _________________ Look ever forward |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Wed Jul 19, 2006 8:21 am Post subject: |
|
|
Hi,
I suggest you to read the very good book of Nebojsa Matic "PIC Microcontrollers" :
http://www.mikroe.com/en/books/picbook/picbook.htm
It is on-line, and it is free ! _________________ BrunoG, Administrator |
|
| Back to top |
|
Ford
Joined: 15 Nov 2006 Posts: 6
|
Posted: Wed Nov 15, 2006 3:12 am Post subject: Nebojsa |
|
|
Hehe, I'm sorry but i must write punchline
Literal translation of the name "Nebojsa" is "dreadnought", meaning someone, who is not afraid (anything, anywhere, against nothing). |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Wed Nov 15, 2006 9:48 am Post subject: |
|
|
So "Nebojsa Matic" is the one who is not afraid of autoMatic process ?
If he can read this, maybe he will give the answer  _________________ BrunoG, Administrator |
|
| Back to top |
|
Clonus
Joined: 15 Jun 2007 Posts: 3
|
Posted: Fri Jun 15, 2007 3:33 am Post subject: |
|
|
This example is just what I've been looking for, however, I am having a helluva time getting the output to be correct.
I am using a 16f84a at 20mhz, with the minor mod listed above.
I get nothing but garbage from the serial output.
Is there a modification for this?
It would be nice to have a working piece of code.
thanks! |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Fri Jun 15, 2007 8:30 am Post subject: |
|
|
Hello,
I tried to build the project with the source code from the web page example, and I noticed that the soft UART init function prototype has changed since last mikroC revision, please use now :
| Code: | | Soft_Uart_Init(PORTB, 1, 2, 38400, 0) ; |
and it will work fine.
The change has been reported to the web page, thank you for your report.
If you still get garbage on your terminal, please try a slower baud rate.
hallelujah ! _________________ BrunoG, Administrator |
|
| Back to top |
|
Clonus
Joined: 15 Jun 2007 Posts: 3
|
Posted: Fri Jun 15, 2007 10:23 pm Post subject: |
|
|
oh yes, sorry, soft_uart_init did change as well. glad you noticed.
besides this, I still get garbage at both higher and lower baud rates. If I compile even a simple "hello world" application I still get garbage.
I tried with MikroC < never works
PicBasic < works just fine.
Also, after all my troubles I noticed that PicBasic has a "Count" command to test frequency on a port. Have you ever tried comparing the results?
Just trying to save myself a hundred bucks by building something simple.
thanks
clonus |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Sat Jun 16, 2007 11:23 am Post subject: |
|
|
You still get garbage ?
It should workd at first try with a 1200-8-N-1 serial communication line
I tested my PIC16F84A serial output frequency meter with a function generator and it is ok for the range I mention, but I don't know what you can expect from the picbasic count routine
you can try to wake up this thread :
http://www.micro-examples.com/forums/viewtopic.php?t=106 _________________ BrunoG, Administrator |
|
| Back to top |
|
Clonus
Joined: 15 Jun 2007 Posts: 3
|
Posted: Mon Jun 18, 2007 2:34 am Post subject: |
|
|
1200 is too low a baud rate at 20mhz, so i tried 2400, still no luck [/img] |
|
| Back to top |
|
BrunoG Site Admin
Joined: 22 Nov 2005 Posts: 636
|
Posted: Mon Jun 18, 2007 8:28 am Post subject: |
|
|
Can you please send me you full mikroC folder of this project by email ?
I will check on my hardware _________________ BrunoG, Administrator |
|
| Back to top |
|
|