Author Topic: MIDI Library for MikroC or MPLAB X  (Read 643 times)

0 Members and 1 Guest are viewing this topic.

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
MIDI Library for MikroC or MPLAB X
« on: October 01, 2019, 09:16:17 am »
Hi everybody
 
i'm looking for a MIDI Library, like the one that exists for Arduino, for MikroC or MPLAB X.
 
Best regards
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1056
  • Country: fi
Re: MIDI Library for MikroC or MPLAB X
« Reply #1 on: October 01, 2019, 10:38:23 am »
MPLAB X is an IDE. What microcontroller are you targeting, what kinds of features and functionality are you expecting from the library? Basic MIDI by itself is just bytes sent over a serial port.

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
Re: MIDI Library for MikroC or MPLAB X
« Reply #2 on: October 01, 2019, 12:17:36 pm »
Hello

Thanks for the reply.


I initially made with Arduino Mega. Now that I have to industrialize it, I would like to use a PIC, for example 18f4520, but I'm not sure if he has enough pins.

For this my first version I only use the Program Change function, but in the future I would also like to use its other features as well.

So I wanted to know if there was a library that included any MIDI functionality. Like the one that exists for the arduino IDE.

Best regards
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 1276
  • Country: us
  • Yes, I do this for a living
Re: MIDI Library for MikroC or MPLAB X
« Reply #3 on: October 01, 2019, 10:01:09 pm »
Hello

Thanks for the reply.


I initially made with Arduino Mega. Now that I have to industrialize it, I would like to use a PIC, for example 18f4520, but I'm not sure if he has enough pins.

For this my first version I only use the Program Change function, but in the future I would also like to use its other features as well.

So I wanted to know if there was a library that included any MIDI functionality. Like the one that exists for the arduino IDE.

Best regards

I don't remember offhand what is in the Arduino MIDI library, but I suppose I should ask: what is your intent? Are you designing a MIDI controller, that is something that will send MIDI messages to another device, or are you designing a MIDI-controlled "thing," which receives MIDI messages and does something interesting as a result? Or both?

Also I assume you're using serial MIDI on DIN jacks and not MIDI over USB.

MIDI isn't all that difficult. On the receive side you wait for bytes and build up a message to parse. On the transmit side you wait for an event and build a message based on it, then transmit the message.
 

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
Re: MIDI Library for MikroC or MPLAB X
« Reply #4 on: October 02, 2019, 06:16:05 am »
Thanks for the reply

I have already realized my MIDI PEDAL but with Arduino mega. For this first realization i used only PROGRAM CHANGE function of Midi Protocol. I know that PROGRAM CHANGE is equal to a serial data.

Now i have to create a PCB and i can't use Arduino Mega and i think to use PIC.

For the subsequent realizations of my pedal board i would like to use all of functions of MIDI Protocol so i would like to know if there are a Midi Library for MPLAB iDE or MikroC that included all MIDI function.


I hope I was clear

best regards
 

Offline Fire Doger

  • Regular Contributor
  • *
  • Posts: 176
  • Country: 00
  • Stefanos
Re: MIDI Library for MikroC or MPLAB X
« Reply #5 on: October 02, 2019, 12:09:21 pm »
You can't use Arduino mega but you can use atmega2560 which is what arduino mega has. :-//
 
The following users thanked this post: Bassman59, voltsandjolts

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3571
  • Country: fr
