USB MIDI Interface

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
christian
Objective Development
Objective Development
Posts: 1361
Joined: Thu Nov 09, 2006 11:46 am

Re: USB MIDI Interface

Postby christian » Wed Oct 27, 2010 10:00 am

I originally thought that we can use 5V levels, although it does not meet the specs. It turned out, though, that (at that time) newer USB host chips did not cope with those high levels. Similarly the bulk endpoints: When the feature was implemented, all operating systems accepted them for low speed devices. As you probably know, it won't work in WIndows 7 without a patch.

If you can argue that the host can't see the difference (if they adhere to the specs) and all hosts and hubs available today accept this type of level conversion, you have a point.

I'm very interested in feedback for this level converter because it avoids the zener diodes.

gamo
Posts: 2
Joined: Sat Oct 30, 2010 2:34 pm

Re: USB MIDI Interface

Postby gamo » Sat Oct 30, 2010 2:41 pm

Hi!
I built Horo's schematic and used his firmware. My computer runs XP. When I plug the controller in, my PC detects an usb audio device and an usb composite device. It's okay. But nowhere I can see the controller as a MIDI device. (control panel, traktor dj).
Any idea?

adrian.gin
Posts: 9
Joined: Thu Oct 21, 2010 12:33 pm

Re: USB MIDI Interface

Postby adrian.gin » Mon Nov 01, 2010 4:12 am

Try using MIDI OX to look at your MIDI ports.

The MIDI port will only show up on MIDI probing software.

gamo
Posts: 2
Joined: Sat Oct 30, 2010 2:34 pm

Re: USB MIDI Interface

Postby gamo » Mon Nov 01, 2010 2:14 pm

Hi!
Nothing in the MIDI Inputs list in MIDI-OX

adrian.gin
Posts: 9
Joined: Thu Oct 21, 2010 12:33 pm

Re: USB MIDI Interface

Postby adrian.gin » Wed Nov 03, 2010 9:50 am

I'm sure you changed the code in some way, because the default seems to work for all of us.

and don't say you didnt, because I know you did :P

horo
Rank 2
Rank 2
Posts: 56
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: USB MIDI Interface

Postby horo » Mon Jan 03, 2011 3:03 pm

Hi

happy new year to all V-USB hackers ;)
I've just pushed my local repo to bitbucket. The latest changes I did were some experiments with the descriptors - e.g. I removed the (mandatory) dummy AudioControl desc. It's also possible to remove the Jack descriptors (sections B.4.3 and B.4.4) without problems - my tests were done on an up-to-date debian sid - but YMMV.

The second project called ADIO in this repo is a quick measurement hack - it uses similiar hardware with the eight analog inputs and the four analog pwm outputs converted from/to midi note off events on the lowest midi notes:

Code: Select all

00001000  // Note off event
10000ccc  // Note off; Channel (ADC channel 0..7, PWM channel 0..3)
00000mmm  // Key (MSB of ADC/PWM)
0lllllll  // Velocity (LSB of ADC/PWM)


Ciao, Martin

adrian.gin
Posts: 9
Joined: Thu Oct 21, 2010 12:33 pm

Re: USB MIDI Interface

Postby adrian.gin » Wed Feb 09, 2011 3:07 pm

Since Win7 doesn't support Low Speed Bulk endpoints. My version doesn't work anymore.

It works with interrupt endpoints, but its 4 times slower. and latencies suffer as a result.

Until someone makes a Win7 Bulk Low Speed driver or something.... WinXP supported this however...

Cheers,

Adrian

christian
Objective Development
Objective Development
Posts: 1361
Joined: Thu Nov 09, 2006 11:46 am

Re: USB MIDI Interface

Postby christian » Mon Feb 14, 2011 12:24 pm

Did you have a look at Osamu Tamura's pages at http://www.recursion.jp/avrcdc/

He has a similar problem with CDC (which requires bulk endoints) on Windows 7 and as far as I know, he came up with a patch.

adrian.gin
Posts: 9
Joined: Thu Oct 21, 2010 12:33 pm

Re: USB MIDI Interface

