salggarcia

MIDI/Audio Wing

Recommended Posts

Hello,

I'm new here and could use some guidance to see if this project is even possible.

I wanted to use the Papilio One and the MIDI wing to make a MIDI controller, so the MIDI in would need to be a MIDI out, and I would use hyperterminal to issue commands to the MIDI controller (like Channel #, program change, control change messages).

Please let me know if this is possible and what would be the first steps in accomplishing this project.

thanks!

-Sal

Share this post


Link to post
Share on other sites

Hey Sal,

I'm actually about to release a Kickstarter project, hopefully on Monday, that does something very similar. The project will include MIDI In, MIDI Out, and MIDI through.

For your project you would want to start with the Arduino MIDI library. You would then just need to capture serial data in the loop and send it out using the MIDI library.

Jack.

Share this post


Link to post
Share on other sites

Great!

Looking forward to seeing that kickstarter project. For using the Arduino IDE, would you suggest using the ZPUino Soft Processor or the AVR8 Soft Processor for implementing this?

Share this post


Link to post
Share on other sites

Hey Sal,

I want to get as many eyes on the RetroCade Synth code as early as possible but I do have some cleanup to do before it is ready for release.

But the MIDI code framework for the RetroCade is the same as the MIDI code in the YM2149 Synth project that is already published. There is a concrete example of setting up MIDI In there. You do need the correct ZPUino "Apollo" variant, most ZPUino variants do not have a second UART like the Apollo does.

In the RetroCade I have not needed to use MIDI out or through, just MIDI In. But it should be pretty easy to setup that functionality.

Jack.

Share this post


Link to post
Share on other sites

Okay understood.

But since I'm doing very basic functions I think i'll stick with the AVR8 processor.

But now to identify which port the MIDI wing is plugged into can I still use:

#define SERIAL1RXPIN WING_C_15      //Audio-MIDI Wing connected to CH

or do I have to do it another way, since it says "WING_C_15 is not declared in this scope"

- Sal

Share this post


Link to post
Share on other sites

Also, I was looking at the MIDI Audio wing schematic and wondering if it is even set up to do MIDI out, because if I connected it to the wing 2 port on the papilio one, can I still use that same RX line pin?

Thanks!

-Sal

Share this post


Link to post
Share on other sites

Sal,

The MIDI Audio Wing is only setup to do MIDI In. If you want I can get you a MIDI Wing that does both in and out, I discontinued the Wing but I still have some left.

Jack.

Share this post


Link to post
Share on other sites

That would be great! How can I order one?

Also, I'm still trying to just get MIDI in working. How can I can I specify which port to talk to (I plugged it in the Wing 2 slot) using the AVR8 processor and the MIDI library?

Thanks

-Sal

Share this post


Link to post
Share on other sites

Hello Sal,

Just send me a PM with a shipping address and I'll send out a MIDI Wing that has IN and OUT.

I just took a closer look at the AVR8 VHDL code and I just realized that the biggest problem we have the AVR8 is there is only 1 serial port and the pins of the serial port are not setup to be shifted. If you want to use the AVR8 to do what you need then here are a couple approaches:

[list type=decimal]

[*]Use the AVR8 "Vanilla" variant and see if you can figure out how to add a second serial port, this might be tricky since you would probably have to hi-jack the address from something else.

[*]Modify the ucf file to manually place the rxd and txd pins on the Wing 2 slot locations where you need them.

I would recommend taking the path of least resistance though, in this case it looks like going with the ZPUino "Apollo" variant is the path of least resistance. It already has a second serial port defined and the pins of that second serial port can be shifted anywhere you need them. Take a look at the YM2149 Synth Project to see example code of how to shift the serial pins for the ZPUino.

Jack.

Share this post


Link to post
Share on other sites

Sal,

If you look at the YM2149_Synth sketch you will see the following line:

#define SERIAL1RXPIN WING_C_15      //Audio-MIDI Wing connected to CH

Just change the WING_C_15 part to whatever you need, like WING_A_1.

Ok, so that takes care of the RX pin, but you are still going to need the TX pin. Since I did not use that pin in the example we need to figure out what pps slot the RX pin is connected to. In order to that we need to refer to the reference document for the ZPUino Apollo variant which can be found here.

If you look at the PPS Mapping section you see that the UART2 RX pin is on index 1 which matches our code:


#define SERIAL1RXPIN WING_C_15      //Audio-MIDI Wing connected to CH
  //Move the second serial port pin to where we need it, this is for MIDI input.
  pinMode(SERIAL1RXPIN,INPUT);
  inputPinForFunction(SERIAL1RXPIN, 1);

The inputPinForFunction uses index 1.

So looking back at the pps pin mapping table we see that UART2 TX is on index 6. So the code we would add would be:


#define SERIAL1TXPIN WING_C_14      //Audio-MIDI Wing connected to CH
    //Move the second serial port pin to where we need it, this is for MIDI input.
    pinMode(SERIAL1TXPIN,OUTPUT);
    outputPinForFunction(SERIAL1TXPIN, 6);

post-3-1343162758052.png

Share this post


Link to post
Share on other sites

Sorry let me rephrase that,

The second Serial port for the MIDI for both rx and tx I understand and looks simple to integrate as you explained, but I also wanted to change the ports of which the first Serial port talks to the computer with.

I see in the "papilio_one.ucf" file in the zpuino s3e250 apollo variant folder of the ZPUino hdl code that right now, the rx and tx lines are on P89 and P90, respectively. I was hoping just to change this to two external ports, say P91 and P92, to hook up my own serial bluetooth device to replace the cable and talk to the board wirelessly using Hyperterminal. I opened up the ISE project in these folders with an error right away with a few missing files. After attempting to resolve most of the missing file issues, I updated the ucf file to generate a new .bit file for the apollo variant, but I got a few errors associated with "no wishbonepkg" library found in work library. If this is the approach to doing this, could you assist me in these errors, or send me an updated version of the ISE project? That would be greatly appreciated!

-Sal Garcia

Share this post


Link to post
Share on other sites

Hi Sal,

I'll address your problems tomorrow, as soon as possible.

But you will need an extra serial interface (RS232) if you still want to upload your sketch using the FTDI USB chip. An extra RS232 interface should be easy to add, and with no impact.

Please contact me directly though email (alvieboy at alvie dot com) if I fail to post anything during this saturday.

Best,

Álvaro

Share this post


Link to post
Share on other sites

Okay the MIDI In/Out was received thank you very much.

After adding the code to add the TX line on the MIDI serial port like you suggested, I connected the MIDI out to a MIDI device that accepts program changes on MIDI channel 1. Im not sure how to send it a program change correctly, since after just adding this line to change it to program 1:

MIDI.sendProgramChange(1,1);

The device does not respond. I just may not be including something or not passing the right values in the "sendProgramChange" function. Please let me know !

-Sal

Share this post


Link to post
Share on other sites

Sal,

That looks right to me, you probably need to do a little troubleshooting now to pinpoint where the problem is. Is the MIDI message making it out of the serial port? Or is the MIDI equipment not responding as expected?

I would plug the MIDI out into your MIDI in, send the message and then pass anything that comes from MIDI in through the USB port to verify that MIDI out is working.

Jack

Share this post


Link to post
Share on other sites

Okay,

After some debugging, I found that the MIDI out is not working, since MIDI in responds fine with a MIDI program changer I have. Here's the code used for debugging:



#include "YM2149.h"
#include "MIDI.h"                  //Had to change MIDI.h to use Serial1 instead of Serial


#define SERIAL1RXPIN WING_C_15      //Audio-MIDI Wing connected to CH
#define SERIAL1TXPIN WING_C_14      //Audio-MIDI Wing connected to CH


int incomingByte = 0;
char incoming = 0;


void setup(){
  Serial.begin(9600);


  //Move the second serial port pin to where we need it, this is for MIDI input.
  pinMode(SERIAL1RXPIN,INPUT);
  inputPinForFunction(SERIAL1RXPIN, 1);
 
  //Move the second serial port pin to where we need it, this is for MIDI output.
  pinMode(SERIAL1TXPIN,OUTPUT);
  outputPinForFunction(SERIAL1TXPIN, 6);
 
  //Setup the pin modes for the YMZ294
  setupYM2149();


  // Initiate MIDI communications, listen to all channels
  MIDI.begin(MIDI_CHANNEL_OMNI); 


  MIDI.setHandleProgramChange(HandleProgramChange);
}


void loop(){
  // Call MIDI.read the fastest you can for real-time performance.
    MIDI.read();
  // Read in command 
  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();
    enable_midi(incomingByte);
  }
}
 
  void enable_midi(int incoming)
{
  if(incoming == 49)
    {
      Serial.println("HIT");
      MIDI.sendProgramChange(1,1);
    }
}