Re: MIDI Library for MikroC or MPLAB X
« Reply #6 on: October 02, 2019, 12:19:43 pm »
From what I understand, you want to design a device that basically emits some MIDI commands (are you interested in receiving MIDI commands as well? doesn't look like it.)

From the MCU POV, MIDI is very simple. You just need a UART TX @ 31250 bps. (You'll have to choose the system clock properly so that you can get this rate with the embedded UART peripheral of your MCU. This one is pretty easy. 31250 was not choosen randomly. You'll get that from dividing a pretty standard clock rate by a power of two.)

Then it's just a matter of sending a few bytes. MIDI commands/messages are very simple. You really don't need any library to do this. You just need an MCU with an embedded UART, and send bytes.

Actually, MIDI communication is pretty slow, so you could even bit-bang it without any embedded UART peripheral, even on a small MCU (but don't bother, there are craptons of small and cheap MCUs with appropriate UARTs.)

« Last Edit: October 02, 2019, 12:22:42 pm by SiliconWizard »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 2057
  • Country: fi
Re: MIDI Library for MikroC or MPLAB X
« Reply #7 on: October 02, 2019, 02:02:33 pm »
Yes. It's basically:

1) Pick any microcontroller,
2) Use a suitable crystal frequency so that it divides properly to the desired baudrate (31250 bps). 8 MHz will do fine, because 8000000/256 = 31250
3) Literally recreate the most basic "Hello world" uart example available. Should be approx. 10 lines of code.
4) Instead of "Hello World" text, now just output the MIDI command bytes.
 

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
Re: MIDI Library for MikroC or MPLAB X
« Reply #8 on: October 02, 2019, 03:38:19 pm »
Yes i know. I spoke about PIC beacuase at home i have already PIC 18f4520.

And i can program it with MPLAB X, for example. Correct ?

Best regards
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3571
  • Country: fr
Re: MIDI Library for MikroC or MPLAB X
« Reply #9 on: October 02, 2019, 03:44:07 pm »
Yes i know. I spoke about PIC beacuase at home i have already PIC 18f4520.

And i can program it with MPLAB X, for example. Correct ?

The PIC18F4520 would be fine for this use. It has one UART, one ADC (if you ever need that for reading pots or such), and enough IOs.
Since it can run from 2.0V to 5.5V, you have ample choice for your power supply too.

One last advice is, preferably use an external crystal than the internal oscillator. MIDI is kind of picky regarding the baud rate, so a crystal-based oscillator will be safer to make your device robust.

Yes you can use MPLAB X. You'll also need the XC8 compiler, which is a separate download AFAIK, unless you want to program in assembly (which I doubt  ;D ).
Of course you'll need a programmer "probe" too (such as Pickit or ICD...)

« Last Edit: October 02, 2019, 03:46:28 pm by SiliconWizard »
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 1276
  • Country: us
  • Yes, I do this for a living
Re: MIDI Library for MikroC or MPLAB X
« Reply #10 on: October 02, 2019, 09:50:13 pm »
For the subsequent realizations of my pedal board i would like to use all of functions of MIDI Protocol so i would like to know if there are a Midi Library for MPLAB iDE or MikroC that included all MIDI function.

I think you're still missing the point. There are no "MIDI Functions," per se.

You receive a MIDI message and parse it, and then decide what to do with the contents. And that's application-specific. What does your pedalboard need to do in response to messages it might receive from -- where?

On the transmit side: you have a pedalboard, so I imagine a row of buttons. When you press a button, you send a control-change message. Or a program-change message. Or a Note On/Off message. Building the messages is easy.

But you have to work out what your hardware is supposed to do.
 
The following users thanked this post: lorenrus

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3571
  • Country: fr
Re: MIDI Library for MikroC or MPLAB X
« Reply #11 on: October 02, 2019, 10:33:42 pm »
Yep. If the OP still insists on using this said library, they can just give us a link to it here (provided that it's open source). It's likely not much more than some light sugar coating around UART transmission, and maybe a few constants with the various midi messages. Maybe a few functions to further sugar-coat it, each sending a couple bytes. Probably nothing to write home about.

 

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
Re: MIDI Library for MikroC or MPLAB X
« Reply #12 on: October 03, 2019, 08:33:00 am »
Hello

Premise:
I know Midi Protocol and i able to use Midi fuction without library.

I was just curious if there was a Midi library for MPLAB X or MikroC.

Best regards

 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 3571
  • Country: fr
Re: MIDI Library for MikroC or MPLAB X
« Reply #13 on: October 03, 2019, 05:01:51 pm »
Just saying here, but you are probably (/have already) wasting more time looking for a possible ready-made library than writing it yourself...
 
The following users thanked this post: lorenrus

Offline lorenrus

  • Contributor
  • Posts: 16
  • Country: it
Re: MIDI Library for MikroC or MPLAB X
« Reply #14 on: October 04, 2019, 05:58:18 am »
Good morning

Yes you are right, but in the meantime i'm realizing projects for job.

I'm not idle hahah

Thank you very much
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf