Best way for an arduino to receive 5 independent 40KHz~ digital signals and track their start times?

Asking for guidance here since i don't want to spend weeks making up a subpar solution myself.

Where the input is coming from:

Sonar transducer output which has gone through an amplifier and then a comparator working as a zero cross detector so that the analog signal is turned into something the arduino can work with easily. (schematic of the amplifier, the values of the capacitors and resistors are wrong, the gain is also supposed to be 65 V/V, 36.6 dB)

What I want the arduino to do:

See which transducer gives a receiving signal first then second and so on (there will be 5 or 6 transducers). i will also probably need to check if the signal is switching in the correct frequency through software. Then i need the arduino to send the data collected through a radio transceiver (still to pick)
then a trigonometric function based on the time delays between the transducers (if this turns out to be too slow, i can also do this on a computer on the receiving side of the radio).

I need this to be as real time as possible

1 Like

There are varieties of Arduino.  Any idea yet which one will be used?

You are dealing with transducers, meaning a device sends and receives. They cannot receive until the transmission has stopped and the physical vibration of the housing has stopped. That will not be identical for all 5 or 6 of your devices. Therefore they cannot all begin receiving at the same time. Or you going to force all to begin receiving at identical times?

1 Like

i meant real time as in not having to pause to process the incoming data, i know that transducers will receive signals at different times and this is exactly what im trying to use. sorry for confusing wording

Probably an UNO or a MEGA

What is the purpose if you are not processing the data? Are you just ignoring it?

Hi, @Nahian9749
What will be the "ping" rate of the system?

Tom.. :smiley: :+1: :coffee: :australia:

hello, im not fully sure what you mean by ping rate but i think 8 pulses (40KHz) 5 times a second. Thats how fast im planning to scan. The hardware and pcb for this all is still arriving so i dont know if there will be any bottlenecks yet

Hi, @Nahian9749

That's 40 pings per second, that will tell you what your maximum range will be.

Tom.. :smiley: :+1: :coffee: :australia:

340m / 40 = 8.5m. More than sufficient enough for the 3m range (min) i am aiming for.
If i write a simple interrupt routine where anytime the signal rises the time stamp in micros() is saved in an array, will the arduino be fast enough to do this for all the 5 transducers?

8.5m round trip, so 8.5/2 = 4.25m :+1: :+1: :+1:

Tom.. :smiley: :+1: :coffee: :australia:

No, that's like triggering an HC-SR04 [*] five times a second, or once every 200 ms.

[*] when triggered, the HC-SR04 puts out a string of eight pulses at 40 kHz (which takes about 0.2 ms to do), just like the OP is proposing to do.

If you want to use interrupts: the Uno has only two external interrupt pins, whereas the Mega has six.

"Sounds" like you are doing a sound-localization project...

haha very funny :joy:. Your right on that one. Sound localization indeed. I did realize a bit ago that i will need a MEGA if i want to do 5. But for the initial prototype the two interrupts on the UNO will do just fine.

And you are also right in that a large part of this is just reverse engineering the HCSR-04.

But i think what Tom said is still relevant. I still will need to worry about the 40 pings a second because the arduino will receive the signals as they come through the comparator, 40 times a second.

yeah that figures. But in my specific use case i dont need them to reflect back.

Oh. I figured you would act on the first pulse of the train of 8, and ignore the other 7, like the HC...

i might do that, just need to build up the hardware and see what works best really.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.