![]() |
![]() |
![]() |
|
|
|||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
New Member
|
Hey everyone!
I wanted to know whether anyone has a C-Code which is measuring the frequency (50-60Hz, or a bit less or more) using timers and the Capture mode of the CCP modules. I'm working with the PIC16F877 and using the CCS compiler. I know it's not difficult to write such a programm, I just don't have the time to do it now Any help is appreciated! cheers
__________________
|
|
|
|
|
|
(permalink) |
|
Experienced Member
|
But you have plenty of time to read through someone else's code so you can understand it and adapt it for your own purposes. Is that right?
Assuming you can count zero crossings or rising edges or some other feature of your waveform, you just count them for one second and the number is the frequency.
__________________
We never have time to do it right; but we always have time to do it over. |
|
|
|
|
|
(permalink) |
|
Experienced Member
|
What is the precision required?
If you don't need much precision, you can do it with only I/O operations, and counting into some defined variables, that wont take 5 minutes if you have some C experience. |
|
|
|
|
|
(permalink) |
|
New Member
|
ikalogic, thanks for trying to help, but i've written the code myself meanwhile using interrupts, etc.
Papabravo, I never meant to go through other people's codes, I just needed this one to do some simulation tests. I'm actually pretty good with programming in C, so there's no need for you to be offensive. I never meant to harm anyone here.
__________________
|
|
|
|
|
|
(permalink) |
|
Experienced Member
|
I was most certainly not trying to be offensive and I'm sorry you took it that way. I was trying to say that it would certainly take about the same amount of time to utilize some code from somewhere else as it would to write it.
__________________
We never have time to do it right; but we always have time to do it over. |
|
|
|
|
|
(permalink) |
|
Experienced Member
|
it is very accurate to use a capture register to measure the time between zero crossings. I had forgotten just how over priced PICs were! Use what you want, but I wouldn't touch those things!
|
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
|
|
|
|
|
|
|
(permalink) |
|
Experienced Member
|
i look at performance for the dollar. if you get 20 MIPS and need twice as many instructions you might as well only be getting 10.
If you are paying $8 (single piece price at digikey for the part he mentioned) when a $4 in singles part has what you need then the $8 part is way overpriced. |
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
__________________
Regards, Sarma. |
|
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
__________________
Regards, Sarma. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| PIC code protection | arhi | Micro Controllers | 2 | 28th April 2008 11:49 PM |
| Convert serial LCD code into parallel LCD.. Help please.. | AntRoFiZ | Micro Controllers | 10 | 22nd May 2007 01:07 PM |
| what is a microcontroller made of ? | pinblaster73 | Micro Controllers | 9 | 16th May 2007 04:48 AM |
| Problem with Code: Help | Electrix | Micro Controllers | 7 | 29th September 2005 07:42 PM |
| Z8 Encore C code samples needed | Scruit | Electronic Projects Design/Ideas/Reviews | 4 | 29th July 2004 01:58 AM |