Postby adrian.gin » Mon Mar 21, 2011 2:10 pm

I've done a few tests and I've found a hack on machines which allows high speeds on Interrupt Endpoints.

Usually, USB Polls low speed interrupt endpoints at:

Windows 8ms (minimum)
Linux 2ms (minimum)

See this page for more details:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Value of bInterval Polling Period (1-millisecond frames) Interrupt
0 to 15 8 Supported.
16 to 35 16 Supported.
36 to 255 32 Supported.
> 255 Polling intervals > 255 are forbidden by the USB specification. Supported.

Basically, this says that even though the device asks for 2ms or 1ms pollrate interval, windows only gives us 8ms.

With a maxmimum of 8byte packets, this gives us a maximum interrupt throughput of around 1000bytes/second. ~ 9600 baud.

However, we can HACK windows system files to give us a faster poll rate of 1ms allowing up to around 60,000baud which is great!

many gamers have hacked the sys and dlls to allow them to poll their low speed mice at a faster rate. Google: Mouse 500Hz Hack or something similar.

SweetLow from russia has developed a hack which works with all version of Windows including Win7 64bit. I've tested this myself and have seen the transmit rates increase from 1000bytes/second to 4000bytes per second. A 4 fold increase. Obviously this puts more load on the ATMEGA, but that's a decision you'll have to make.

Even though the bInterval on my device is set to 1ms, I think Win7 polls it at 2ms anyway even with the hack. Not sure why this is, by again I didn't write the hack. Apparently the hack does allow up to 1ms poll rates on low speed devices however.

You may ask why not just use Bulk Endpoints - the reason being Win7 no longer supports Lowspeed bulk devices.

horo
Rank 2
Rank 2
Posts: 56
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: USB MIDI Interface

Postby horo » Fri Apr 08, 2011 1:36 pm

Hi,

some time ago I also did some tests with win xp and linux:

viewtopic.php?f=8&t=1352&start=15#p9104

linux:
bmAttributes=2 (bulk), bIntervall don't care -> 2ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=1..3 -> 2ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=4..7 -> 4ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=8..15 -> 8ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=16..31 -> 16ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=0 or 32..63 -> 32ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=64..127 -> 64ms poll, low cpu load
bmAttributes=3 (interrupt), bIntervall=128..255 -> 128ms poll, low cpu load


Ciao, Martin

Oddgit
Posts: 2
Joined: Thu Sep 22, 2011 12:15 pm

Re: USB MIDI Interface

Postby Oddgit » Sat Sep 24, 2011 2:17 pm

Hi guys,

I'm very new to AVR programming, and my first big project is a midi controller. So I hope it's okay to post my questions in this threat. I've downloaded the latest version of V-USB-MIDI and I'm using an ATmega8 with AVR Studio 5 and AVRISP mkII. At the moment, I've only connected one potentiometer, one LED and one button to the device. But, unfortunately, it doesn't work. Both, Windows 7 and XP can't identify the USB device.

I've connected the USB-jack in this way:
Image
In my case, D- goes to PD0 and D+ to PD2 (INT0). I've also adjusted this by editing "usbconfig.h".

But connecting the 1k5 pull-up resistor confuses me. In the schematic above, it's a pull-up to +5V, isn't it? Because in the comments of "usbdrv.h" I've read the following:
Hardware Prerequisites:
=======================
If you use Zener diodes to limit the voltage on D+ and D-, you MUST use a pull-down resistor, not a pull-up.

So, what to do?!
Anyway, if I don't connect the 1k5 resistor to a port of the microcontroller, how must I handle the "Optional Hardware Config" in "usbconfig.h"? Is it okay, to simply delete "#define USB_CFG_PULLUP_IOPORTNAME D" and "#define USB_CFG_PULLUP_BIT 4"? Do I have to change something else in the source code, if I use this way to connect the USB jack? Btw, I'm using those zener diodes:
http://www.reichelt.de/index.html?;ACTION=7;LA=3;OPEN=0;INDEX=0;FILENAME=A400%252FZF%2523MOT.pdf;SID=13Tmr58n8AAAIAADj1Ejc9346e0fe3139afadbe3f92f875a7f569

