Time measuring or other way to build the TAP tempo button

Hello colleagues!

Have the ADAU1701 board and trying to made the tap-tempo algorithm without external control such Arduino.

 General idea use the VCO as the tempo function and i can not suggest how to transform signals from GPIO to DC values for VCO. Maybe someone have such experience or know how to measure time gaps? I will be happy to all your ideas. Thank you in advice!

  •      Hello,

         Here's two ideas to get you started.  Both begin with the input pin MP9 corresponding to GPIO 9 in SigmaStudio.  In the HW Configuration window, check the Invert box so that pressing the button produces a 1.0 output at GPIO 9:

    On the ADAU1701MINIZ eval board, MP9 is wired to PB switch S6.  If you're using a different ADAU1701 board such as SureDSP, change the GPIO input and audio outputs accordingly.  At the left end of each example below, the PB state at GPIO 9 is AND-ed by the Min block with a Value Cross Detector to produce a one-sample wide pulse with each button press (without the AND, the Value Cross Detector would pulse at both button press and button release).

         Generally, time intervals can be measured with a Stopwatch block.  These count samples between Start, Stop and/or Reset events.  At the default sample rate of 48K, you get an output of integer 48000 for a one-second interval.  One mS provides 48 counts.  All such counts are in integer format (28.0 format for the -1701).  A few seconds' count can look like a huge number, but remember it tales 2^23 integers to make a 1.0 decimal number -- if you need to brush up on these number formats, see What are the Number Formats in SigmaDSP.

         The first example below uses a Stopwatch to count the interval between button presses.  The Stopwatch is set up to run constantly and reset to zero one sample after a button press.  Just before the reset, the Value Hold block grabs and holds the count.  At this point the count value in decimal is (48000 per second) / (2^23) = .005722 per second.  The Gain block scales this up to 0.04167 per second.  The VCO outputs a tone frequency of (fs/2 =24000) x its decimal input.  This results in a 1000 Hz tone for a time interval of 1 second.  The output is proportional to time -- double the time to two seconds, and you get 2 KHz.

         Perhaps you're looking to measure not the time interval itself, but the rate which is inversely proportional to time.  You could preform the  needed reciprocal function with a Divide block in SigmaDSP -- yet in Sigma100 processors like the ADAU1701, the Divide block uses many instructions.  It would be simper if we could directly produce a signal proportional to rate instead of counting time.  Here's one way to do it:

    This circuit substitutes for the Stopwatch an ABCD Comparator, a Feedback block and a Gain block.  When the button press reaches the A input of the Comparator, it selects its C input which sets its output to 1.0.  During the time interval before the next press, it feeds back to itself via the Gain block to input D, which multiplies the output by a number very close to, but not exactly 1. The resulting output decays from its initial value of 1.0 at a rate proportional to itself -- you may recognize this as a decaying exponential function similar to that of a discharging capacitor. After a second has elapsed this multiplication has occurred 48000 times, which in turn provides an output of 0.99998^48000 = 0.38289. This signal is inversely proportional to time -- double the time and you halve the signal -- so it's directly proportional to rate.  Block Gain2 scales this so the VCO puts out a frequency 10 times the incoming beats per minute.

         Now you're free to come up with a circuit which implements your own needs.  For example, change the output scaling as needed.  Implement a "time-out" feature to kill the output when the button hasn't been pressed in awhile.  Or whatever.  The more you work with SigmaStudio, the easier this becomes!

         Best regards,

         Bob

    Projects.zip