Pages: [1]   Go Down
Author Topic: baud rate and latency  (Read 872 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13846
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Rob Tillaart

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

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

and indeed 115200 seems to work best, thank you
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: