Show Posts
Pages: [1] 2
1  Using Arduino / Interfacing w/ Software on the Computer / Re: "Array of MIDI-Interfaces" - how? - SOLVED - on: May 14, 2014, 02:38:21 am
Okokok... I am such an idiot. The problem was not the code. The problem was in front of the screen.

In my main code I just forgot to initialise the MIDI interfaces and in my example code I made a mistake while initialising the array for the MIDIs.

This works (on a Mega!):

Code:
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiA);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midiB);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial3, midiC);

midi::MidiInterface<HardwareSerial> m[]={midiA,midiB,midiC};

void setup()
{
  byte i;
  
  Serial.begin(115200);
  Serial.println("Start");

  // dont't forget to initialize!!!
  for(i=0;i<3;i++)  
    m[i].begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
  byte in_port;
  
  for(in_port=0;in_port<3;in_port++)
  {    
    if(m[in_port].read())
    {
      Serial.print("incoming port: ");
      Serial.print(in_port,DEC);
      Serial.print(" channel: ");
      Serial.print(m[in_port].getChannel());
      Serial.print(" data1: ");
      Serial.print(m[in_port].getData1());
      Serial.print(" data2: ");
      Serial.println(m[in_port].getData2());
    }
  }
}
2  Using Arduino / Interfacing w/ Software on the Computer / Re: "Array of MIDI-Interfaces" - how? on: May 12, 2014, 04:28:52 am
I just tried the following. It compiles with no errors but it does not work - the read()-method does never show any events...

Code:
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiA);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midiB);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial3, midiC);
midi::MidiInterface<HardwareSerial> m[3]={
  midiA,midiB,midiC};

void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
  
  m[0].begin(MIDI_CHANNEL_OMNI);
  m[1].begin(MIDI_CHANNEL_OMNI);
  m[2].begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
  byte in_port;
  
  for(in_port=0;in_port<3;in_port++)
  {    
    if(m[in_port].read())
    {
      Serial.print("incoming port: ");
      Serial.print(in_port,DEC);
      Serial.print(" data1: ");
      Serial.println(m[in_port].getData1());
    }
  }
}
3  Using Arduino / Interfacing w/ Software on the Computer / "Array of MIDI-Interfaces" - how? on: May 12, 2014, 04:01:43 am
Hi Arduinianers,

I have a bigger problem with a project (http://sourceforge.net/projects/ardumidimerge/). I am working with an Arduino-Mega and three of the serial ports as MIDI. I need to make an array of my MIDI instances - but how?

Here is my test code - works not. I think it is a problem of understanding C++:
 
Code:
#include <MIDI.h>

midi::MidiInterface<HardwareSerial> m[3];

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, m[0]);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, m[1]);
MIDI_CREATE_INSTANCE(HardwareSerial, Serial3, m[2]);

void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
 
  m[0].begin(MIDI_CHANNEL_OMNI);
  m[1].begin(MIDI_CHANNEL_OMNI);
  m[2].begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
  byte in_port;
 
  for(in_port=0;in_port<3;in_port++)
  {   
    if(m[in_port].read())
    {
      Serial.print("incoming port: ");
      Serial.print(in_port,DEC);
      Serial.print(" data1: ");
      Serial.println(m[in_port].getData1());
    }
  }
}

Does anyone know how I can get my instandes in an array?

Thanks a lot, Holger
4  Using Arduino / Networking, Protocols, and Devices / Re: EthernetServer (TCP) for more than one connection? on: January 17, 2013, 07:32:12 am
PaulS, SurferTim,

perhaps it will work without persistant connections. The protocol definition doesn't specifiy something like that, right. But it also says:

Quote
The server MUST differentiate all client sessions internally

The big question is: How does the SRCP client software interprets this (like RocRail, Android SRCP client, ...). Perhaps I will try it with non-persistant connections and see what happens. If it will not work I have to think about it again (perhaps using a Raspberry with multithreaded server and connect the Arduino to the Rapsi with I2C).

The project can be found at https://sourceforge.net/projects/maerklino/. The current state is: The first version of Jan Weller is working (see http://forum.rocrail.net/viewtopic.php?t=4583 but not very comfortable. I have done some changes but hadn't test them until now. Hopefully I can do this on weekend.

Thanks, Holger

 
5  Using Arduino / Networking, Protocols, and Devices / Re: EthernetServer (TCP) for more than one connection? on: January 17, 2013, 06:55:59 am
PaulS,

thanks for the fast answer!

