Jump to content

Add 18 encoder in AIN64_DIN128_DOUT128


Junkyseb

Recommended Posts

Hi,

i've got some problem with my midibox program.

I made a ableton lives's control surface with 78 switch and 18 encoder. Of course I can't use the MB64E appli cause I have more than 64 switch...

So I try to use the C program call AIN64_DIN128_DOUT_128 but I not manage to add the encoder. As I never progam in C I need some help.

I try to edit the mios_enc_table.inc but it doesn't work when i recompile the program...

Can you give me some hints please ???

Link to comment
Share on other sites

What doesn't work?

Do you have the correct toolchain installed?

Do you get an error during compile or does the app simply not work?

If you get an error - what does it say?

Show some code!

Give us some details to work with ;-)

You might not like nILS' questions, but you won't get far unless you answer them ;)

Link to comment
Share on other sites

well...

is toolchain mean MSYS, gputils etc ??? if yes, everything is well install on my computer.

No error while compile the app. The app work perfectly for the switch but the encoder are invisible for the app.

I edit the main.h. I only notice that I have No AIN (my config : 1 core + 4DINX4)

// $Id: main.h 234 2008-03-28 23:10:41Z tk $
/*
 * Main header file
 *
 * ==========================================================================
 *
 *  Copyright <year> <your name>
 *  Licensed for personal non-commercial use only.
 *  All other rights reserved.
 *
 * ==========================================================================
 */

#ifndef _MAIN_H
#define _MAIN_H

/////////////////////////////////////////////////////////////////////////////
// Global definitions
/////////////////////////////////////////////////////////////////////////////

#define AIN_NUMBER_INPUTS      0    // number of used analog inputs (0..64)
#define AIN_MUXED_MODE         0    // set this to 1 if AIN modules are used
#define AIN_DEADBAND           7    // define deadband here (higher values reduce the effective resolution but reduce jitter)
                                    // 7 is ideal for value range 0..127 (CC events)

#define NUMBER_OF_SRIO        16    // how many shift registers chained at the DIN/DOUT port (min 1, max 16)

#define DIN_DEBOUNCE_VALUE    10    // 0..255
#define DIN_TS_SENSITIVITY     0    // optional touch sensor sensitivity: 0..255

/////////////////////////////////////////////////////////////////////////////
// Global Types
/////////////////////////////////////////////////////////////////////////////

// status of application
typedef union {
  struct {
    unsigned ALL:8;
  };
  struct {
    unsigned DISPLAY_UPDATE_REQ:1;  // requests a display update
  };
} app_flags_t;


/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////
extern app_flags_t app_flags;

#endif /* _MAIN_H */
Then editing the mios_enc_table.inc in the \include\asm :
; $Id: mios_enc_table.inc 69 2008-02-01 00:20:18Z tk $
;
; "Dummy" Configuration Table for Rotary Encoders
; 
; Should be included by the application, if no rotary encoders are connected
; in order to pre-initialize the table area with EOT's
; 
; ==========================================================================

	org	0x3280		; never change the origin!

;; --------------------------------------------------------------------------
;; In this table DIN pins have to be assigned to rotary encoders for the
;; MIOS_ENC driver 
;; 
;; up to 64 entries are provided
;; 
;; The table must be terminated with an ENC_EOT entry. Unused entries should
;; be filled with ENC_EOT
;; 
;; ENC_ENTRY provides following parameters
;;    o first parameter: number of shift register - 1, 2, 3, ... 16
;;    o second parameter: number of pin; since two pins are necessary
;;      for each encoder, an even number is expected: 0, 2, 4 or 6
;;    o the third parameter contains the encoder mode:
;;      either MIOS_ENC_MODE_NON_DETENTED
;;          or MIOS_ENC_MODE_DETENTED
;;          or MIOS_ENC_MODE_DETENTED2
;;          or MIOS_ENC_MODE_DETENTED3
;;
;; Configuration Examples:
;;    ENC_ENTRY  1,  0,  MIOS_ENC_MODE_NON_DETENTED    ; non-detented encoder at pin 0 and 1 of SR 1
;;    ENC_ENTRY  1,  2,  MIOS_ENC_MODE_DETENTED        ; detented encoder at pin 2 and 3 of SR 1
;;    ENC_ENTRY  9,  6,  MIOS_ENC_MODE_NON_DETENTED    ; non-detented encoder at pin 6 and 7 of SR 9
;; --------------------------------------------------------------------------

	;; encoder entry structure
