Jump to content

modify the direction of work an encoder


Recommended Posts

Posted (edited)

hi all

i build a midibox sid on a home made pcb

but a lot of my encoder work on the wrong way

i have inverted the sr pin on eagle without paying attention -(

when i turn the encoder clockwise it decrease the value

that's possible to modify the direction of work an encoder in sid app ?

best regards

yoda

http://www.youtube.com/watch?v=E0QNuXENkQw

Edited by yodabe
Posted

Yes, this is possible by inversing the incrementer in main.inc:



;; --------------------------------------------------------------------------
;; This function is called by MIOS when an encoder has been moved
;; Input:
;; o Encoder number in WREG and MIOS_PARAMETER1
;; o signed incrementer value in MIOS_PARAMETER2:
;; - is positive when encoder has been turned clockwise
;; - is negative when encoder has been turned counter clockwise
;; --------------------------------------------------------------------------
USER_ENC_NotifyChange
comf MIOS_PARAMETER2, F ; inverse incrementer
...
[/code]

Best Regards, Thorsten.

Posted

thx Thorsten

thats work for all encoder but how to for only 8 encoder on 12 ?

4 work normally

thx

best regards

Pascal

Yes, this is possible by inversing the incrementer in main.inc:



;; --------------------------------------------------------------------------

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

;;  Input:

;;     o Encoder number in WREG and MIOS_PARAMETER1

;;     o signed incrementer value in MIOS_PARAMETER2:

;;       - is positive when encoder has been turned clockwise

;;       - is negative when encoder has been turned counter clockwise

;; --------------------------------------------------------------------------

USER_ENC_NotifyChange

        comf    MIOS_PARAMETER2, F  ; inverse incrementer

...

Best Regards, Thorsten.

Posted

Which encoders should be reversed exactly?

Best Regards, Thorsten.

Osc delay/transpose/assign sr 3 pin 0

Filter CutOff sr 3 pin 2

Filter Resonance sr 4 pin 0

Env depth/assign sr 4 pin 2

Env sustain/assign sr 5 pin 0

Env release/assign sr 5 pin 2

Osc attack/finetune/assign sr 2 pin 0

Osc decay/portamento/assign sr 2 pin 2

thx

best regards

Posted

Yes, this is possible by inversing the incrementer in main.inc:



;; --------------------------------------------------------------------------

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

;;  Input:

;;     o Encoder number in WREG and MIOS_PARAMETER1

;;     o signed incrementer value in MIOS_PARAMETER2:

;;       - is positive when encoder has been turned clockwise

;;       - is negative when encoder has been turned counter clockwise

;; --------------------------------------------------------------------------

USER_ENC_NotifyChange

        comf    MIOS_PARAMETER2, F  ; inverse incrementer

...

Best Regards, Thorsten.

I am trying to do the same thing, I've added the line so that it looks like this:

USER_ENC_NotifyChange

comf MIOS_PARAMETER2, F ; inverse incrementer

movf SID_MIDI_DEVICE, W ; exit if device ID != 0x00

skpz

return

and the encoders work in the opposite direction, but now I have to turn past several detents to increase by one increment. My encoders in general behave erratically when this line is added. Can you spot my mistake? I added it by copy/past in a text editor the main.inc file.

Thanks for your help, looking forward to learning more about this since it's the first time I've done anything other than change din and dout assignments.

Posted

Osc delay/transpose/assign sr 3 pin 0

Filter CutOff sr 3 pin 2

Filter Resonance sr 4 pin 0

Env depth/assign sr 4 pin 2

Env sustain/assign sr 5 pin 0

Env release/assign sr 5 pin 2

Osc attack/finetune/assign sr 2 pin 0

Osc decay/portamento/assign sr 2 pin 2

So, these are encoder number #1, 2, 3, 8, 9, 10, 11, 12 in the MIOS_ENC_PIN_TABLE (-> setup_* file)

Workaround (simplified form, there are also ways to optimize this check but it would lead to more complicated code):


;; --------------------------------------------------------------------------
;; This function is called by MIOS when an encoder has been moved
;; Input:
;; o Encoder number in WREG and MIOS_PARAMETER1
;; o signed incrementer value in MIOS_PARAMETER2:
;; - is positive when encoder has been turned clockwise
;; - is negative when encoder has been turned counter clockwise
;; --------------------------------------------------------------------------
USER_ENC_NotifyChange
movf MIOS_PARAMETER1, W
xorlw 1
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 2
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 3
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 8
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 9
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 10
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 11
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer

movf MIOS_PARAMETER1, W
xorlw 12
skpnz
comf MIOS_PARAMETER2, F ; inverse incrementer
...
[/code]

Best Regards, Thorsten.

Posted

and the encoders work in the opposite direction, but now I have to turn past several detents to increase by one increment. My encoders in general behave erratically when this line is added. Can you spot my mistake?

In this case there is no software solution, you have to fix the encoder connections hardware-wise!

(this shouldn't be so difficult, even if a PCB is used)

Best Regards, Thorsten.

Posted

In this case there is no software solution, you have to fix the encoder connections hardware-wise!

(this shouldn't be so difficult, even if a PCB is used)

Best Regards, Thorsten.

Yes, they work fine when this line is not added, one detent per increment, and performance is good, and they work properly when I modify the hardware, so I thought that I made an error in the conkinde that was causing poor performance. It is no big deal to correct the hardware. I will just do that. Thanks~

Posted (edited)

So, these are encoder number #1, 2, 3, 8, 9, 10, 11, 12 in the MIOS_ENC_PIN_TABLE (-> setup_* file)

Workaround (simplified form, there are also ways to optimize this check but it would lead to more complicated code):


;; --------------------------------------------------------------------------

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

;;  Input:

;;     o Encoder number in WREG and MIOS_PARAMETER1

;;     o signed incrementer value in MIOS_PARAMETER2:

;;       - is positive when encoder has been turned clockwise

;;       - is negative when encoder has been turned counter clockwise

;; --------------------------------------------------------------------------

USER_ENC_NotifyChange

        movf    MIOS_PARAMETER1, W

        xorlw   1

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   2

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   3

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   8

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   9

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   10

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   11

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer


        movf    MIOS_PARAMETER1, W

        xorlw   12

        skpnz

        comf    MIOS_PARAMETER2, F  ; inverse incrementer

...

Best Regards, .
thx Thorsten thats work but wiht this code the increment not work on osc env section (for a d s r) he work fine on sub menu (fin por phs pw k#2 k#3 k#5 k#5) and i have the same bug like sidmonster if turn the encoder slowly it not increment or decrement if turn normally or quickly thats work fine best regards my code :
;; --------------------------------------------------------------------------

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

;;  Input:

;;     o Encoder number in WREG and MIOS_PARAMETER1

;;     o signed incrementer value in MIOS_PARAMETER2:

;;       - is positive when encoder has been turned clockwise

;;       - is negative when encoder has been turned counter clockwise

;; --------------------------------------------------------------------------

USER_ENC_NotifyChange


movf    MIOS_PARAMETER1, W 

xorlw   2        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   3        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   13        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   14        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre



movf    MIOS_PARAMETER1, W 

xorlw   8        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   9        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   10        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre


movf    MIOS_PARAMETER1, W 

xorlw   1        

skpnz       

comf    MIOS_PARAMETER2, F  ; inverse incre

	movf	SID_MIDI_DEVICE, W	; exit if device ID != 0x00

	skpz

	return


	;; store encoder number in CS_MENU_USED_ENCODER - will be used by CS_MENU_ENC_CSInc later to set a new speed!

	movff	MIOS_PARAMETER1, CS_MENU_USED_ENCODER

; comf    MIOS_PARAMETER2, F  ; inverse incrementer                                                                      

#if CS_MENU_USE_INCDEC_BUTTONS == 0

	;; if encoder #0 has been moved, jump to Control Surface Menu Encoder Handler

	movlw	0x00		; encoder #0

	cpfseq	MIOS_PARAMETER1, ACCESS

	rgoto USER_ENC_Handler_NoMenu


	;; get incrementer and jump to control surface menu encoder handler

	movf	MIOS_PARAMETER2, W

	goto	CS_MENU_ENC_Handler


USER_ENC_Handler_NoMenu

	decf	MIOS_PARAMETER1, F; decrement encoder number (the CS encoders begin at 0)

#endif

	;; jump to CS handler

	goto	CS_MENU_ENC_CS_Handler

Edited by yodabe
Posted

and i have the same bug like sidmonster

if turn the encoder slowly it not increment or decrement if turn normally or quickly thats work fine

This is not a bug, but just an indication that this issue can't be solved via software.

Please remove the changes and fix your hardware as well - it's simple!

Best Regards, Thorsten.

Posted

Please remove the changes and fix your hardware as well - it's simple!

Best Regards, Thorsten.

yep i processing a new pcb board

thx for your help Tk

best regards

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