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
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.
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.
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.
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.
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!
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 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.
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.
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.