ENC_ENTRY MACRO sr, din_0, mode
	dw	(mode << 8) | (din_0 + 8*(sr-1))
	ENDM	
ENC_EOT	MACRO
	dw	0xffff
	ENDM

_MIOS_ENC_PIN_TABLE
MIOS_ENC_PIN_TABLE
	;; encoders 1-16
	;;        SR  Pin  Mode
	ENC_ENTRY  1,  0,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  1,  2,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  1,  4,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  1,  6,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  2,  0,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  2,  2,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  2,  4,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  2,  6,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  3,  0,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  3,  2,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  3,  4,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  3,  6,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  4,  0,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  4,  2,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  4,  4,  MIOS_ENC_MODE_DETENTED
	ENC_ENTRY  4,  6,  MIOS_ENC_MODE_DETENTED

	;; encoders 17-32
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT

	;; encoders 33-48
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT

	;; encoders 49-64
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT
	ENC_EOT

I compile the code by typing make in the command shell.

I've an uptade of the project.hex and I load it in my PIC with mios studio...

What's wrong ??? where is my mystake ?

Thanks for your help

Link to comment
Share on other sites

hi,

take a look into the main.c file :

/////////////////////////////////////////////////////////////////////////////
// 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
{
}

as you can see, in this app, there is nothing programmed to do something when an encoder is moved..so you have to add some code yourself:

examples:

http://www.ucapps.de/mios_c_send_enc_rel.html

http://www.ucapps.de/mios_c_send_enc_abs7.html

Link to comment
Share on other sites

On a related note, this is the third time in two weeks I've seen someone edit MIOS files in an attempt to make their app work. The rule on this is pretty simple:

You never have to change any part of MIOS. If you find yourself editing MIOS files, something has gone wrong, and it's time to post on the forum or visit the chat ;)

The reason for this is simply because TK has already provided a way to change everything you need, at the application level. The encoder_tables_in_c page is a prime example of this.

Link to comment
Share on other sites

sorry, but with my poor english I don't see what you mean...

I'm not editing mios file, I try to edit the app file.

My big mistake was that I forgot that MB64e could have only 64 switch...

I have had a look at the encoder_table_in_c page but it's still not clear for me. I'm really noob in programmation. I've already manage to config my last midibox based on MB64E. But with the AIN64_DIN128 I d'ont understand why there's a Mios_enc_table.inc file because when I edit it it change nothing in the hex file. Do you see what I mean?

I'm looking at the encoder_table_in_C page on the wiki and I see :

makefile

Add the â€-DDONT_INCLUDE_MIOS_ENC_TABLE†define:

# pass parameters to MIOS wrapper

MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f \

                      -DDONT_INCLUDE_MIOS_ENC_TABLE

Does It mean that I have to edit the makefile file in order to make it like that ?:

MIOS_PATH= .
MIOS_BIN_PATH = .\bin
export MIOS_PATH
export MIOS_BIN_PATH
include makefile.orig
# pass parameters to MIOS wrapper
MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f \
                       -DDONT_INCLUDE_MIOS_ENC_TABLE


Sorry for my dummy question...

Link to comment
Share on other sites

yeah, work in progress !

I try to follow the moxi's post and I use the page http://www.ucapps.de/mios_c_send_enc_rel.html

My encoders work... a little ! I mean when I turn one encoder I have this message in mios studio :

B0 10 3D Channel 1 : CC GP Controller 1 value : 61

The first problem is that the value is between 61 and 67... is it normal, I expected a value between 1 and 127...

Idem for encoder 2, 3 and 4.

for encoder 5,6,7,8  : Channel 1 : CC undefined  value : 65

and the value is 65,66 or 67...