I have a sketch for driving Maerklin-Motorola-II model locomotives. Now I want to add support for SRCP (http://srcpd.sourceforge.net/srcp/srcp-084.pdf), so I can create a SRCP central station. For this I have to allow 1+n clients. Clients can be programs or other Arduinos which can talk SRCP. SRCP is TCP based...

Regards, Holger
6  Using Arduino / Networking, Protocols, and Devices / EthernetServer (TCP) for more than one connection? on: January 17, 2013, 06:48:46 am
Hi all,

is it possible to write a server sketch where I can accept more than one connection via TCP? I have only found many (working) example for just one connection...

Thanks, Holger
7  Using Arduino / Audio / Re: Multiple MIDI I/Os on: November 24, 2012, 02:43:54 pm
Just not tested, but if you check out the code of the Arduino MIDI library from the link mymaestro posted, I think there is already a Multi-MIDI(Serial) class in this library (also it seems there is a software MIDI implemented). If I have more time I will try this.

Regards, Holger
8  Using Arduino / Audio / Re: Multiple MIDI I/Os on: November 15, 2012, 04:03:50 am
Ahhh, great! This would be a solution on a Mega. I think I have to buy one to test ist.

Thanks, Holger
9  Using Arduino / Audio / Multiple MIDI I/Os on: November 12, 2012, 10:30:17 am
Hi all,

I hope this will be the right forum for my question:
I want to build a MIDI-Router (3 MIDI-INs / 3 MIDI-OUTs). Perhaps I can use a Mega, but are the serial ports of the Mega buffered?
Is there another solution, perhaps with other Serial-UARTs which have a SPI-Bus (does anyone know which type can handle MIDI)?
Has anyone done such thing already and can give me some hints?

Thanks, Holger
10  Using Arduino / Programming Questions / Re: Strange class problem on: November 08, 2012, 02:54:30 am
Ok, I understand what my problem was.

Thanks for your help!

Holger
11  Using Arduino / Programming Questions / [SOLVED] Re: Strange class problem on: November 07, 2012, 07:18:24 am
Hi all,

ok, I see, that my Uno is not a memory giant... and my class is not very small. But with MAX_FADE_ELEMENTS set to 10 the storage for one instance should be about 180 Bytes. I tried to use only _one_ instance and the Arduino freezes.

Nick Gammon's hint was the solution (not for everything, but now it works!): The constructor was "too big" - don't ask me why this is a problem. But when rewriting the constructor function to a DMX_RGB.begin() method it works! Also four instances are working! I took a look at http://www.arduino.cc/playground/Code/AvailableMemory and checked my free memory and there were about 300 bytes empty.

If anyone can explain why the constructor was the problem and why I should use a begin()-method for initialization I would be very glad!

Thanks for helping!

Holger
 smiley-cool
12  Using Arduino / Programming Questions / Re: Strange class problem on: November 07, 2012, 03:15:00 am
Hi all!

thanks for your hints. I wonder that one class instance would need so much memory. I will try your suggestions and write the solution to this thread as soon as possible.

Regards, Holger
13  Using Arduino / Programming Questions / Strange class problem on: November 06, 2012, 10:57:42 am
Hi all,

I have a strange problem with my selfmade class. I want to use some DMX spots over WiFi, so I created a simple sketch for a client (Arduino+WiFi) and a sketch for a server  (Arduino+Ethernet). For the server I wrote a class called DMX_RGB (see attached). I need to create some instances (globaly)in DMXNet_Server.ino:

Code:
DMX_RGB Bar1("192.168.1.40",4711,10,11,12,9,8);

When I create such an instance, the sketch stops and nothing happens anymore. Also no debug output on the serial monitor...

If I comment out everything which is relating to the instance Bar1 (and of course the code above) the sketch works (also it is not doing what I want :-( )

I think it is a simple, stupid problem - but I cannot find where. Has anyone an idea?

Thanks a lot, Holger
14  Using Arduino / Networking, Protocols, and Devices / Re: Serial library with non standard bit rates? on: August 15, 2011, 02:05:53 am
Hi all,

thanks for your responses!

@MarkT: I hoped to find a way to avoid writing the interrupt driven code :-) but it seems that I have to write such library (which will take more time for me than I thaught). My problem is that I have no scope, so I have to do trial & error for the signal generation (that's a problem with all other solutions, too).

@Bill_Kerr: Yes, that's also a possibility to avoid the software signal generation code. But I know that there is a working(!) software implementation based on UARTs (http://srcpd.sourceforge.net/srcpd/index.html). I will keep in mind to change to the hardware signal generation when everything will fail.

@skyjumper: I will use the the Arduino UNO (328P). It seems that someone has made a Port from OpenDCC to the Arduino (http://developer.berlios.de/projects/microsrcp/) which is also based on UART output (like srcpd). But I hope to get arround the tricky timings when using the "right" bit rate to communicate with.

It seems that I have to write my own signal generation code with interrupts or I have to use the hardware encoder from Motorola...

Regards, Holger
15  Using Arduino / Networking, Protocols, and Devices / Re: Serial library with non standard bit rates? on: August 12, 2011, 07:09:11 am
Hi skyjumper,

no UART :-)
I need to generate a signal for driving digital modell locomotives (not DCC but Motorola-Märklin). So my other end of the communication is a decoder chip inside the locomotive. I have a rough manual how to generate the frames with a serial line at 19200 bit/s but you have to do some strange timing things to get the right signal. I thaught that it is better to generate the signal without that strange things but for this you "might" have to send the frames with a non-standard bit rate (s. http://modell-zug.com/Support/HowToArticles/DigCtrlSys/DigitalTransmission.htm). I read some documentation where they don't use exactly 4800 bit/s... but I'm not sure.

Regards, Holger
Pages: [1] 2