Jump to content

led programming.... pc interface


dizzu

Recommended Posts

How should i program the leds so that for each different midi note coming from the pc a different led lights? I have 128 leds connected to core.

I tested ain64_din128_dout128 and works fine, so I would like to do the same from the pc now

Basically i want to build a software ( hope that I find one free :-) ), to trigger an led according to outputs selected, from 0-127

Thanks a lot

Link to comment
Share on other sites

thanks, working nearly as i want it but....

I wrote the following;

/////////////////////////////////////////////////////////////////////////////

// This function is called by MIOS after startup to initialize the

// application

/////////////////////////////////////////////////////////////////////////////

void Init(void) __wparam

{

  // set shift register update frequency

  MIOS_SRIO_UpdateFrqSet(1); // ms

  // only one DOUTX4 module is connected

  // the maximum value is 16 (-> 128 digital outputs)

  MIOS_SRIO_NumberSet(16);

}

/////////////////////////////////////////////////////////////////////////////

//  This function is called by MIOS when a complete MIDI event has been received

/////////////////////////////////////////////////////////////////////////////

void MPROC_NotifyReceivedEvnt(

  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2, unsigned char pin, unsigned char value) __wparam

{

  // a note event provides 128 different note values (0..127)

  // in this simple example, each note sets an individual pin

  // for DOUT pin numbers, see also this documentation:

  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!

    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)

    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off

      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On

      MIOS_DOUT_PinSet(pin, 1);

    }

  }

}

and every note I send I get the same first led to light only. Can I modify the code so that each led corresponds to a different note?

Thanks

Link to comment
Share on other sites

void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2, unsigned char pin, unsigned char value) __wparam
Hah where did ya get that from? should look like this:
void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
then do:
MIOS_DOUT_PinSet(evnt1, 1)

Link to comment
Share on other sites

not working............ now no led's light

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!

    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)

    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off

      MIOS_DOUT_PinSet(evnt1, 0);

    } else {

      // Note On

      MIOS_DOUT_PinSet(evnt1, 1);

No idea how or what's happening :-(

Link to comment
Share on other sites

Well, posting in year-old threads may not help, especially when they already put the answer there ;)

Cross-posting like that is generally considered bad netiquette, it just creates confusion...

Maybe you should try some troubleshooting... Try hardcoding a value in there...

MIOS_DOUT_PinSet(32, 1);

Link to comment
Share on other sites

sorry about posting.. i deleted it.

Yes I already tried hardcoding before like this

 // Note Off
      MIOS_DOUT_PinSet(2, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(2, 1);

It works when I send a midi note, turns on led 3 and off straightaway.

I am sending midi notes from the keyboard on MIOS studio, that's ok to test?

Link to comment
Share on other sites

You don't seem to have set the 'pin' variable from the note number?

Speaking of which- I was looking at some of Thorsten's "Programming Examples" from the bottom of the MIOS C interface page the other night, and there's an example which seems to do the same thing (I couldn't find the link between the incoming note # and the "pin" variable used for the DOUT call). IIRC, I had seen the missing part in one of his other apps or examples, so maybe the example snippet was pulled from one of them.

Take Care

Link to comment
Share on other sites

When trying to code this ' Controlling 128 LEDs VIA midi ' example

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  // set shift register update frequency
  MIOS_SRIO_UpdateFrqSet(1); // ms

  // only one DOUTX4 module is connected
  // the maximum value is 16 (-> 128 digital outputs)
  MIOS_SRIO_NumberSet(16);
}


/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);

    }
  }
}

I get

main.c:83: error 20: Undefined identifier 'pin'

main.c:83: error 20: Undefined identifier 'pin'

main.c:88: error 20: Undefined identifier 'pin'

main.c:88: error 20: Undefined identifier 'pin'

Thanks

Link to comment
Share on other sites

Wel that'll be because it's not defined.

This is the same answer that you have been given before in this thread and that you saw in the other thread.

Use evnt1 like instructed before, or try this:

/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{

unsigned char pin;

pin = evnt1;

  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);

    }
  }
}

I would also recommend that you read The C Book, you can find it with a search of the forums here.

Link to comment
Share on other sites

THANKS stryd_one... I got something working at last!!!!!

Now the led's are following the velocity setting. Now I need to set them to turn off and not stay ON.

