Jump to content

How to manage with a mix of AINx4 and J5B


dubphil
 Share

Recommended Posts

Hello,

I wanted to add 3 additionnals pots but directly connected to the unused J5B pins of the CORE.

Now when I move those pots I have 8 CC events for each. How can I manage to have only 1 CC per pot ?

Another thing, by playing with setup_midibox64.asm to test things, I have lost the ability for my buttons

to be in the toggle mode, now if I press a button the led light on, but if I released the button the led light off.

I would like to light off the led if I pressed the button a second time (this was the behavior of my buttons/leds before I upload a new mb64 app).

I can't find my original mb64 app (it was in 2009) I have search the forum for an answer, but I didn't found the best solution.

Hope you can help me.

Best regards

Philippe

Edited by dubphil
Link to comment
Share on other sites

Hi,

I wanted to add 3 additionnals pots but directly connected to the unused J5B pins of the CORE.

Now when I move those pots I have 8 CC events for each. How can I manage to have only 1 CC per pot ?

difficult... using pots without multiplexer in an application which has been programmed for multiplexer usage is an exotic usecase and not prepared.

Currently I'm unsure how to handle this properly without making it too complicated at the software (configuration) side, it's definitely not something which could be programmed (and documented) in less than 1 hour.

Do you have a spare 4051? It would be the most efficient solution just to use a multiplexer (costs 0.30 EUR!)

Or alternatively: do you have assembly programming skills, so that you could program this special variant by yourself?

Another thing, by playing with setup_midibox64.asm to test things, I have lost the ability for my buttons

to be in the toggle mode, now if I press a button the led light on, but if I released the button the led light off.

I would like to light off the led if I pressed the button a second time (this was the behavior of my buttons/leds before I upload a new mb64 app).

I can't find my original mb64 app (it was in 2009) I have search the forum for an answer, but I didn't found the best solution.

There are four solutions to change the button mode:

- use the control surface - this requires a LCD and the 4 menu buttons, are they available?

- edit the src/mb64_presets.inc file: e.g. instead of "BUTTON_ENTRY 0x90, 0x30, 0x7f, 0x00" write "BUTTON_ENTRY 0x90, 0x30, 0x7f, 0x02" (0x02 selects the toggle mode)

- configure via SysEx by using an .ini file and converting it to .syx format with the mk_syx.pl script - preferred solution under Linux and MacOS

- configure via SysEx with Serge's editor - preferred solution under Windows.

I'm unsure which one is the best at your side, since I neither know how your MIDIbox looks like, nor (if you prefer configuration via SysEx) which operation system you are using.

Best Regards, Thorsten.

Link to comment
Share on other sites

Thanks for the replies

Do you have a spare 4051? It would be the most efficient solution just to use a multiplexer (costs 0.30 EUR!)

Yes I do, but I have no much place left in my board to put a second AINx4

do you have assembly programming skills, so that you could program this special variant by yourself?

unfortunately not :(

And of course I could use ain64din128dout128 app, but I would need also to associate the DIN and DOUT pins to light up the leds when I press the buttons.

Best

Philippe

Link to comment
Share on other sites

lets go for using ain64din128dout128 app then, but please put me on the rails ;)

I have see that ain64din128dout128 app have only one main.c does everything goes here ?

to enumarate my needs :

1 - pin A5 to A7 each should gives only one CC : I don't guess where to put the switch/cases you suggest julienvoirin

2 - Buttons set to the toogle mode : is there a solution to set this directly in the app code ?

3 - associate DIN pins 17 to 24 to the DOUT pins 17 to 24 : I admit that

easy ! use an array if neccessary for cpxe routines
is far far not easy for my understanding.

I'm damn lost how to achieve this.

Best

Philippe

Edited by dubphil
Link to comment
Share on other sites

Thorsten,

the simple way for me is the best one, what is your advice about modfying ain64din128dout128 app ? this app is fitting my needs, I don't need at all the MB64 app if it is too difficult to modify it.

