Arduino Uno R3, MIDI interface to a USP port on a computer

I have been busy making my Arduino Uno R3 controlled MIDI musical instrument.
My instument has both a Hardware and a Software serial out. If need be I am happy to use only the Software serial out MIDI messages.

With reference to Mike Cooks excellent book “Arduino Music and Arduino projects” Do I need to reprogram my Arduino Uno R3 using the Hiduino project for it to look like a MIDI interface to a USB port on a computer,
or as the Uno R3 no longer uses the 8U2 chip but now features the Atmega16U2 programmed as a USB-to-serial converter is this is no longer necessary?

Sam

What's a USP port?

The ATmega16U2 is basically the same chip as the ATmega8U2, it just has more memory.

The Arduino UNO does not have a native USB port (i.e. the main MCU, the ATmega328P, does not have a hardware USB connection). To get MIDI over USB working, you either have to flash custom MIDI firmware to the ATmega16U2, or use an external MIDI-to-USB interface.
I prefer the first method, however, you can't use the ATmega16U2 for programming the Arduino once you have flashed the MIDI firmware. To change your Arduino program, you either need an external USB-to-Serial adapter, an in-system programmer, or you have to flash the Arduino Serial firmware back to the ATmega16U2 every time you change your program.

To flash the MIDI firmware, you need Atmel Flip or DFU-programmer.
Installation instructions
Flashing instructions

For creating MIDI controllers and instruments, I prefer to use Arduino boards with native USB support. They support MIDI over USB directly, and you don't have to use bodges like Hiduino to get it working.
Examples of boards that support this are Teensy, Arduino Leonardo, Micro, Due, Zero, SparkFun Pro Micro, ...

More information on MIDI over USB on different Arduino-compatible boards

Pieter

Thank you for the reply.

I now fully understand what the issues are.

You say for creating MIDI controllers and instruments, you prefer to use Arduino boards with native USB support such as the Teensy, Arduino Leonardo, Micro, Due, Zero, SparkFun Pro Micro, ...

The reason for using the Uno is that the Atmega328 built-in analog comparator I am using for measuring pulse width from a quadrature optical rotary encoder. I am using Martin Nawrath`s FreqPeriod Library Lab3 - Laboratory for Experimental Computer Science
This is the only way I have got what I wanted to work.

Are any of the boards you mentioned compatible with the Uno in that they have the built-in analog comparator?

The MIDI controller library looks very interesting, I shall be spending some time examining it for ideas .

Sam

I don't really understand why you would need an analog comparator for a quadrature encoder. All quadrature encoders I've come across (both optical and mechanical) produce digital square waves.
You can just use external interrupts, no need for comparators. Check out the Encoder library, used in the MIDI Controller library.

Pieter

Ok, I am a 600 pulse per turn encoder on a MIDI hurdy gurdy that I am building.
See; - YouTube
for an early model of what I am making.
This should give you a good idea of what the encoder is used for. Namely mapping volume to turn speed, setting a trigger point for buzz to speed and setting a velocity with speed for the buzz.
I have attempted every method of using interrupts that I can find but for some reason (perhaps with my limited experience) I cannot get anything to work all attempts I have made have produced undesirable results . Martin Nawrath`s FreqPeriod Library worked out of the can, no problems.

Sam

Counting frequencies is usually done with timer interrupts or external interrupts. There's loads of examples online. For example: Gammon Forum : Electronics : Microprocessors : Timers and counters.
As far as I can see, the comparator is just used as a Schmitt trigger, to convert from sine waves to square waves that can be measured.
No need to do that if your signal already is a square wave and if your edges are sharp enough.

(That being said, I'm pretty sure many other MCUs also contain one or more comparators, and there's nothing stopping you from using an external Schmitt trigger connected to an interrupt pin.)

Pieter

I am using Martin Nawraths FreqPeriod Library to measure Frequency period i.e. the size of the pulse .Yes I know a I do fully realise that I do not need a comparator for measuring square waves, but as I said his library works the way I want it to, if I could get some one else’s code to work I would happily consider using it. If anyone can decipher what Martin Nawrath FreqPeriod Library is doing and work out a way of using it on external interrupts I would be very grateful.
I am have stuck to using the Arduino Uno because I have made it work for all I need for my instrument .I have not had to compromise my project because of any limitations the board may have.
Ultimately I would like to use a bare bones device but it must have the comparator pins on D6 and D7 for using Martin Nawrath`s FreqPeriod Library. Any suggestions please?
Sam