problems with rotary encoder (fixed)

Hi,

I’m trying to use a rotary encoder connected to pin 6 and 7 of my second din register…

I’ve tried to use this encoder with this line in init():

// set encoder speed mode of datawheel
  MIOS_ENC_SpeedSet(14, DATAWHEEL_SPEED_MODE, DATAWHEEL_SPEED_DIVIDER);

  and this code in ENC_NotifyChange(…)

if (encoder == 14) {
        unsigned int value;
	if (cs_layer == CS_LAYER_SFB) {
		CS_GetSFB(cs_sfb_mode);
		value = SFB_val;
		SFB_val = (MIOS_HLP_16bitAddSaturate(incrementer, &value, SFB_max))&0xFF;
	} else {
		//if no special function is selected the encoder changes the current bpm
		value = MCLOCK_BPMGet();
		MCLOCK_BPMSet(MIOS_HLP_16bitAddSaturate(incrementer, &value, 255)&0xFF);
	}
	app_flags.DISPLAY_UPDATE_REQ = 1;
}

but the code seems to do nothing  :frowning:

What if you replace the if statement with something simple like sending a midi CC, does that work?

You got that encoder in the table? Does it work with normal encoder speed?

Sorry for the barrage of questions… I’m trying to pinpoint the source of the fault, and your answers will give me the hints I need :slight_smile:

have you added the Encoder to the table in mios_tables.inc ?

if you did so, try to call an easy function to determine if everthing is wired right, eg:

on ENC_NotifyChange():

MIOS_LCD_Cursor_Set(0x0);

MIOS_LCD_PrintCString(“Encoder down”);

Cheers,

Michael

Sorry for the barrage of questions…

;D now even more…

;D now even more…

Thank you guys for your help  :)  :smiley:

if you did so, try to call an easy function to determine if everthing is wired right, eg:

on ENC_NotifyChange():

I tried this already, same result

You got that encoder in the table?

-> this seems to be the solution, since I have no MIOS asm background

I was even unaware of this table (always seemed a mystery how MIOS identified encoders  ::))

so if I summarise encoder handling in MIOS C:

  • connect encoder to shift register, first pin on an even pin number

  • add an encoder entry in mios_tables.inc

  • add a line in Init() in main.c:

    // set encoder speed mode of datawheel
    MIOS_ENC_SpeedSet(ENCODER_NR, DATAWHEEL_SPEED_MODE, DATAWHEEL_SPEED_DIVIDER);

  • handle encoder events in ENC_NotifyChange(…)

I will try this when I get home tonight…

(always seemed a mystery how MIOS identified encoders  ::))

Hehehehe I know what you mean! It’s one of many little mysteries :slight_smile:

This info is documented here:

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

just for the case you missed the examples

Best Regards, Thorsten.

just for the case you missed the examples

I guess I did miss the encoder example, thanks TK ;D

Everything works now,

I made some stupid errors on my veroboard din module  ::slight_smile: