Skip to content

Commit ea8a45c

Browse files
committed
First version
0 parents  commit ea8a45c

40 files changed

+8731
-0
lines changed

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
*.obj
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Compiled Dynamic libraries
12+
*.so
13+
*.dylib
14+
*.dll
15+
16+
# Fortran module files
17+
*.mod
18+
19+
# Compiled Static libraries
20+
*.lai
21+
*.la
22+
*.a
23+
*.lib
24+
25+
# Executables
26+
*.exe
27+
*.out
28+
*.app
29+
30+
# Eclipse
31+
.*project
32+
33+
# VScode
34+
.vscode
35+

README.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# V-USB Arduino port (20121206)
2+
3+
Allows an Arduino to act as midi device through 2nd (firmware-only) usb port.
4+
5+
# V-USB
6+
7+
[V-USB](http://www.obdev.at/products/vusb/index.html) by Objective Development Software GmbH
8+
http://www.obdev.at/products/vusb/index.html
9+
10+
# Circuit
11+
![Arduino & V-USB](https://github.com/TechFactoryHU/vusb-arduino/circuits/arduino_vusb_dev.png)
12+
![Arduino & V-USB](https://github.com/TechFactoryHU/vusb-arduino/circuits/arduino_vusb_dev_schematic.png)
13+
14+
Default config:
15+
D- = Pin 7
16+
D+ = Pin 2
17+
18+
You can change default values in src/usbconfig.h file. For more information please visit [Obdev's site] (https://www.obdev.at/products/vusb/index.html)
19+
20+
21+
# Midi sample
22+
```C++
23+
#include <TFUsbMidi.h>
24+
unsigned long ms = 0;
25+
26+
void setup() {
27+
Serial.begin(115200);
28+
//setup midi msg callback
29+
VUsbMidi.OnMsg(OnMidiMessage);
30+
VUsbMidi.begin();
31+
}
32+
33+
void loop() {
34+
//watch for new midi messages
35+
VUsbMidi.refresh();
36+
37+
//send some midi messages at every 5sec
38+
if (ms < millis()) {
39+
Serial.println("SendNoteOn");
40+
//NoteOn message: channel, note, velocity
41+
VUsbMidi.NoteOn(1, 60, 100);
42+
delay(200);
43+
//NoteOff message: channel, note
44+
VUsbMidi.NoteOff(1, 60);
45+
46+
//ControlChange message: channel, ctrlid, value
47+
VUsbMidi.ControlChange(2, 10, 54);
48+
49+
//Send raw message v1:
50+
TFMidiMessage midimsg;
51+
midimsg.type = TFMidiType.NoteOn;
52+
midimsg.channel = 1;
53+
midimsg.data1 = 60; //note
54+
midimsg.data2 = 50; //velocity
55+
VUsbMidi.write(midimsg);
56+
57+
//send raw message v2
58+
byte buffer[4];
59+
buffer[0] = 0x09;
60+
buffer[1] = 0x90 | 1; // message type | channel
61+
buffer[2] = 0x7f & 60; //note
62+
buffer[3] = 0x7f & 50; //velocity
63+
VUsbMidi.write(buffer,4);
64+
65+
ms = millis() + 5000;
66+
}
67+
}
68+
69+
//this function will be called on every midi message
70+
void OnMidiMessage(TFMidiMessage msg) {
71+
Serial.print(msg.type);
72+
Serial.print("\t");
73+
Serial.print(msg.channel);
74+
Serial.print("\t");
75+
Serial.print(msg.data1);
76+
Serial.print("\t");
77+
Serial.println(msg.data2);
78+
}
79+
```
80+
81+
82+
# TFMidiUsb wrapper
83+
84+
Wrapper class based on:
85+
86+
- V-USB-MIDI
87+
http://cryptomys.de/horo/V-USB-MIDI/
88+
89+
- vusb-for-arduino
90+
https://code.google.com/p/vusb-for-arduino/downloads/list
91+
92+
- Arduino MIDI Library
93+
https://github.com/FortySevenEffects/arduino_midi_library
94+
95+
- mimuz-avr-core
96+
https://github.com/mimuz/mimuz-avr-core/blob/master/arduino/libraries/VUSBMidiATtiny
97+
98+

circuits/Readme.txt

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
This is the Readme file for the V-USB example circuits directory.
2+
3+
4+
CIRCUITS IN THIS DIRECTORY
5+
==========================
6+
Since USB requires 3.3 V levels on D+ and D- but delivers a power supply of
7+
ca. 5 V, some kind of level conversion must be performed. There are several
8+
ways to implement this level conversion, see the example circuits below.
9+
10+
with-vreg.png and with-vreg.sch (EAGLE schematics):
11+
This circuit uses a low drop voltage regulator to reduce the USB supply to
12+
3.3 V. You MUST use a low drop regulator because standard regulators such
13+
as the LM317 require at least ca. 2 V drop. The advantage of this approach
14+
is that it comes closest to the voltage levels required by the USB
15+
specification and that the circuit is powered from a regulated supply. If
16+
no USB cable is used (connector directly soldered on PCB), you can even
17+
omit the 68 Ohm series resistors. The disadvantage is that you may want to
18+
use other chips in your design which require 5 V. Please check that the AVR
19+
used in your design allows the chosen clock rate at 3.3 V.
20+
21+
with-zener.png and with-zener.sch (EAGLE schematics):
22+
This circuit enforces lower voltage levels on D+ and D- with zener diodes.
23+
The zener diodes MUST be low power / low current types to ensure that the
24+
1k5 pull-up resistor on D- generates a voltage of well above 2.5 V (but
25+
below 3.6 V). The advantage of this circuit is its simplicity and that the
26+
circuit can be powered at 5 V (usually precise enough if the cable drop is
27+
neglected). The disadvantage is that some zener diodes have a lower voltage
28+
than 3 V when powered through 1k5 and the choice of components becomes
29+
relevant. In addition to that, the power consumption during USB data
30+
transfer is increased because the current is only limited by the 68 Ohm
31+
series resistor. The zeners may even distort the signal waveforms due to
32+
their capacity.
33+
34+
with-series-diodes.png and with-series-diodes.sch (EAGLE schematics):
35+
This is a simplified low-cost version of the voltage regulator approach.
36+
Instead of using a voltage regulator, we reduce the voltage by the forward
37+
voltage of two silicon diodes (roughly 1.4 V). This gives ca. 3.6 V which
38+
is practically inside the allowed range. The big disadvantage is that the
39+
supply is not regulated -- it even depends strongly on the power
40+
consumption. This cannot be tolerated for analog circuits.
41+
42+
tiny45-rc.png and tiny45-rc.sch (EAGLE schematics):
43+
This is mostly an example for connecting an 8 pin device using the internal
44+
RC oscillator for system clock. This example uses series diodes to limit
45+
the supply, but you may choose any other method. Please note that you must
46+
choose a clock rate of 12.8 or 16.5 MHz because only the receiver modules
47+
for these frequencies have a PLL to allow higher clock rate tolerances.
48+
49+
50+
GENERAL DESIGN NOTES
51+
====================
52+
All examples have D+ on hardware interrupt INT0 because this is the highest
53+
priority interrupt on AVRs. You may use other hardware interrupts (and
54+
configure the options at the end of usbconfig.h accordingly) if you make sure
55+
that no higher priority interrupt is used.
56+
57+
If you use USB_SOF_HOOK or USB_COUNT_SOF in usbconfig.h, you must wire D- to
58+
the interrupt instead. This way the interrupt is triggered on USB Start Of
59+
Frame pulses as well.
60+
61+
Most examples have a 1M pull-down resistor at D+. This pull-up ensures that
62+
in self-powered designs no interrupts occur while USB is not connected. You
63+
may omit this resistor in bus-powered designs. Older examples had a pull-up
64+
resistor instead. This is not compatible with the zener diode approach to
65+
level conversion: 1M pull-up in conjunction with a 3.6 V zener diode give an
66+
invalid logic level.
67+
68+
All examples with ATMega8/88/168 have D+ at port D bit 2 (because this is
69+
hardware interrupt 0) and D- on port D bit 4 because it is also a clock input
70+
for timer/counter 0. This way the firmware can easily check for activity on
71+
D- (USB frame pulses) by checking the counter value in regular intervals. If
72+
no activity is found, the firmware should (according to the USB
73+
specification) put the system into a low power suspend mode.
74+
75+
76+
77+
----------------------------------------------------------------------------
78+
(c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH.
79+
http://www.obdev.at/

circuits/arduino_vusb_dev.png

117 KB
Loading
67.5 KB
Loading

circuits/tiny45-rc.png

7.4 KB
Loading

circuits/tiny45-rc.sch

189 KB
Binary file not shown.

circuits/with-series-diodes.png

12 KB
Loading

circuits/with-series-diodes.sch

209 KB
Binary file not shown.

circuits/with-vreg.png

12.8 KB
Loading

circuits/with-vreg.sch

211 KB
Binary file not shown.

circuits/with-zener.png

12.1 KB
Loading

circuits/with-zener.sch

220 KB
Binary file not shown.

examples/MidiTest/MidiTest.ino

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <TFUsbMidi.h>
2+
3+
void setup() {
4+
Serial.begin(115200);
5+
Serial.println("Setup");
6+
7+
Serial.println("VUSB setup onmsg callback");
8+
VUsbMidi.OnMsg(OnMidiMessage);
9+
10+
Serial.println("VUSB begin");
11+
VUsbMidi.begin();
12+
13+
}
14+
15+
unsigned long ms;
16+
17+
void loop() {
18+
//watch for midi packets
19+
VUsbMidi.refresh();
20+
21+
//send some midi messages on every 5sec
22+
if (ms < millis()) {
23+
//send note on: channel, note, velocity
24+
VUsbMidi.NoteOn(1, 60, 100);
25+
delay(200);
26+
//send note off: channel, note
27+
VUsbMidi.NoteOff(1, 60);
28+
//send control change message: channel, ctrlid, value
29+
VUsbMidi.ControlChange(2, 10, 54);
30+
31+
//Send raw message v1:
32+
TFMidiMessage midimsg;
33+
midimsg.type = TFMidiType::NoteOn;
34+
midimsg.channel = 1;
35+
midimsg.data1 = 60; //note
36+
midimsg.data2 = 50; //velocity
37+
VUsbMidi.write(midimsg);
38+
39+
//send raw message v2
40+
byte buffer[4];
41+
buffer[0] = 0x09;
42+
buffer[1] = 0x90 | 1; // message type | channel
43+
buffer[2] = 0x7f & 30; //note
44+
buffer[3] = 0x7f & 50; //velocity
45+
VUsbMidi.write(buffer,4);
46+
47+
ms = millis() + 5000;
48+
}
49+
}
50+
51+
52+
void OnMidiMessage(TFMidiMessage msg) {
53+
Serial.print(msg.type);
54+
Serial.print("\t");
55+
Serial.print(msg.channel);
56+
Serial.print("\t");
57+
Serial.print(msg.data1);
58+
Serial.print("\t");
59+
Serial.println(msg.data2);
60+
}
61+

library.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=V-USB Arduino port
2+
version=1.0.0
3+
author=TechFactory.hu
4+
maintainer=TechFactory.hu <[email protected]>
5+
sentence=Obdev's V-USB arduino compatible version (vusb-20121206)
6+
paragraph=Allows an arduino device to act as midi device through firmware-only usb port
7+
category=Communication
8+
url=https://github.com/TechFactoryHU/vusb-arduino
9+
architectures=*

0 commit comments

Comments
 (0)