void HandleProgramChange(byte channel, byte number)
{
  Serial.println("Program change received: ");
  Serial.println(number);
}

The serial monitor says HIT on sending a 1 to it, but no program change message. But when I plug in my external MIDI program changer device it says "Program change received:" and works correctly. After wiggling around the MIDI In/Out wing it printed:

"Program change received: 128"

and

"Program change received: 64"

and

"Program change received: 135"

and so on...

My guess is I constructed the wing incorrectly. When I plug it into the papilio, I observed with a DMM that a few nodes turn to ground when I believe they shouldn't, such as the MIDI out line! Do you have a schematic so I can go through and check all the connections?

Share this post


Link to post
Share on other sites

Okay,

The schematic seems to match up exactly with the board after going through with a DMM, except the ground is actually on MIDI pin 3 except pin 2, but Im sure that doesn't make a difference if they are both the same on the MIDI In and Out connectors. The only thing I can think of is the UART2 TX line is not set up properly but Im not sure.

-Sal

Share this post


Link to post
Share on other sites

I also noticed that on the MIDI out connector, MIDI pins 4 and 5 are still tied to ground, and after probing with an oscilloscope, their is no activity on pin C14 when a sendProgramChange is sent. Their is activity that I can see on the MIDI In C15 pin when accepting program changes to verify my oscilloscope is working.

-Sal

Share this post


Link to post
Share on other sites

Hello Alvie,

Yes everything works great. It uploads correctly and stays upon repowering. The only thing now is that the MIDI out is not working. It seems like its not sending anything at all (control changes, program changes, etc.) even probing the tx line with a oscilloscope shows no sign of activity when attempting to send through that port.

-Sal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now