Pages: 1 [2]   Go Down
Author Topic: TouchOSC via Ardosc/Bonjour  (Read 3509 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

replace the :
Code:
  wert=value;
  Serial.println(wert);
with:
Code:
  Serial.print("Value = : ");
  Serial.println(value);

And see what that does. That works in the example code I wrote. It's a bit shooting in the dark, however, if that works you've accomplished 2 things.

1. You know your openFrameworks code sends a valid float.
2. You know where the problem is in the Arduino code.
Logged


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

mh, only alive! in serial monitor. Nothing besides that.

i wonder if this has something to do with library problems, i had an ArdOSC library that was written for the Watterod RedFly wifi shield and i reinstalled this one for the Ethernet board to test the connection. mh but I removed the RedFly ArdOSC folder in my library path to avoid trouble... i think it's a very small problem. all the ports and ip settings seem to be okay. frustrating
« Last Edit: January 08, 2013, 07:57:25 pm by Nixon123 » Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What Arduino board are you using ?

I am asking because my sample code specifies :

Code:
Serial.begin(115200);

On an Arduino Uno for example that would not work and I'd start with :

Code:
Serial.begin(9600);

And don't forget to change that in the serial monitor as well ;-)

Also, perhaps, if your board has an LED pin you may want to start getting to turn the LED on and off. Then at least you know that you can send an receive a value.
Logged


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

Seems all to be ok, it's an arduino ethernet board i program with an usb2serial light adapter, the proper board is selectet,  the baudrates are the same. i just read that the build in led is on pin 9, i'm going to test if i can cahnge something, tried it before with an external led, but no luck.
« Last Edit: January 08, 2013, 08:43:00 pm by Nixon123 » Logged

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


First, I'm very thankful for your help, great community here.
Second, I solved it  smiley or to be precise someone pointed me to a problem with the ofxOsc library and bundled osc messages, so it was related to Open Frameworks. Here is the link for everyone who runs into the same issues and stumbles over this thread
http://forum.openframeworks.cc/index.php/topic,6563.0.html

so long, nixon
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool! Thanks for posting the openFrameworks part of it too. It's often ant these software interfaces where one gets stuck.

Or in Obi Wan's words "Be mindful of the Interface Luke'"  smiley-mr-green
Logged


Northern Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks HeadRoom and crew, this thread really got me unstuck.

I reserved DHCP IP on the router for the Arduino Ethernet Shield so I never have to change OSC settings on the iPad regardless what is connected.

Time to add the DMX shield and see if I can get that going too.  I also bought a seeed Studio WiFly.  Would like to ditch the router/EtherNet shield if I can.


Gratefully yours,
Carl
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Replacing the Ethernet Shield with a WiFi shield will require some adaptions to the ArdOSC library. The ArdOSC library contains a few function calls to the lower level SPI functions of the Ethernet library.

I personally am not working with the ArdOSC library anymore as it is rather dated and not maintained anymore. I have rewritten my code to use the OSC library from CNMAT (Oscuino) https://github.com/CNMAT/OSC. It is writen and maintained by the inventors of the OSC protocol and actively maintained.
It uses the "regular" Arduino Ethernet and EthernetUDP libraries and is not directly hardware dependent. However, using hardware that can make direct use of the the Arduino Ethernet libraries is a not to be underestimated advantage to getting things to work very quickly.
For example I use a WIZ820io Ethernet module instead of the Ethernet Shield.

Any change in Ethernet related hardware will require you to change code in the used libraries unless the libraries that come with these shields e.g. the Seedstudio WiFi shield have compatible function calls.
Logged


Northern Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for replying and I will investigate CNMAT.  Feel free to drop out of this thread.

I'm not at the Bonjour stage yet, and not sure why I would need it.  If anybody wants to tell me the advantages, I'm listening.

I couldn't find Headroom's TouchOSC template, so I made my own, but Pin 13 LED just blinks on -then- off immediately.  My TouchOSC template works, as the call to funcOnOff() is happening and I can see tx/rx LEDs working in TouchOSC on my iPAD. 

TouchOSC control is: /Eth_ArdOSC/toggle1

But Pin 13 LED just Blinks ON/OFF when I push the toggle.

My Serial Monitor is funky too (I added some debugs to Headroom's code):

Serial looks like this (I matched the baud rates):

FLAG
0.00
alive!

LAG
1.00
alive!

Here's the code:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <ArdOSC.h>

//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

// Me Mal Arduino Ethernet shield MAC address
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xFB, 0xCF };


OSCServer server;
OSCClient client;

int serverPort = 8000; //Touch OSC Port (outgoing)
int destPort = 9000;   //Touch OSC Port (incoming)
int ledPin = 13;       //6 on a Teensy++2
int flag=0;

void setup(){
  Serial.begin(115200); //set your serial monitor's baud rate to 115200 or you won't be able to read the debugs
  Serial.println("DNS and DHCP-based OSC server");
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // print your local IP address:
  Serial.print("Arduino IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();
  Serial.println();
 
  //start the OSCserver
  server.begin(serverPort);
 
  //add OSC callback function. One function is needed for every TouchOSC interface element that is to send/receive OSC commands.
  server.addCallback("/Eth_ArdOSC/toggle1", &funcOnOff);
}

void loop(){

if(server.aviableCheck()>0){
     Serial.println("alive! ");
    } 
}

//When the button on the TouchOSC inteface is pressed, a message is sent from the iDevice
//to the Arduino to switch (togle) the LED on the Arduino on/off
//then a messeage is sent bak from the Arduino to the iDevice to toggle the buttom on/off

void funcOnOff(OSCMessage *_mes){
  float value = _mes->getArgFloat(0); //TouchOSC expects float values
 
  //create new osc message
  OSCMessage newMes;
 
  //set destination ip address & port no
  newMes.setAddress(_mes->getIpAddress(),destPort);
  newMes.beginMessage("/Eth_ArdOSC/toggle1");
 
  //added by me Mal 2013-09-21
  Serial.println();
  Serial.println("FLAG" + char(value));
 
 
  if(flag==1){
    flag=0;
    Serial.println(value);
    digitalWrite(ledPin, LOW);
  }
  else{
    flag=1;
    Serial.println(value);
    digitalWrite(ledPin, HIGH);
  }
  newMes.addArgFloat(flag);
 
  //send osc message
  client.send(&newMes);
 
}



Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't NEED Bonjour, but it is cool ;-)

I think I had the problem with the LED just blinking once too when I was figuring things out. IIRC the trick in TouchOSC is to use a toggle button (not a push button) and un-check the "local feedback" check box.
  • When you press the button once an OSC message is sent to the Arduino.
  • Then the LED is turned on.
  • then a message is sent back to the toggle button in TouchOSC to turn it on.
Logged


Northern Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did get the EtherNet and Conceptinetics DMX shields working with ArdOSC/TouchOSC/iPad. 

Support told me Ethernet shield requires pin 2,  so, connect middle pin of the Slave jumper on the DMX shield to Arduino Pin 7 and code to: DMX_Master dmx_master ( 100 , 7 );

No PWM gios sacrificed in this experiment.

Thanks again,
Carl
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 265
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's very good to hear. Congrats!
Logged


Pages: 1 [2]   Go Up
Jump to: