ΣSigmaStudio Ask AI Русский Log in

ADAU1701 - How to measure time difference between current pulse and previous pulse?

SigmaDSP & SigmaStudio AravinthPanch Feb 17, 2019 00:00 5 replies Original on forum ↗
Subscribe
AravinthPanch Question
Feb 17, 2019 00:00

Hello EngineerZone Community,

I'm a New Media Artist and I’m using ADAU1701 for my interactive art project where i have to translate pulses into sound.

I’m using Analog Devices DSP and SigmaStudio for the first time and help/guidance regarding this will be greatly appreciated.

From Micro-controller (Arduino Nano), pulses are sent by switching on and off GPIO.

I need to capture the pulses on DSP side and measure the time difference between the current pulse and the last pulse. The time difference is used as a length of the sound that has to be produced.

I’m having difficulty to find a right toolbox in SigmaStudio get time delta between two pulses.

What is the best way to achieve this?

Is there any other better way to send interrupt driven data from Micro-controller to DSP, than using GPIO?

Please let me know if you need more information about the project.

Thank you very much in advance.

Audio Signal Processors

pulse

mcu

arduino

time

SigmaDSP Audio Processors

gpio

delta

adau1701

count

Show More

KJBob Reply
Feb 17, 2019 00:00

Hello,

The GPIO method is quite suitable for many uses, although it cannot control every function in detail. On the other hand, safeloading numerical parameters directly into the DSP's control registers can do nearly anything, but is more complex to implement. If your Arduino has analog output(s) available, you could wire them to a GPIO Auxiliary ADC input to get a quick zero to 1.0 variable (256 levels) into the DSP. More complex systems might use all of these methods, each where they make the most sense.

If you have your Arduino output a High for sound and Low for none, the DSP end becomes very simple -- a GPIO input directly controlling a External Slew Volume Control. The schematic would look like the one below but with the PB Toggle block removed. As shown, he schematic turns the sound ON when a pulse arrives, and OFF on the next pulse. Change the GPIO input (MP Pin) and DAC output according to your hardware. One issue with this arrangement: The DSP won't know whether a given pulse is to begin or end the sound, except that each pulse does the opposite of the previous one. If a random glitch somehow gets counted as a pulse, the logic gets inverted -- staying that way until another glitch or the system is reset.

Likely you have more involved functions in mind. If for example you would like the DSP to count time (in 1/48000 second increments) between two pulses, a Stopwatch cell with some additional logic can accomplish this. I could likely scare up such a circuit for you, although it's more fun to create it yourself with help from the EZ Community along the way. We've all made our beginner's mistakes and learned from them.

Best regards,

Bob

GPIO-Toggle_sch.png
GPIO-Toggle_sch.png
AravinthPanch Reply
Feb 19, 2019 00:00

Thank you very much Bob for the great support.

KJBob said:
safeloading numerical parameters directly into the DSP's control registers can do nearly anything,

Did you mean writing to DSP registers from MCU using I2C?

KJBob said:
If your Arduino has analog output(s) available, you could wire them to a GPIO Auxiliary ADC input to get a quick zero to 1.0 variable (256 levels) into the DSP.

Thanks for the suggestion. I've been using Arduino Nano (ATmega328) which doesn't have DAC, but it has Fast PWM to output 256 values. The values that i need to send are from 500 to 1200. However, if this is only option, then i can map 0 to 255 to 500 to 1200.

KJBob said:
If you have your Arduino output a High for sound and Low for none, the DSP end becomes very simple -- a GPIO input directly controlling a External Slew Volume Control.

Thanks for this schematics. Actually what it does is, it translates heartbeats from ECG sensor to artistically synthesised sound. The duration of the sound output is dependant on the time delta between the current heartbeat and the previous heartbeat. So we need to know when the heart beats and when was the last beat happened.

KJBob said:
If for example you would like the DSP to count time (in 1/48000 second increments) between two pulses, a Stopwatch cell with some additional logic can accomplish this.

Thanks for this suggestion. I will look in the forum if there are some examples to do this.

If you want to know more about the art project itself, please let me know so that i can send some details.

KJBob Reply
Feb 20, 2019 00:00

Hello,

Your project sounds interesting! I'd like to know more about it.

AravinthPanch said: Did you mean writing to DSP registers from MCU using I2C?

Yes -- many SigmaDSP blocks include embedded numbers called parameters which determine how the block performs. I2C transfers can modify these parameters, as well as the DSP control registers described in the ADAU1701 Data Sheet. The best I2C transfer mode is called safeloading -- it syncs the transfers to the dead time between samples, preventing "pops" and "clicks" in the DSP's audio output. You'll find info on I2C and safeload scattered about this forum should you need to use it. It does take some dedication to use I2C -- I've called it "an engineer's rite of passage."

Below are two example schematics. This first one counts the time interval between pulses -- one second = 60 bpm = 48000 counts. I test my projects on a ADAU1701MINIZ board; this has pushbuttons which ground their MP pins when pressed (negative logic). Thus, remove the Zero Comparator at the GPIO input for positive logic. The following One Shot goes high at the leading edge of an input pulse, then the feedback around it resets it on the next sample interval (Feedback blocks delay one sample). That pulse latches the previous count to the output, then the Stopwatch cell resets the count one sample interval later. Once the reset comes and goes, the Stopwatch commences counting. The next pulse that arrives latches this count, resets the stopwatch to zero, and starts counting again in that order. You can use the count output to drive various effects; in my example it operates a VCO scaled to produce middle A at 60 bpm. Because the count is proportional to the period (time between beats), a faster heartbeat produces a lower pitch.

Perhaps you could use a signal that relates to the heart rate. You could take the reciprocal of the period, but this takes many instructions. Instead, we can have each pulse generate and latch an exponential decay, as shown below. Both of these circuits use feedback and ABCD comparator blocks extensively -- you'll find these incredibly useful.

I attached these project files; you'll need to modify them to fit your hardware ins and outs.

Best regards,

BobHeart Time & Rate.zip

Heart-Time-Count_sch.png
Heart-Time-Count_sch.png
Heart-Rate-meas_sch.png
Heart-Rate-meas_sch.png
AravinthPanch Reply
Feb 24, 2019 00:00

KJBob said:
Yes -- many SigmaDSP blocks include embedded numbers called parameters which determine how the block performs. I2C transfers can modify these parameters,

Thanks for this direction and i was able to simply modify block parameters, as well as interface registers via I2C. This method definitely gives complete control.

KJBob said:
This first one counts the time interval between pulses -- one second = 60 bpm = 48000 counts. I test my projects on a ADAU1701MINIZ board;

This is the ultimate answer for my question and we have developed an organic heart beat sound based on your heart rate measurement design.

Here is what we have added to your design :

This is how it sounds now :

8508.dsp-i2c-safeload.jpg
8508.dsp-i2c-safeload.jpg
8512.organic-heart-beat.png
8512.organic-heart-beat.png
KJBob Reply
Feb 25, 2019 00:00

The display on your website would likely grab the attention of passers-by, and would likely be a welcome addition to museums featuring hands-on activities (near me that would be Liberty Science Center & The Franklin Institute).

Thanks for the offer to mention me, although really I just help around here only occasionally for fun. Apparently the PM system only works for "friends," so I'll request your friendship and we'll be able to do PMs.

I'm quite impressed that you and/or your team have gotten up to speed on I2C control in just a few days, with only the meager help supplied on EZ. This can be very frustrating until suddenly it works and you have a "Eureka" moment.

Best regards,

Bob