Encoder ky-040 and DAW, issue with values.

Hi everyone, thanks for sharing your knowledge with others.

I must say that was study a lot C++ and try and modificate many codes while many days, but i cant resolve it.

My question; I building a surface control midi,i was can working buttons and pots,but the encoders working with errors (ky-040),at rotate the encoder jump the values (0 to 60 to 90 to 127 for example, or others random values ) in the Daw (Reaper).

Reaper haves 4 modes to manage encoder/potentiometers; absolute, relative1, relative 2 and relative 3. In absolute mode (to potentiometers) encoder working fine but rotary encoders must works in relative modes.

This its a bounce´s issue? i guess the code its using “software debounce” or I must build a “hardware debounce” (with resistors and capacitors)?

I hope you can help me with that,its the only issue i must resolve it and finish my proyect.

Components & details.:

1-Arduino Mega 2560.
2-Encoders model ky-040.
3-Reaper DAW.
4-Windows 7/10 x64(in both same errors).
5-Loopmidi and Hairless.

I add the .zip code, thanks a lot everyone.

code.zip (6.89 KB)

First, read the posts at the top of this Forum, especially the one that tells you how to post code here.
Second, we need to see the entire program posted using proper code tags. The code you posted is not going to work in the Arduino IDE.
Third, read up on “input debounce for Arduino” and then try to apply what you learned there to you problem.

econjack: First, read the posts at the top of this Forum, especially the one that tells you how to post code here. Second, we need to see the entire program posted using proper code tags. The code you posted is not going to work in the Arduino IDE. Third, read up on "input debounce for Arduino" and then try to apply what you learned there to you problem.

Thanks, i fixed it the post, the filecode has 7 pages/files, so

I highly doubt it's a bounce problem, it sounds like you're just sending the wrong data. If you select a relative mode in Reaper, you have to send relative messages from the Arduino as well.

I'm not going to open that ZIP, but the Control Surface library supports all relative modes in Reaper: RotaryEncoder.ino

You can check the documentation and the source code for more information about the format of the messages.

RelativeCCMode documentation RelativeCCSender source

Pieter

PieterP:
I highly doubt it’s a bounce problem, it sounds like you’re just sending the wrong data. If you select a relative mode in Reaper, you have to send relative messages from the Arduino as well.

I’m not going to open that ZIP, but the Control Surface library supports all relative modes in Reaper:
RotaryEncoder.ino

You can check the documentation and the source code for more information about the format of the messages.

RelativeCCMode documentation
RelativeCCSender source

Pieter

Thanks.

The code "rotary encoder.ino" was of the firsts codes that i used, and get the error in Hairless " +6.543 - Error: got unexpected data byte 0x....etc"

Now i try again and get same error.

snikt: The code "rotary encoder.ino" was of the firsts codes that i used, and get the error in Hairless " +6.543 - Error: got unexpected data byte 0x....etc"

Now i try again and get same error.

If you want to use Hairless, you have to use the HairlessMIDI_Interface instead of the USBMIDI_Interface.

Please read this section of the "getting started" guide: https://tttapa.github.io/Control-Surface-doc/Doxygen/d5/d7d/md_pages_Getting-Started.html#first-output-midi-interface

I love you man, thanks so much, i have 8 encoders working fine in reaper........but, i guess MCU protocol that use the library, just it has 8 vpots, and i need add more encoders, (for example V_POT_9 command not working) how can i do it?

snikt: I love you man, thanks so much, i have 8 encoders working fine in reaper........but, i guess MCU protocol that use the library, just it has 8 vpots, and i need add more encoders, (for example V_POT_9 command not working) how can i do it?

You don't have to use the MCU protocol, you can map the encoders to any MIDI Control Change number, simply replace MCU::V_POT_n by a number from 0 to 119. You'll have to map this control in Reaper manually.

The encoder 9 work with issues of values (like bounced).

The code that i used:

CCRotaryEncoder enc9 = { {19, 20}, // pins 24, 1, // MIDI address (CC number + optional channel) 1, // optional multiplier if the control isn't fast enough };

Please see the CCRotaryEncoder documentation The "1" in your code is not the channel. By providing this many arguments, you set the number of pulses per step to 1 instead of 4, which is the default for a standard encoder.

This could also be useful: MIDI Addresses

PieterP: ... simply replace MCU::V_POT_n by a number from 0 to 119.

I replaced:

CCRotaryEncoder enc9 = { {19, 20}, // pins 24, // MIDI address (CC number + optional channel) 1, // optional multiplier if the control isn't fast enough };

But not sending signal, (24,1, sending signal with errors).

PD: I read the links.

snikt: But not sending signal, (24,1, sending signal with errors).

What does it send? What do you expect to be sent instead?

PieterP: What does it send? What do you expect to be sent instead?

Sending "CC24 Channel 1" in Hairless, but in Reaper fader values step up and down.

snikt: Sending "CC24 Channel 1" in Hairless, but in Reaper fader values step up and down.

Please be more precise, what values does it send (check this in Hairless), and describe the behavior in Reaper in more detail. What relative mode do you have selected in Reaper? And in your Arduino code?

When i use "24,1, " in second line (CCnumber+Channel)in Hairles shows:

+10.661- Serial In: Ch 1 Controller 24 value 1 +10.731- Serial In: Ch 1 Controller 24 value 127

Both messages at same time.

In reaper Relative 1 (i try 3 relative´s modes) in arduino Relative_1.

To be sure we're on the same page: the "1" is the speed multiplier, not the channel.

If it sends these two messages at exactly the same time, it could be a hardware/wiring issue.

Please try this example te make sure your hardware is correct: https://github.com/PaulStoffregen/Encoder/blob/master/examples/Basic/Basic.pde

PieterP: To be sure we're on the same page: the "1" is the speed multiplier, not the channel.

If it sends these two messages at exactly the same time, it could be a hardware/wiring issue.

Please try this example te make sure your hardware is correct: https://github.com/PaulStoffregen/Encoder/blob/master/examples/Basic/Basic.pde

I changed wired pins 19,20 for 34,35 (or other) and delete "1" just 24, and now work perfectly.

Was "pin´s problem,i dont know why, but solutioned issue my friend, thanks for your patience.

Glad to hear you got it working!

Pins 19 and 20 seem to be interrupt pins on the Mega. I'd expect it to work better with interrupt pins, but apparently that's not the case.

Hi, now I try to make the encoders work in Pro Tools, I can modify the CC # messages and send them and have Pro Tools read them, but the values ​​jump from the minimum to the maximum of the fader volume (0 to 127). How can I make the fader to move gradually and incrementally?

I am using Mackie Control Relative on arduino, cheers and thanks.