Forum

Reading rs232

hi!
i’m having some problems with parsing rs232 string from arduino board.
with one pot data from arduino looks like this:
1020a
value has range from 0 to 1023
with one pot there is no problem becouse i take the string to tokenizer (as separator i use letter a) and then transform it to value.
i was using patch from MrBenefit:
http://vvvv.org/tiki-index.php?page=arduino03

but when i use two pots i cant parse them with tokenizer.
data from arduino looks like this:
1023a23b
first and second value has range from 0 to 1023. first value is from pot 1 and second is from pot 2. i vould like to split this string in two values. i’ve try it with tokenizer and i cant make it work.

could someone give me some hints?

vedran

regExpr ?.. no text …

when the protocol becomes more complex you might resort to automata (Animation) to follow a set of steps.

ive read the helpfiles for the automata a few times but i havent really understand it. are there examples off practical uses of automata in a vvvv-patches? that would be a great help, because the help docs are quite theoretical and not so easy to understand if you have no programming experience like me.

the Tokenizer (string) node would be the one to use. you can spread the separator pin to make the tokenizer react to multiple separators.

see the attached patch fragment. its completely untested, but should give you an idea.

the reason for the tokenizer is to synchronize the arduino output to vvvv frames - in the simplest case that you will receive one complete data message in one frame (when the tokenizer is an enqueue mode). you will not want to have parts of the data packet (like the pot number from the current reading, but the value from the last reading)

as you can change your arduino code really easily
id sugest sending a carriage return or an unique command after each pot command. this makes parsing a little bit clearer.

like
1023a<carriage return>
23b<carriage return>

also note that simpler to parse would be

0,1023<carriage return>
1,23<carriage return>

with that format you could use the Separate (String) node to split the pot index from the value instead of the Regexpr (String) .
this also saves you from the next proposed vvvv faq entry
“how to convert something like a b c d to 0 1 2 3 4”

arduino.v4p (4.8 kB)

hi!
i think tokenizer will do the job.
then i’ll just format it like oschatz purposed, it’s easy to do it in arduino.
i’ll put tutorilal on wiki when i test it
thnx

i still can’t make it work…
i have format the value this way:

0,1023 carriage return
1,23 carriage return
that was easy

but i still can’t make it work in vvvv
i use as a separator carriage return (ascii 13) in tokenizer
(when i use enqueue it doesn’t work at all, it work only in discard mode)
and (0,\d*) in first regExpr to get first pot value out
and (1,\d*) in second regExpr to get second pot value out
when i try all the regExpr code in one node it doesn’t work!
i use it like this (0,\d*)(1,\d*)
and what is a R at the end of the string node?

data has to much jitters and is useless…
do i miss something?
i have the att.

test_2pots.v4p (9.8 kB)

hello all,

i had recently do the same (1 poti and 1 IR sensor) … i had no problems. i used a “;” to seperate the data. see patch.
and in arduino that code:

// print value to serial port (auto converted from byte to integer)
printInteger(IRValue);
printString(";");
printInteger(valPoti);
serialWrite(10);
serialWrite(13);
delay(10);

bene

arduino_to_vvvv.v4p (13.2 kB)

nice and elegant!
muchos gracias!
it’s working!

super :) … no text …