USB MIDI Interface

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Claudiu

Re: USB MIDI Interface

Post by Claudiu » Tue Jan 24, 2017 3:38 pm

Hello,

Does the VUSB MIDI work with latest linux kernel versions still with 2ms high speed?

Thx in advance

winelight
Rank 1
Rank 1
Posts: 21
Joined: Tue Nov 27, 2012 11:36 pm

Re: USB MIDI Interface

Post by winelight » Fri Mar 24, 2017 4:26 pm

I think the exchange rate is determined by the operating system on the PC and how quickly it polls the USB port. Obviously there is an upper limit imposed by the speed of USB too.

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

Re: USB MIDI Interface

Post by horo » Thu Mar 30, 2017 6:31 pm

Hi,

after a quite long time I've added a new demo project - V-USB-MIDI-ATtiny85.
Runs on a real cheap development board, e.g. Digispark - available as china clone for about 1..2 € or $.
Image
Image
The board has it's own USB bootloader - no need for a programmer - connect via USB and download your *.hex :)
16.5 MHz without xtal, 1 key input,one potentiometric analog input.
MIDI out is also possible, e.g. PWM or digital.

Have a look at my Bitbucket.

Ciao, Martin
Last edited by horo on Thu Aug 31, 2017 12:06 pm, edited 2 times in total.

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

Re: USB MIDI Interface

Post by horo » Sun Apr 02, 2017 5:41 pm

Hi,

me again. I've cleaned up the attiny85 midi code at bitbucket, added pwm out and a 2nd analog input.

Possible tested I/O functions are:
PB0: Digital input or digital output or pwm output.
PB1: Digital input or digital output or pwm output (active high LED attached).
PB2: Digital input or digital output or analog input ADC1.
PB3, 4: USB data lines.
PB5: 1 analog input (ADC0, shared with the /Reset function, but you can apply a voltage between Vcc/2 and Vcc -> 512..1023 without resetting the device).

Ciao, Martin

EDIT 20170403:
I did some timing tests with an empty main loop, PB1 toggles every 3µs (idle) with a gap of 150µs (USB transfer) every 2ms.
So we still have >90% CPU time for our program available. This looks similar to my measurements from 2009.
Test system: Lenovo T400 with Linux 4.10.8-towo.1-siduction-amd64 #1 SMP PREEMPT siduction 4.10-14 (2017-03-31) x86_64 GNU/Linux.

Short test on Win7 -> USB transfer every 8ms.

Win / Mac users: please double check on your systems.

Code: Select all

int main(void) // test loop
{
   uchar iii, value;
   uchar midiMsg[8];

   DDRB |= 2;      // LED pin output
   PORTB |= 2;      // LED on

   setName( 0 );

   usbDeviceDisconnect();
   for(iii=0;iii<20;iii++){  /* 300 ms disconnect */
      _delay_ms(15);
   }
   usbDeviceConnect();
   PORTB &= ~2;      // LED off

   wdt_enable(WDTO_1S);
   usbInit();
   sei();
   value = 0;
   for(;;){    /* main event loop */
      PORTB ^= 2;   // toggle LED while idling
      wdt_reset();
      usbPoll();
      if ( usbInterruptIsReady() ) {   // prepare and start USB transfer
         iii = 0;
         midiMsg[iii++] = 0x0B;
         midiMsg[iii++] = 0xB0;
         midiMsg[iii++] = 70; // cc 70
         midiMsg[iii++] = value++;
         midiMsg[iii++] = 0x0B;
         midiMsg[iii++] = 0xB0;
         midiMsg[iii++] = 71; // cc 71
         midiMsg[iii++] = value++;
         usbSetInterrupt(midiMsg, iii);   // transfer message
         if ( value > 127 ) {
            value = 0;
         }
      }
   }
   return 0;
}

Post Reply