Pages: [1]   Go Down
Author Topic: monome protocol  (Read 999 times)
0 Members and 1 Guest are viewing this topic.
Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I'm trying to implement the monome protocol on the arduino, but I have some trouble figuring how to translate those C commands into the Arduino IDE. the monomeserial recognize my board as a 40h after I changed the FTDI chip ID, but I can't (yet) use it as a monome.

The messagePackButtonPress function is used to send serial data :
void messagePackButtonPress(t_message *message, uint8 state, uint8 x, uint8 y)
{
    message->data0 = (kMessageTypeButtonPress << 4) | (state ? on : off);
    message->data1 = (x << 4) | y;
}

t_message is defined as follow
typedef struct {
    uint8 data0;
    uint8 data1;
} t_message;

You can find the protocol specifications here : http://docs.monome.org/doku.php?id=tech:protocol:40h & http://docs.monome.org/doku.php?id=tech:protocol:serial:series

I know that each data to send (adress, state, xpos, ypos) must be 4 bits long, but what I don't understand is the message->data0 & message->data1 syntax. I tried

Serial.print(0x0000 | 0x0000);
Serial.print(0x0000 | 0x0000);

But I must have some bit shifting of variable type problem (I'm really bad with all this binary stuff ^^)

How to translate in "Arduino style"? Thanks
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
I do my own experiments.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The function you pasted shows you how to bit shift things over...

although you might need to specify like Serial.print(x,BYTE);

Code:
Serial.print((address << 4) | state, BYTE);
Serial.print((x << 4) | y, BYTE);
well, if you need to clean up input:

Code:
Serial.print((address << 4) | (state & 0x0F), BYTE);
Serial.print((x << 4) | (y & 0x0F), BYTE);
Logged

Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi KyleK
Thanks for replying. I tried your method, it should work but I guess I'm having another problem, as monomeserial recognize my arduino board as a 40h but the monometest max patch doesn't show me anything. I must first check that I can get anything (even noise) going between the arduino & max/msp before going further with the protocol ^^
Thanks

I'll keep posted.

Bye
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, with a print object in the monome_test patch, I can see that max/msp is receiving commands from my arduino. Now I just have to figure the good syntax, as monomeserial always sends /test/press 0 0 0 whatever I do...
Keep you posted
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Found the problem. Based on what I read on other sites (monome forum, tinct blog, etc...) I started a Serial.begin with a speed of 9600. By looking into the various max patches, I found that It must be 115200.

So, for anyone interested, you can send button states this way
Code:
int address = 0; // message ID, in this case, button state
int state = 0; // 0 (keyUp) or 1 (keyDown)
int x = 4; // x position
int y = 2; // y position
Serial.print((address << 4) | (state & 0x0F), BYTE);
Serial.print((x << 4) | (y & 0x0F), BYTE);

Thanks again kylek, I'll try to extend this to the other type of messages (ADC, ledOn/Off, etc... ) and make it a proper library ^^
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

By the way, to have your arduino recognized as a monome by monomeserial, you have to change the FTDI chip ID.
To do that, you have to install Mprog and the D2XX drivers from FTDI (your arduino will still work with the arduino IDE with this drivers)

MProg 3.0 > http://www.ftdichip.com/Resources/Utilities.htm
D2XX Drivers > http://www.ftdichip.com/Drivers/D2XX.htm

1/ Install both, then run Mprog
2/ Launch Mprog, then click on Device / Scan. You should see something like this appearing in the box down.
Code:
Number Of Blank Devices = 0
Number Of Programmed Devices = 1
3/ Click on Tools > Read and Parse. This will fill the boxes.
4/ Check the "use fixed serial number" box and change the value below.
To have your board recognized as a monome by monome serial, you have to enter something like
m40h-xxx
m64-xxxx
m128-xxx
m256-xxx
Choose whatever you want, I'm not sure what is different between the various IDs, for the moment I'm using m40h-001.
There is 2 protocols described on the monome site, and the 64/128/256 seems to be more complete (15 message IDs, 9 for the 40h protocol), so maybe you'd better use m256-xxx ^^
5/ Click on File > save as
6/ Once saved, click on the flash icon (Program all existing devices, Ctrl+P).
7/ Unplug / plug back your board from the usb port.
7/ Run monomeserial, you should see something appear on the devices list.

Good luck
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there
Just to keep you posted.
Buttons presses work, it's ok, I need now to work a bit on the hardware as I use a pin for each button (ugly wiring ^^). I'll have to do a matrix for this.
I just finished my prototype max/msp patch to send rgb intensity to the arduino, but I think i'll need to modify the monomeserial source code and extend the monome protocol to have it relay the new message type (/rgb x y r g b) to the arduino.
Cheers
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Really interesting stuff, please keep posting.
Logged

France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Wiring Board owner
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

melka, do you use RGB leds ?
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi julienb
I just sent you a mail, because I started a thread on the monome forum and thought you migh like to join
http://post.monome.org/comments.php?DiscussionID=1549&page=1#Item_15

Right now, I haven't made any significant progress on the arduino side, I was away in Shanghaï (yay!! great city, if you can, you must go there, especially Beijing Dong Lu, a lot of little shops selling everything you need, from ball bearings to electronic components)

I finished the max/msp patch (sends /rgb x y r g b) but now, I'm settling on the key matrix side : how can I have small sized (monome sized, I mean, not sparkfun, a bit too big) backlit pressure sensitive pads? I plan to use RGB leds but I don't yet know if i'm going with smd or through hole components.

xndr on the monome forum mentioned that we could use 2 boards, one for the leds and one for the buttons, and have holes on the top one (buttons matrix) to put the leds through.

For the pressure sensitivity, I wanted to use piezo transducers, but it'll be hard to find ring shaped piezos, so I guess I'll go with pezoresistive fabric (http://www.eeonyx.com/prodte.html). I got an email from Adrian Freed, CNMAT Berkeley, who used it to "bend" sparkfun's & monome buttons pad and add pressure sensitivity.

For the leds, I plan on using 12-channels 12bit PWM chips like Linear LT3595 or TI TLC5940. Still have to order those and understand how they work. Might be a lot easier that trying to deal with MAX7221 and some software kind of PWM.... This would have been a real pain in the a..

As usual, I'll keep you posted ^^
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there
Just to tell you that I made a blog, essentially for talking about this project.
I'll ask the questions here, and keep you posted about the project, but the blog is for publishing each step forward and think I have (this sentence doesn't seem to be correct, but I'm tired, it's 5 AM here ^^)
You can visit it here
http://play-collective.net/blog/
Don't hesitate to comment ^^

Cheers

melka
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there.
I spent the evening working on how I'm gonna light my buttons, and I came with a design that might be do-able, but not easily I think. Any idea that might help ? More details here.
http://play-collective.net/blog/archives/44

Thanks ^^

NB : maybe an admin should move this post from Software / syntax& programs to General / Exhibition, or maybe a Projects section?
Logged


Grenoble/Lyon - France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 363
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

New post on my blog, I got a little bit ahead on the code to differentiate each message type.
http://play-collective.net/blog/archives/48

cheers
Logged


Pages: [1]   Go Up
Jump to: