Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


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.

Reply
 
Thread Tools Display Modes
Old 11th May 2008, 06:30 PM   (permalink)
New Member
mrrmot is on a distinguished road
Post Needed! C-code frequency measurment

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
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 11th May 2008, 10:49 PM   (permalink)
Experienced Member
 
Papabravo is a glorious beacon of lightPapabravo is a glorious beacon of lightPapabravo is a glorious beacon of lightPapabravo is a glorious beacon of light
Default

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.
Papabravo is offline   Reply With Quote
Old 11th May 2008, 11:31 PM   (permalink)
Experienced Member
 
ikalogic is just really niceikalogic is just really niceikalogic is just really nice
Send a message via MSN to ikalogic Send a message via Skype™ to ikalogic
Default

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.
__________________
Ibrahim Kamal
check my electronics and robotics page: http://www.ikalogic.com/
ikalogic is offline   Reply With Quote
Old 12th May 2008, 12:51 AM   (permalink)
New Member
mrrmot is on a distinguished road
Default

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.
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 12th May 2008, 01:25 AM   (permalink)
Experienced Member
 
Papabravo is a glorious beacon of lightPapabravo is a glorious beacon of lightPapabravo is a glorious beacon of lightPapabravo is a glorious beacon of light
Default

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.
Papabravo is offline   Reply With Quote
Old 12th May 2008, 10:46 AM   (permalink)
Experienced Member
Ubergeek63 is a jewel in the roughUbergeek63 is a jewel in the rough
Default

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!
Ubergeek63 is offline   Reply With Quote
Old 12th May 2008, 12:44 PM   (permalink)
Experienced Member
 
Blog Entries: 4
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

Quote:
Originally Posted by Ubergeek63
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!
Shop around, they're cheap. Guess it also depends on where you are in the world.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Old 12th May 2008, 03:55 PM   (permalink)
Experienced Member
Ubergeek63 is a jewel in the roughUbergeek63 is a jewel in the rough
Default

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.
Ubergeek63 is offline   Reply With Quote
Old 12th May 2008, 05:35 PM   (permalink)
Experienced Member
mvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to all
Send a message via MSN to mvs sarma Send a message via Yahoo to mvs sarma
Default

Quote:
Originally Posted by Ubergeek63
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!
I have my own doubts on the accuracy of the zero crossing mechanism at the raising edge and the one at the trailing edge. Perhaps one has to count between two consecutive leading edge points to cover a full cycle.
__________________
Regards,
Sarma.
mvs sarma is online now   Reply With Quote
Old 12th May 2008, 05:43 PM   (permalink)
Experienced Member
mvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to allmvs sarma is a name known to all
Send a message via MSN to mvs sarma Send a message via Yahoo to mvs sarma
Default

Quote:
Originally Posted by Ubergeek63
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.
I fear that when we are at experimental stage and purchase chips at 2 off (I always order for minimum 2 pieces for the sake of redundancy) On line orders are generally costly. Even going to a shop to get small quantities is not cost worthy, either. As rightly pointed by Bluroomelectronics, orders on international firms is very costly even when they operate from inside your country. For example, see the prices of M/s R.S Components. these are normal. Many times, I look at the issue with comfort, that, at least someone is giving a single or 2 pieces of a specific chip.
__________________
Regards,
Sarma.
mvs sarma is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 04:56 AM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.