as far as i can tell this 1. can read a max of 1khz 2. reads or counts for half a second. and 3. was going to have more inputs on port D?
as far as i can tell this 1. can read a max of 1khz 2. reads or counts for half a second. and 3. was going to have more inputs on port D?
Yes, you are correct in assuming this version reads a max of 1KHz - and that is if the input is a square wave, less if the duty cycle is not 50%.
I have used this routine successfully to read fan RPMs over 15,000.
To increase the maximum frequency you can count, you have to increase the interrupt rate. Right now, the period is 500uSec, but could be easily decreased to less than 100uSec by changing the TMR preload (use Mr. E's calculator). I chose to run my routine for 1000 counts ( .5 seconds) so that I could get acceptable resolution, but there is no "magic". You do have to run it for a defined amount of time to come up with the answer you need.
There is no limit to the number of pins you can read with this method. Theoretically, every pin on the pic could be an input.
Charles Linquist
Thanks again for posting that. i actually learned a bit from it, and have a use for it! I mentioned the portd for expansion as it was read and compared while there doesn't appear to be a fan assigned to it. this is finally starting to make sense.
You are right about reading PortD and not using the result. I use this routine across several products. Some use PortD input, some do not. Because I support so many products, I sometimes have trouble with "cross pollination". This is one of those cases. I'll comment the port read out and save a few processor cycles. I have plenty of speed, since I always use 18F8722's at 40MHz.
Charles Linquist
Bookmarks