Do you think that it would be simple for me to use a spare 4051 ? I'm not enough skilled in electronic to build something not documented by schematics or pcb.

Best

Philippe

Link to comment
Share on other sites

Modifiying the ain64din128dout128 app is not the most simple solution, you would have to work through the tutorials to understand the basics first -> http://www.ucapps.de/mios8_c.html otherwise you are lost when debugging your modifications.

If Julien (who brought up the idea) can support you on this topic, it might be feasible for you without spending so much time.

4051: just have a look into the MBHP_AINX4 schematic, the 4051 doesn't need additional circuitry, you can connect it directly to the appr. pins of the core module. Are you able to enhance your MIDIbox based on this schematic, or do you need additional help here? (currently I won't have the time to draw a customized schematic)

Don't forget to connect all unusued pot inputs to ground!

Best Regards, Thorsten.

Link to comment
Share on other sites

Here is my idea

1 - pin A5 to A7 each should gives only one CC : I don't guess where to put the switch/cases you suggest julienvoirin

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

// This function is called by MIOS when a pot has been moved

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

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam

{


	switch (pin){

		case 0: // = 1st pot ^^

		case 1:

		case 2:

		case 3:

		case 4: 

		case 5:

		case 6:

		case 7:

		case 8:

		case 9:

		case 10:

		case 11:

		case 12:

		case 13:

		case 14:

		case 15:

		case 16: 

		case 17:

		case 18:

		case 19:

		case 20:

		case 21:

		case 22:

		case 23:

		case 24:

		case 25:

		case 26:

		case 27:

		case 28:

		case 29:

		case 30:

		case 31: // 32nd pot

		case 32: // pin A5

		case 40: // pin A6

		case 48: // pin A7

			// a pot has been moved, send CC#<pin-number> at channel 1

			MIOS_MIDI_BeginStream();

			MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1

			MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to CC number

			MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value

			MIOS_MIDI_EndStream();

			break;


		default: // all other pots and ain

			// do nothing

			break;


  // notify display handler in DISPLAY_Tick() that AIN value has changed

  last_ain_pin = pin;

  app_flags.DISPLAY_UPDATE_REQ = 1;

	}

}
2 - Buttons set to the toogle mode : is there a solution to set this directly in the app code ?
/////////////////////////////////////////////////////////////////////////////

// This function is called by MIOS when an button has been toggled

// pin_value is 1 when button released, and 0 when button pressed

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

void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam

{

	// http://www.arduino.cc/en/Tutorial/Switch

	// if the input just went from LOW and HIGH, toggle the output pin 


	int state = HIGH;      // the current state of the output pin

	int reading;           // the current reading from the input pin

	int previous = LOW;    // the previous reading from the input pin


	reading = pin_value;


	if ( reading == HIGH && previous == LOW) { // buttons are high-active

		if (state == HIGH){

			state = LOW;

		}

		else{

			state = HIGH;

		}


		// digitalWrite(outPin, state);

		MIOS_MIDI_BeginStream();

		MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1

		MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to note number

		MIOS_MIDI_TxBufferPut(state << 3);  // bitshifting to multiply x127

		MIOS_MIDI_EndStream();


		previous = reading;

	}


	// toggle LED corresponding to pin

	MIOS_DOUT_PinSet( pin, state);


  // notify display handler in DISPLAY_Tick() that DIN value has changed

  last_din_pin = pin;

  app_flags.DISPLAY_UPDATE_REQ = 1;

}
3 - associate DIN pins 17 to 24 to the DOUT pins 17 to 24 : I admit that
	// toggle LED corresponding to pin

	MIOS_DOUT_PinSet( pin, state);

please try the .hex and tell me if it does what expected

ain64_din128_dout128 - dubphil.zip

Edited by julienvoirin
Link to comment
Share on other sites

yeah thanks julienvoirin !

it is nearly perfect, but 3 thins are not working as expected :

1 - pins CC

