I have first to thank everyone for responding quickly.
The problem with my RPM calculation is that it needs to be fairly precise and in fairly close to real time. The preferred device I have to count is an optical counter which will have a wheel and blank spaces so I have the option of counting either the length of the width of the blank space or of the null from the disk. High or low pulse counting option is what I am looking at. I really need to count the specific one pulse width issue and maybe keep a sum of these like 5 in a stack because this is fairly "now" use data.
The next thing I need to do is execute a pulse to do my control function that varies in length with RPM. (Function of degrees of turn of the device and latency of the control circuit) This I expect will be on a lookup or a formula depending on the math I can do. This pulse will be executed a period of time delay after the timing (RPM count) pulse comes in and will execute a turn off of the pulse after a short period of time based on the RPM.
I am needing help figuring out the way to count the pulse so that the counter does not affect timer accuracy and responds with about 1/10,000 sec accuracy.
The RPM will be slow relative to some of the response posts. It will be 0-1,800 RPM. At this time it is more likely to stay below 600 RPM. The device will have extreme torques on it allowing a substantial variance of the RPM in time so I need to respond in real time. It may seem that the speed of response is not critical but the device is definitely needing this accuracy. 1/1,000 it too inaccurate. Honestly I would like to push it closer to 1/100,000 sec.
If somebody thinks Hall Effect is better for this I can use it. The latency is the issue. The sensor latency needs to be low. I am looking at 1/1000 to 5/1000 delay in the sensor as is. Circuit delays are real issues in this device. If somebody knows a sensor with wheel package already done up I am all ears.
So I have 2 issues. Pulse width measuring or RPM counting by other means and timer interrupt On and timer interrupt off counting without the first timer failing the operations of the second timer.
This could be 3 timers operating, I expect that. (1) to keep up with RPM. (2) To time the initiation pulse ON condition. (3) To time the initiation of Pulse Off condition.
Better Ideas are always welcome.
The method I mentioned above will give you an almost instantaneous rpm reading, so long as you can figure out how to keep good track of time (that's up to you, I'll help you along, others here will help you along, somebody here might spell it out for you and even write the whole program, but I, for one, am not going to write the complete code for you).
You read one pulse, save the time that pulse happened (read one of the timers), you read the next pulse, save the time the 2nd pulse happened, and subtract the 1st pulse from it. Read the 3rd pulse, subtract the 2nd pulse from it, etc.etc.
After reading a pulse, do the math on it, reciprical functions (i.e. 1 pulse per second = 1 rpm, 2 pulses per second = 2 rpm, etc., less time per pulse = more rpm).
Assuming you use PBP math functions to do the multiplication/division on it, you could easily get a solution within 1/1000 of a second. Use a few look-up tables and a fast PIC, and that number could go down into the microseconds.
As far as controlling whatever you are controlling, you're looking at using a PID control loop to keep the rpm constant under varying loads. It's the same principle with microprocessor controlled voltage regulators, only an electrical load vs. a mechanical load.
And give a hard thought about what you really NEED vs. what YOU want . I can't think of very many things that need instantaneous correction within one us...and I can think of fewer things that can possibly respond inside of a handful of microseconds, much less 10 us.
I have really only wanted a basic description of the process solution. I am not asking for code so much as use timerO to count ... and timer1 to count. This is sort of a process thing rather than expecting detailed answers. I did ask and get a detail question on pull-up resistors because I simply didn't know the answer for sure. Thanks all
Bookmarks