??? 11/14/04 20:33 Read: times |
#81142 - RE: Servo control Responding to: ???'s previous message |
Hi Neo,
By the title of your post, I expect you want to close a control loop of some sort. I'm guessing the sample period is to be 1 millisecond. Rather than consuming the processor time resource to decrement and test a counter, why not devote an internal timer interrupt to autonomously count and give an interrupt every 1 millisecond. Using an interrupt as a timer will give you (1) more time for loop closure activities and, (2) the freedom to alter loop closure activities without changing the timer preload value every time the number of clock cycles needs to change due to a change in the loop closure activities. You'll only need to test your loop closure activity for execution time so that it doesn't exceed (1 millisecond - the interrupt service time). If you so choose, the 1 millisecond could be a heartbeat in which the interrupt service routine would increment one or more variables used as counters of 1 millisecond increments. Non-critical activities unrelated to loop closure could then be allocated to times greater than a 1 millisecond sample period. A non-timed loop would test the value of each variable and when equal to a desired value, control is transferred to a section of code to be run at the sample period associated with the variable. This is an example of a 'poor man's task scheduler'. It works quite well for periodic tasks requiring a variable priority. It does not suspend tasks in favor of a higher priority task and then return control to the suspended task after the higher priority task is complete, but if you're reasonably modest in the allocation of tasks, it'll work just fine. Cheers, Bruce |
Topic | Author | Date |
Servo control | 01/01/70 00:00 | |
RE: Servo control | 01/01/70 00:00 | |
RE: Servo control | 01/01/70 00:00 | |
RE: Servo control | 01/01/70 00:00 | |
RE: Servo control![]() | 01/01/70 00:00 |