the pin A7 of j5B gives nothing (it should expect 48 isn't it ?)

the pin A6 of j5B gives 48 (it should expect 40 isn't it ?)

the pin A5 of j5B gives 40 (it should expect 32 isn't it )?

2 - Leds are light on when the button is pressed on but light off when pressed off. the led should stay lighted on until I press a second time on the button.

3 - the LCD don't show events anymore when pots ore sliders are moved it only show events when buttons are pressed and only the DIN part, the DOUT part doesn't show any events (thats not very important indeed)

Best regards and thousand thanks for your assistance !

PS: I remember that you've already help me before with my Core ;)

Link to comment
Share on other sites

the pin A7 of j5B gives nothing (it should expect 48 isn't it ?)

the pin A6 of j5B gives 48 (it should expect 40 isn't it ?)

the pin A5 of j5B gives 40 (it should expect 32 isn't it )?

OK my fault. we count from A0 so ... (i count from A1 like a stupid boy)

         case 31: // 32nd pot

                case 40: // pin A5

                case 48: // pin A6

                case 56: // pin A7

                        // a pot has been moved, send CC#<pin-number> at channel 1

                        MIOS_MIDI_BeginStream();

                        MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1

                        MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to CC number

                        MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value

                        MIOS_MIDI_EndStream();

                        break;

                        
2 - Leds are light ... 3 - the LCD don't show events
parenthesis problem modified code
/////////////////////////////////////////////////////////////////////////////

// This function is called by MIOS when an button has been toggled

// pin_value is 1 when button released, and 0 when button pressed

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

void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam

{

	// http://www.arduino.cc/en/Tutorial/Switch

	// if the input just went from LOW and HIGH, toggle the output pin 


	int state = HIGH;      // the current state of the output pin

	int reading;           // the current reading from the input pin

	int previous = LOW;    // the previous reading from the input pin


	reading = pin_value;


	if ( reading == HIGH && previous == LOW) { // buttons are high-active

		if (state == HIGH){

			state = LOW;

		}

		else{

			state = HIGH;

		}

	}


	// digitalWrite(outPin, state);

	MIOS_MIDI_BeginStream();

	MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1

	MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to note number

	MIOS_MIDI_TxBufferPut(state << 3);  // bitshifting to multiply x127

	MIOS_MIDI_EndStream();


	previous = reading;


	// toggle LED corresponding to pin

	MIOS_DOUT_PinSet( pin, state);


  // notify display handler in DISPLAY_Tick() that DIN value has changed

  last_din_pin = pin;

  app_flags.DISPLAY_UPDATE_REQ = 1;

}


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

// This function is called by MIOS when an encoder has been moved

// incrementer is positive when encoder has been turned clockwise, else

// it is negative

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

void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam

{

}


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

// This function is called by MIOS when a pot has been moved

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

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam

{


	switch (pin){

		case 0: // = 1st pot ^^

		case 1:

		case 2:

		case 3:

		case 4: 

		case 5:

		case 6:

		case 7:

		case 8:

		case 9:

		case 10:

		case 11:

		case 12:

		case 13:

		case 14:

		case 15:

		case 16: 

		case 17:

		case 18:

		case 19:

		case 20:

		case 21:

		case 22:

		case 23:

		case 24:

		case 25:

		case 26:

		case 27:

		case 28:

		case 29:

		case 30:

		case 31: // 32nd pot

		case 40: // pin A5

		case 48: // pin A6

		case 56: // pin A7

			// a pot has been moved, send CC#<pin-number> at channel 1

			MIOS_MIDI_BeginStream();

			MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1

			MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to CC number

			MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value

			MIOS_MIDI_EndStream();

			break;


		default: // all other pots and ain

			// do nothing

			break;

	}


  // notify display handler in DISPLAY_Tick() that AIN value has changed

  last_ain_pin = pin;

  app_flags.DISPLAY_UPDATE_REQ = 1;


}

ain64_din128_dout128 - dubphil v2.zip

Link to comment
Share on other sites

Hi Julienvoirin,

it looks better but things are not going as expected and after trying to understand why, no success

1 - the buttons are no longer in toggle mode (20:0 Note on 0, note 17, velocity 8 | 20:0 Note off 0, note 17)

2 - A5 of J5B sends CC #40 but display #40 to #47 on the LCD

3 - A6 of J5B sends CC #48 but display #48 to #55 on the LCD

4 - A7 of J5B sends CC #56 but display #56 to #63 on the LCD

5 - DOUT part of the LCD is not showing events (not very important)

Hope this is easily correctible.

Best regards

Philippe

in fact for A5 A6 and A7 the LCD looks buggy, at certain position values are changing alone but midi CC is ok

Edited by dubphil
Link to comment
Share on other sites

for A5 A6 and A7 the LCD looks buggy,
that's what is expected ! you also need too see the right pin ?? i had understood that you only needed the right CC on midi OUT

5 - DOUT part of the LCD is not showing events (not very important)
of course ! it displays the midi messages SENT TO the midi box (midi in)

change the value of HIGH and LOW in main.h for (HIGH = 1, LOW = 0)

change this :

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

// This function is called by MIOS when an button has been toggled

// pin_value is 1 when button released, and 0 when button pressed

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

void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam

{

        // http://www.arduino.cc/en/Tutorial/Switch

        // if the input just went from LOW and HIGH, toggle the output pin 



        reading = pin_value;


        if ( reading == HIGH && previous == LOW) { // buttons are high-active

                if (state == HIGH){

                        state = LOW;

                }

                else{

                        state = HIGH;

                }

        }


        // digitalWrite(outPin, state);

        MIOS_MIDI_BeginStream();

        MIOS_MIDI_TxBufferPut(0x90); // Note at channel 1

        MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to note number

        MIOS_MIDI_TxBufferPut(state *127);  //  to multiply x127

        MIOS_MIDI_EndStream();


        // toggle LED corresponding to pin

        MIOS_DOUT_PinSet( pin, state);


         previous = reading;


  // notify display handler in DISPLAY_Tick() that DIN value has changed

  last_din_pin = pin;

  app_flags.DISPLAY_UPDATE_REQ = 1;

}
put this in initialise data section :
        

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

// Local variables

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


// last ain/din/dout

unsigned char last_ain_pin;

unsigned char last_din_pin;

unsigned char last_dout_pin;


int state = HIGH;      // the current state of the output pin

        int reading;           // the current reading from the input pin

        int previous = LOW;    // the previous reading from the input pin

and recompile the app of course

Edited by julienvoirin
Link to comment
Share on other sites

I think I have understand how to make the cahnges you suggest, but when I type "make"

I have this error :

sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./include/share -I ./modules/app_lcd/dummy -DDEBUG_MODE=0 -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I ./modules/mios_wrapper modules/mios_wrapper/mios_wrapper.asm -o _output/mios_wrapper.o

./bin/mios-gpasm: 24: declare: not found

./bin/mios-gpasm: 27: declare: not found

./bin/mios-gpasm: 37: Syntax error: "(" unexpected (expecting "fi")

make: *** [_output/mios_wrapper.o] Erreur 2

I have sdcc and gputils installed (ubuntu oneiric)

About the LCD with pin A7 A6 and A5 it would be great to have the same event that I have with midi out.

Best

Philippe

Link to comment
Share on other sites

Thanks julienvoirin it remains a starnge bug,

look at this sequence :

I press the button of DIN pin 19 :

20:0 Note off 0, note 19

20:0 Note on 0, note 19, velocity 127 => the DOUT pin 19 stay light on OK

then I press the button of DIN pin 20 :

20:0 Note on 0, note 20, velocity 127 => the DOUT pin 20 light on

20:0 Note off 0, note 20 => the DOUT pin 20 light off

I would expect that the DOUT pin 20 stay light on of course.

perhaps the toggle mode is not what I need, I have see a "Note on mode" is it this what I need in fact ?

Best regards

Philippe

Link to comment
Share on other sites

  • 2 weeks later...

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...
 Share

×
×
  • Create New...