Next thing is linking the correct files to the project. I've copied all files of the folder "usbdrv-20090415" (except the ones, that don't fit to my 12 MHz clock rate) into my project folder. Then I've included all to my project by adding them to the folder tree in AVR Studio 5, except the files "asmcommon.inc" and "usbdrvasm12.inc". They're only in the project folder, because in the comments I've read:
Do not link this file! Link usbdrvasm.S instead, which includes the appropriate implementation!
I hope, that's correct.
So far, so good. But where do I tell the compiler, which clock rate I've choosen?! Because unlike in "usbconfig-prototype.h" the "#define USB_CFG_CLOCK_KHZ (F_CPU/1000)" is missing in "usbconfig.h" of the V-USB-MIDI sample.

I promise, I didn't change anything in the source code (except the pin assignment)! Has anyone an idea, what I else could do, to get the thing working? Or what I do have to change in the source code when using an ATmega8?

As I said, I'm very new to that stuff, so it would be great if someone could help me.

Best,
Philipp

Oddgit
Posts: 2
Joined: Thu Sep 22, 2011 12:15 pm

Re: USB MIDI Interface

Postby Oddgit » Wed Dec 28, 2011 7:03 pm

Hi @ all...

I've solved the problems on my own and finally, I got the whole thing running. I've built a foot controller for digital guitar effect software, based on the V-USB-MIDI project.
Image.

It works perfect with Win 7.

I've created a small blog for the documentation of the project:
http://philaudio.wordpress.com

Best,
Philipp.

Dallum
Posts: 1
Joined: Sat Feb 04, 2012 6:47 am

Re: USB MIDI Interface

Postby Dallum » Sat Feb 04, 2012 7:05 am

Sorry for my English, it's not my native language :)

I want to create USB MIDI controller based on this project: http://cryptomys.de/horo/V-USB-MIDI/
But i want to use encoders instead of potentiometers.
I need to get information about controllers position in host to display it on my device.

I know that i should use usbFunctionWriteOut, but don't understand how... Small number of examples does not give the right information about this.
Can somebody give a little piece of code for this function? How can i get this information from "data"?

I try to do this:

Code: Select all

void usbFunctionWriteOut(uchar * data, uchar len)
{

  uchar cable= (*data)
  uchar channel = (*(data+1))
  uchar CC = *(data+2);
 
   if (CC == 77){
         PORTB = 0x00;
    }
}


I expect that if in host control number 77 is changed then my LEDs are light up. That's don't work.
Where is my mistake?

Thanks.
Evgeny

horo
Rank 2
Rank 2
Posts: 56
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: USB MIDI Interface

Postby horo » Thu May 31, 2012 10:07 am

Hi,

some days ago I had an email discussion with Philipp (in german) about my hardware, maybe the conclusion will be helpful so I'll give a rough translation:

Q: what does the inductor do?
A: it formes a lowpass together with the two capacitors to filter out noise from 5v usb.

Q: what about 3.3V and 12MHz - aren't you out of spec?
A: I use ATMega16A - the data sheet (figure 27.1, Maximum frequency vs. Vcc) shows that we are slight out of spec at 3.3V but I measured Vcc to be in the range of 3.5..3.8V so it's ok again. I also use ATMega168A which is full in spec (figure 29.1). As these are worst case values over the full temperature range there is sufficent margin (up to 16 MHz).

Warning:
The ATMegas work at incredible low Vcc (<1V), if you use the internal eeprom you MUST set the brown out detection fuses to avoid spurious data corruption due to (slowly) dropping Vcc (I learned it the hard way).

Ciao, Martin

Dex

Re: USB MIDI Interface

Postby Dex » Fri Jul 27, 2012 8:56 pm

Hi!

This V-USB-MIDI project is great!
I want to make some MIDI controllers with it, but i dont know how to program in other languages than the used in the Arduino IDE...I saw that some guys installed the V-USB library for using it with the Arduino IDE, anyone here knows how to do this with the V-USB_MIDI library?

Thanks in advance!
Dex


Return to “V-USB”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 9 guests