I will do as you're suggesting and read more in detail.

Somehow my final project is to connect 12 cores with 128leds each at a distance between them so that I could fire a show.

You think that's possible? 

THANKS, thanks

Link to comment
Share on other sites

Wicked :) If it works for velocity, then it will be using evnt2, so just replace that with for evnt1, and it will be using the note number :)

Dave: Nope :( I'm still wanting to find time to try --extended ;) ... and find a version of the doc old enough to tell me what --fstack was before they removed it hehehe

Link to comment
Share on other sites

My DOUT is wired to core J8, correct?

tried evnt0, evnt1, evnt2 but all i can get is velocity to trigger led's

This code turns ON led 0 and OFF


  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet0(evnt0);

    } else {

      // Note On
      MIOS_DOUT_PinSet1(evnt0);

    }
  }
}
and this turns ON but never OFF the corresponding led with velocity...
      // Note Off
      MIOS_DOUT_PinSet0(evnt2);

    } else {

      // Note On
      MIOS_DOUT_PinSet1(evnt2);

Link to comment
Share on other sites

this is getting painful - please go and read up on C

the way to use the function is thus:

MIOS_DOUT_PinSet(pin, 0);

have a look at your code - if you can't work out why it's not working I can't help you, you simply need to learn more about C or one of us is gonna end up coding your app for you, one line at a time

Link to comment
Share on other sites

Dizzu,

You should look further into the MIDI note formatting and where MIOS stores the different parts when it receives a note event (pretty well documented in TK's apps). There's a decent description about halfway down the page here:

http://www.mibac.com/Pages/MIDIReference.html

The three bytes you'll likely be interested in will get dumped into evnt0,evnt1, and evnt2. The first will be the status, which should be a hexadecimal 9x or 8x for note on and off, where "x" is the channel number, 0-15 (0toF hex) for the 16 MIDI channels. As Thorsten has noted, sometimes a note-off will be handled by a note "on" message with a velocity value of zero (9x xx 00). So with evnt0 being passed to the pinset call, you'll effectively be trying to activate some pin way up in the #150 range (hex 90 = dec 144), and probably the same pin each time, even if the note number changes (don't know how the app handles something out of DOUT range).

The part of the message you probably want to send to the DOUT call will be the second byte (evnt1), which holds the incoming note number. Not sure what range you'll be working with, but by default, I guess they'll be triggered by notes 00 and up (pretty low). You may need to subtract something from that evnt1 argument when you use it, if you can't alter the notes you're sending the box.

Also, make sure you incorporate something to turn 'off' the lights, or they'll stay on forever. For instance:

    if( evnt0 == 0x80 || evnt2 == 0x00 ) 
       MIOS_DOUT_PinSet0(evnt1);

should take anything that's a "note off" or "note on with a velocity (3rd byte/evnt2) of zero" and trigger a DOUT "off" message mapping the incoming note# to the pin you want to disable.

Hope that helps, :)

George (fellow C newbie) 

-- BTW, if you haven't already noticed, there's also the call David mentioned, where you specify pin on/off with the second argument you pass to it. I guess either way is OK.

Link to comment
Share on other sites

Yes I am reading some tutorials now.

I am testing notes from midi keyboard on MIOS Studio. Till now only with velocity I managed to trigger led's.

I ask a question; My final project is to build a 12 core system all with different addresses (electronic pyro firing system), so that I can use/write a software that will send specified notes from a cue list so that I turn on for ex: led 13 on core address 6; at least that's what I intend to do.

Do you think midi is the way, or is there a more reliable protocol?

Thanks

Link to comment
Share on other sites

oooops - I just reread your question and the functions list - my apologies, I completely missed the MIOS_DOUT_PinSet0 funciton - my bad, I shouldn't assume...

so that I can use/write a software that will send specified notes from a cue list so that I turn on for ex: led 13 on core address 6; at least that's what I intend to do.

Do you think midi is the way, or is there a more reliable protocol?

1st question - why midi? I.e. are you going to sync to a performance that is running midi anyway, like a band or PA so you can trigger the pyros on say for instance a drum roll?

if not, then i'd say DMX might be a better way to go, as you can intergrate with the lighting desk and there are lots of cool lighting programs around.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...