Go Down

Topic: baud rate and latency (Read 1 time) previous topic - next topic

ggml

im using arduino uno to capture 5 piezo toggle values (table tennis balls&table) that are being forwarded over midi to ableton and i can tell an audible latency between the real and the augmented sound.
regarding baud rates and latency, i found out over testing that 57600, 9600 and 4800 react slower than 14400. how is the optimal baud rate being calculated ?
thanks

PeterH


i found out over testing that 57600, 9600 and 4800 react slower than 14400. how is the optimal baud rate being calculated ?


That's unintuitive and may indicate that there's a design flaw in the sensing or communication algorithm. Perhaps if you posted your code, and gave a bit more detail about the results you're getting (How much delay are you getting, in reality? How big a delay would be tolerable?), somebody might be able to suggest possible causes.
I only provide help via the forum - please do not contact me for private consultancy.

ggml

the code is standard firmata, the data gets passed over rs232 to a platform (vvvv) that is converting the impulses to midi.
differences in latency occur on the same setup, but at different baud rates, as described.

robtillaart

can you also test at 115200?

I know that 57600 is a "strange" baudrate as you check the libs how it is handled, but even then it should be faster than 14K.

Please post your code, maybe there is some fix?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PeterH

In that case I suggest you need to determine whether the latency occurs within the Firmata sketch or the (ableton ?) application receiving the events from it, and then approach the corresponding user community for help.
I only provide help via the forum - please do not contact me for private consultancy.

ggml

sound and visual feedback are in sync
latency changes with baud rate of the arduino, on the same setup.

ggml

and indeed 115200 seems to work best, thank you

Erdin

The signal passes so many buffers and code.
The resulting latency is hard to predict.

Did you know the Arduino can send midi codes itself ?
http://arduino.cc/en/Tutorial/Midi
I think that most latency is in the firmata path. So I'm guessing that the latency could be easily half of what you have now by directly sending midi strings.

Detecting a knock is also something that often can be made a lot faster.
If you calculate the delta and test for a certain level, the knock will be detected on the rising slope. You can't get faster than that.

ggml

i need the sensor data inside my work platform (instead of sending midi directly from arduino), for a couple of reasons:
- dynamic treshold
- some boolean logic
- signal used also for visual feedback, wich is not midi
- cannot code

however,
could you please hint me at a resource about the minimal code that i would be needing for capturing 5 analog inputs (piezo),
so that i hopefully will reduce latency caused by standard firmata.

ggml

Quote
If you calculate the delta and test for a certain level, the knock will be detected on the rising slope

what do you mean by delta ?
what do you mean by test for a certain level? a treshold ?

Erdin

With delta I mean the difference with the previous sample.
That is the first derivate.
http://en.wikipedia.org/wiki/Derivative
If the value is above a certain level, the signal is rising with a steep slope.
Some filtering is needed to avoid detection of noise.

I think the best option is to let the Arduino do the detection and send the data to the midi and the work platform. So you have all the data and also a fast response.
But you have to know how to write code, since the code will always require some adjusting and finetuning.

ggml

i can implement something similar with 'framedifference'
before i implement logic in arduino, does it make sense from the latency pov to just to get rid of standard firmata and have some custom, minimal code that is only forwarding the analog inputs ?

Erdin

I don't know the numbers for latency.
If I search for "firmata latency" there are many things to read about it, but I still don't know.

You could run a few tests, to see what happens, and to learn along the way.

Go Up