Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/26/04 11:54
Read: times


 
#74878 - RE: single crystal
Responding to: ???'s previous message

Most microprocessors can do quite an amount of work in 1/100th of a second, even in 1/1000th of a second, so why so many micro's for such a simple task? From my simple understanding all the micro has to do is:

1/ Have a counter ticking over at a given rate
2/ sample a number of inputs to see if there is a change - if so, grab the current timer value and flag the change.
3/ report times to the PC

having 41 inputs may produce a bit of a challenge - you may need to choose a speedier microprocessor - but not 41 of them!

You don't need to use external interrupts in this instance - each timer tick you read all the inputs, then determine which one has changed. You must sample at least twice the minimum tick you need. Say 1/100th second resolution, sample at 200hz and you will be able to resolve 1/100th sec +/- 1/200th sec. Having one micro means your timing is synchronised as well as not having to worry about high speed clock distribution.



simple psuedocode example:

main:
load timer for 200hz
clear queue
clear tick counter
start interrupts

loop:
if queue has a time sample then
get time sample from queue
print time sample to pc
goto loop


timer_interrupt:
reload timer
read inputs into memory
while number of inputs do
if input has changed then
read tick counter value
store tick counter value and input# into queue
next input
wend
if odd tick, increment the tick counter
return from interrupt

end.

You need to implement a fifo queue to store the tick counts. Do a search on 'fifo' and 'queue'
Shouldn't be a problem fitting this into a 89S2051 - you might run out of port pins though!










List of 18 messages in thread
TopicAuthorDate
single crystal            01/01/70 00:00      
   RE: single crystal            01/01/70 00:00      
      RE: single crystal            01/01/70 00:00      
         RE: single crystal            01/01/70 00:00      
            RE: single crystal            01/01/70 00:00      
   RE: single crystal            01/01/70 00:00      
   RE: single crystal            01/01/70 00:00      
   RE: single crystal            01/01/70 00:00      
      RE: single crystal            01/01/70 00:00      
   RE: single crystal            01/01/70 00:00      
      RE: single crystal            01/01/70 00:00      
         RE: single crystal            01/01/70 00:00      
            RE: single crystal            01/01/70 00:00      
            RE: single crystal            01/01/70 00:00      
               RE: single crystal            01/01/70 00:00      
                  RE: single crystal            01/01/70 00:00      
            RE: single crystal            01/01/70 00:00      
               RE: single crystal            01/01/70 00:00      

Back to Subject List