Any Idea?

Link to comment
Share on other sites

I'm not editing mios file, I try to edit the app file.

You said:

Then editing the mios_enc_table.inc in the \include\asm :

That is not really part of the application, it is part of MIOS. You should not edit this file.

As you can see in SVN, There are only four files to this app, two if you don't count the readme and the makefile. From your description, what you have, is a 'distribution package'. This contains not only the application, but all of the other required files to build the application to run on MIOS. /include/asm/* are some of those files. A distribution package is intended for releasing a finished applicaton for distribution, and not for creating a new application as you have. This is because modifications are made which make it possible to build the application from the contents of the one .zip file, but they can make changing the application a little tricky. I'll come back to that.....

I have had a look at the encoder_table_in_c page but it's still not clear for me. I'm really noob in programmation. I've already manage to config my last midibox based on MB64E. But with the AIN64_DIN128 I d'ont understand why there's a Mios_enc_table.inc file because when I edit it it change nothing in the hex file. Do you see what I mean?

Yes. that is how it's supposed to work. That file should not be edited, it is (as it says at the top of the file) a dummy table. It serves the purpose of providing an empty table, when no other table is provided. MIOS will look for the encoder table in your application files, if you provide the table it as it is shown on the wiki page, or as included in the example you have found.

I'm looking at the encoder_table_in_C page on the wiki and I see :

Does It mean that I have to edit the makefile file in order to make it like that ?:

MIOS_PATH= .
MIOS_BIN_PATH = .\bin
export MIOS_PATH
export MIOS_BIN_PATH
include makefile.orig
# pass parameters to MIOS wrapper
MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f \
                       -DDONT_INCLUDE_MIOS_ENC_TABLE


Almost, but not quite. If you are building a new app, you would do it using the mios_base package, and a fresh skeleton. The skeleton has a makefile in it, which you would normally edit, as you have done above. So... almost :)

But not quite... I mentioned that distribution packages are not intended for creating new apps, and this is one reason why. You'll notice that the last line in the makefile (before you edited it), is:

include makefile.orig

That line, as it suggests, includes the contents of the file named makefile.orig, in this file. As it's name suggests, it is the original makefile, as it would have been in the application, prior to being converted into a distribution package.

Because you have placed your edit below that line, the entirety of makefile.orig, which builds the app for you, will have completed, before your modification is reached. If you put the text before the 'include', then it still would not work, because that variable is overwritten in makefile.orig. You should edit makefile.orig..... or better yet, you should get rid of your current distribution package, download the mios_base package, and use the skeleton to create your new app.

Sorry for my dummy question...

The question was not dummy, but not bothering to search the wiki was!

Link to comment
Share on other sites

My encoders work... a little ! I mean when I turn one encoder I have this message in mios studio :

B0 10 3D Channel 1 : CC GP Controller 1 value : 61

The first problem is that the value is between 61 and 67... is it normal, I expected a value between 1 and 127...

They are working perfectly. You are sending midi CC's to be used as a relative signal, not absolute - that means, it's not 0...127, it is +1 or -1 or +2 or -2 or +3 or -3, etc etc....The faster you turn, the more it increments or decrements. 64 would be 0; 65 is +1, 66 is +2; 63 is -1, 62 is -2, etc etc.....

Link to comment
Share on other sites

Thanks a lot Stryd_one for explaining. it's very clear now !

Moxi, I have try with the other exemple and it work perfectly !

Just one (last) question :

My 4 first encoder send a value named GP controler 1(or 2, 3, 4) and the encoder 5 to 16 send value called undifined value... Why ???

I search in every files and I didn't find... It's not a real problem but I love knowledge ;-)

Link to comment
Share on other sites

Cool :)

My 4 first encoder send a value named GP controler 1(or 2, 3, 4) and the encoder 5 to 16 send value called undifined value... Why ???

I search in every files and I didn't find... It's not a real problem but I love knowledge ;-)

That's not sent by MIOS, the midibox is just sending midi. The PC software that displays the MIDI messages for you, shows the Defined Controller Name, as per the MIDI specification.

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