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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/24/08 00:40
Read: times


 
#152467 - Note Length & Cadence on One Timer
Responding to: ???'s previous message
A.S.Rudra:

It should be reasonably straightforward to use one timer for the note duration and for the cadence measurements. The trick here is to not think it is necessary to directly program this timer to the length of the note. Instead program the timer for a periodic interrupt at a rate that corresponds to the resolution you need for the note timing. For example if you can do all your note lengths in one millisecond steps then program this interrupt to happen once per millisecond. The note duration then simply becomes a counter that you maintain at each occurance of the interrupt. Likewise the tone cadence, (i.e. on/off times and repeat cycle time), is managed by additional counters in the interrupt routine with one millisecond step size.

If it turns out that you can live with a resolution of 1/100th of a second instead then set this timer to run every 10 milliseconds.

Detection of the ten separate inputs as parallel GPIOs to the MCU can be easily done with minimal code in a 10-msec interrupt (or once each 10 interrupts of a 1-msec interrupt) task. You could download some input scanning code I have done in the past and modify it to suit your application. In my sample I was supporting 8 inputs and so all the variables and function arguments use unsigned char values. You could modify this to use unsigned int (16-bit) values and support parallel detection and debounce for 9 to 16 inputs. The scan routine is called from a repetitive interrupt routine (10 msec recommended) and where you input your 10 inputs simply merge them together into 10 bits of the unsigned int input value for the key scan logic. The other various routines in the module can be called by your mainline code to determine the state or status of any one of the inputs such as current state, queued going ON detection or even the queued going OFF detection.

Note that if you do end up modifying my code to support unsigned int 16-bit values you may have to consider disabling interrupts for a few instructions around the references to the global variables in the mainline routines since the 8051 type MCU can only access 8-bits at a time from a 16-bit variable and a half processed variable access could be buggered by the interrupt scan happening right at the time a variable is half referenced.

Good luck
Michael Karas


List of 44 messages in thread
TopicAuthorDate
Possibly noisy Relay/Switch Inputs            01/01/70 00:00      
   Schmitt inverter            01/01/70 00:00      
      Thanks Steve but please note change            01/01/70 00:00      
         Steve's suggestion is certainly valid!            01/01/70 00:00      
            Thanks Richard            01/01/70 00:00      
               Do you really need the optoisolators?            01/01/70 00:00      
         Why Schmitt Gates            01/01/70 00:00      
            That is the purpose of Schmidt-triggers ...            01/01/70 00:00      
   This is how I would do it            01/01/70 00:00      
      I'd probably do that too, except ...            01/01/70 00:00      
      Thanks            01/01/70 00:00      
         The waters have been muddied ...            01/01/70 00:00      
            Thanks            01/01/70 00:00      
               Yes, it's clearer, but ...            01/01/70 00:00      
                  Priority Encoder Not a Good Idea            01/01/70 00:00      
                     Yes, highest priority input would mask others            01/01/70 00:00      
                     Welcome Sir Michael Karas            01/01/70 00:00      
                        Note Length & Cadence on One Timer            01/01/70 00:00      
         Noise            01/01/70 00:00      
            It's all analog            01/01/70 00:00      
   Another way to do this            01/01/70 00:00      
   how fast do you need to detect the contacts            01/01/70 00:00      
      Hello Erik,Hello Kai,            01/01/70 00:00      
         what are you describing?            01/01/70 00:00      
            actual distance test(ohmically)            01/01/70 00:00      
               please answer questions            01/01/70 00:00      
                  Part success            01/01/70 00:00      
                     In the last analysis, it is up to you            01/01/70 00:00      
                        Provocative            01/01/70 00:00      
                           totally irrelevant            01/01/70 00:00      
                     what 'common'            01/01/70 00:00      
                     Transformerless supply...            01/01/70 00:00      
                        Thanks            01/01/70 00:00      
                           I do not understand, parallelling switches            01/01/70 00:00      
                              Absolutely deadly dangerous!!!!            01/01/70 00:00      
                              parallelling switches            01/01/70 00:00      
                                 Sorry, but I see a contradiction...            01/01/70 00:00      
                                    shock? touching what?            01/01/70 00:00      
                                       Come on!            01/01/70 00:00      
                                          The standard to which we designed ...            01/01/70 00:00      
         I believe you may have missed the point            01/01/70 00:00      
   Current rating of relay?            01/01/70 00:00      
      not to nitpick, but            01/01/70 00:00      
         Thank you very much Erik            01/01/70 00:00      

Back to Subject List