3

I just bought my first Arduino compatible device, and I am greatly enjoying it. I finally could not resist the urge after going to an Arduino meetup, where someone showed me their Teensy connected to their laptop and reacting to MIDI signals over USB.

Not knowing anything, I bought my clone and soon learned about the whole CH340G limitation where it doesn't "just work" (I cannot simply use the USBMIDI Arduino library), and instead I need to run a software MIDI-serial converter command (ttymidi) in order to send the signals to my Arduino clone.

I've been reading up a bit (the amount of information out there is perhaps too vast and often outdated or simply doesn't exactly solve my problem) and have learned of V-USB and the project V-USB-MIDI but I am really out of my element here and do not know how to approach this to get it all working (since it is not just an Arduino sketch and .h header). Or even if this is a solution to my problem. I've read about some solutions which require using an AVR via some of the pins (as opposed to over USB) since you have to reprogram the chip in such a way that it no longer is programmable over USB once the sketch is uploaded, but if I understood it correctly, you can't do even this on the CH340G.

In any case, are there any examples of getting this working? A sketch or something? I downloaded the latest V-USB release, but I really don't want to make a mistake that will brick or otherwise ruin my device.

Basically: I want to just upload my MIDI sketch (with whatever necessary modifications or code) such that I do not need ttymidi to have the device recognized as a MIDI device (over USB) that I can just "plug 'n' play".

5
  • The CH340G is a clear USB to "UART TTL" converter. Some Arduino's or types of them use another AVR chip for the serial connection and can be reprogrammed. And some have the USB stack in the chip. AFAIK the CH340G is not reprogrammable. Best option would be to just get an Arduino that has a reprogrammable USB interface.
    – aaa
    Commented Mar 31, 2016 at 6:23
  • "Horses for courses." Get a USB based MCU board not a UART based MCU board and do it properly.
    – Majenko
    Commented Mar 31, 2016 at 9:59
  • 1
    @Mattia - Thanks for all of the suggested edits, most of them are very high quality. However, some have been a little inconsistent, and not as thorough as others. For example, could you take a look at the edits you made in this post, and the additional edits that I made when I reviewed your edit? Also, could you be a little more descriptive in your "Edit Summary", i.e. "fixed typos, spelling, inlined links", etc., as it makes reviewing the edits easier. Please note that I am not trying to discourage you in any way - like I said, your edits are generally very good. Keep up the good work :-) Commented Mar 31, 2016 at 13:27
  • 1
    @Greenonline sure, I got your point!
    – rebatoma
    Commented Mar 31, 2016 at 13:44
  • @Mattia - Thanks... Like I said, you are doing a great job! :-) Commented Mar 31, 2016 at 13:45

1 Answer 1

2

V-USB bit bangs some GPIO pins so that they speak the low-speed USB protocol. This does not use the 'normal' USB connection through the CH340; you would have to solder a separate USB cable to those GPIO pins.

Programming would be no problem; the V-USB code is just normal code that runs on the MCU. (Programming through ISP pins would be required on hardware where USB communication and programming is handled with a second AVR MCU; in that case, the USB/MIDI code would run on that second MCU.)

Low-speed USB is not supposed to be used for MIDI, and as a software emulation, V-USB does not work very well, or efficiently. If you want to create a USB device, you should use an MCU that actually supports USB in hardware, such as the ATmega32U4 or AT90USB646 used on some Teensies.

7
  • Does that mean it cannot be done with my at328p/ch340g without extra hardware?
    – insaner
    Commented Mar 31, 2016 at 20:24
  • The CH340 is a fixed serial-port device; this cannot be changed in software.
    – CL.
    Commented Mar 31, 2016 at 20:33
  • I have now purchased a couple of USB to TTL converters like this: ebay.ca/itm/… and this: ebay.ca/itm/… would connecting these to some digital pins on the Nano enable me to do what I am trying to do, over this USB connection?
    – insaner
    Commented May 21, 2016 at 6:13
  • The PL2303 is a fixed serial-port device; this cannot be changed in software.
    – CL.
    Commented May 21, 2016 at 6:19
  • Your problem is that the ATmega328 itself does not have built-in USB support. If you want to have USB/MIDI support, you could rip apart a USB/MIDI interface and connect it to your ATmega; alternatively, replace your board with a Teensy.
    – CL.
    Commented May 21, 2016 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.