Arduino to axoloti thru serial


#1

hello again
i am trying to use an arduino to send data to axoloti thru simple a serial connection

i connect arduino's TX pin to axoloti's PA2 pin which seem to be it's serial in pin
but now i don't know how to read the data in the patcher

in the arduino i have a 4x4 keypad which sends numbers 0 to 9 and symbols ABCD*# to its serial screen

in axoloti i see some nodes to configure serial speed but nothing about getting serial data and translate it to notes or whatever

can someone please help me with this ?


#2

Here is what I have found out.

You also need to connect

PA3 (axoloti) to RX (arduino)
And
GND TO GND

From there it's a case of using the right code. I am currently working on a similar thing myself (not fully working yet.) I will post detailed info once I have it all working.

Also check these threads ....

And


#3

thankyou mrBim
it's preciselly in the axoloti's software where i'm a bit lost

i've made a patch placing first a gpio/serial/config to set serial's speed to 115200 like in arduino

then i've placed a gpio/in/digital node to read PA3 and i've connected it to several types of displays to try to understand what is received

i only get intermitent 0 and1 instead of what arduino sends,arduino is printing numbers and leters to the serial output

i can't find any node to interpret string symbols...


#4

"gpio/in/digital" is not the right way to read serial data - it will only give you the momentary state of the digital level.

I just pushed a simple help patch for gpio/serial/config object to the 1.0.10 factory library.

Generally, protocol handling is done in code rather than patching. I don't think protocol encoding/decoding can be expressed nicely by patching.


#5

thank you johannes
would you please have some decoding code example i could use in axoloti to transform serial data into usable switches for other nodes ?
i would also need to know how to enter code anyway...


#6

johannes, you are, as ever awesome.

i plan to share all my info once i have a fully working solution as it would seem there are quite a few people out there who are wanting to do something similar.


#7

I assume your keypad is transmitting ASCII codes for the keys, that would work for key down, but not for key release, and I hear you also want to transmit three channels of accelerometer data.

With just keydown, one byte can tell everything, I suggest these steps:

  • create a "script/script2" object. This one only provides 2 inlets/outlets of a fixed type, we need to modify this...
  • on the object popup-menu, select "embed", now you can customize its in- and outlets
  • the "script/script2" object became a "patch/object". This is a special object, it means the definition of the object is contained in the patch, not in a library. It will have a 2nd edit button. 1st one is for editing the "script", the 2nd one is to edit the object.
  • push the 2nd edit button of the object, to add in- and outlets relevant to the keypad. I guess 16 outputs of the "bool32.pulse" type if you're not interested in key-up events.
  • in the object editor tab "local data", you need to add variables corresponding to the in- and outlets, like already present for in1, in2, out1, out2.
  • in the object editor tab "k-rate code", you need to add assignments similar to what is already present for in1, in2, out1, out2.
  • now first check if the patch with this object skeleton still compiles and runs.
  • in the script (accessed via the script - edit button on the object) you'll need to enter something like
    :
void setup(void) {
} 

void loop(void) {
    // read all pending bytes
    while(!sdGetWouldBlock(&SD2)) {
        char x = sdGet(&SD2);
        switch(x) {
           case '0': out0 = 1; break;
           case '1': out1 = 1; break;
           case '2': out2 = 1; break;
           // add other cases here
           default: LogTextMessage("unhandled: 0x%X",x);
        }
    }
    chThdSleepMilliseconds(3);
    out0 = 0;
    out1 = 0;
    out2 = 0;
}

But if you also want to combine three channels of accelerometer data, you need some sort of protocol to tell keycodes apart from accelerometer data. I don't have time here to write a book chapter about best practices in protocol encoding/decoding, I don't know how familiar you are with Arduino, please be more specific in questions. It would be helpful if you could provide code that would decode the protocol on Arduino. If my example code does not make any sense, please understand I do prefer spending time on development rather than teaching programming basics. Still completely fine to be discussed here, but I'm not likely to engage in such discussion.
Entering code can be as easy as clicking "edit" on a "script/script2" object. Did you do "sync libraries" in 1.0.10, and found the help patch associated with the "gpio/serial/config" object?


#10

You say translate it to notes which makes me think you actually want to transmit MIDI data over the serial connection. This is very easy using the Midi library on teh Arduino and simply connecting the UART TX from duino to the UART in (PA3?) on the Axo. On the duino read your keypad and send Midi note data instead.


#11

i am basically doing what mongrel says with my project.

see this thread for more detail

link


#12

hello
i was starting to try the new patch change system but the last posts here have desapeared…


#13

Looking for this thread about patch changing?