But… I am TOTALLY out of my depth. I have searched around but cannot find any guide/example code anywhere and it is beyond my current skills to write it myself unfortunately.
Does anybody have any code or very basic steps on how to set this chain up that they would be willing to share with me please? This is my first big project I am attempting and I really would like to see it through. I am building a MIDI controller for students in a local school.
Any advice/assistance is gratefully received. Thank you in advance.
Lot’s of assumptions here. First it sounds like you are trying to wire six encoders with displays to a microcontroller. There aren’t enough pins on a small micro to do that. To read the encoders would be 12 input pins if you also want to read the switches that’s another 6 pins, plus the pins to make the serial interface to the encoder displays, plus another 18 pins to control the RGB LEDs on the encoders. If you can’t come up with enough pins you will need more shift registers to serialize the encoder inputs as well. The 595s will only act as outputs. You will need 74HC165s or something for inputs.
You are using a serial interface to effectively get more pins. That’s going to be a key part of your software. Lay out enough memory locations to represent all the individual data. Then use software routines to send and receive the “parallel” data in memory to/from the serial hardware.
The software flow would go something like this:
About once every 5 to 10 mS read the serial data into memory.
Process any state change based on the data in memory for the encoders you just read to translate them into
a new set of display state (write it out to the “parallel” memory)
a new set of midi state/messages/tasks (set flags or make a list)
Send the memory out serially to the encoder displays.
Perform the midi tasks, send messages or whatever.
Wait for the next time to read the encoders (wait for the end of the 5-10 mS).
Loop back to the top.
One thing you might want to do as you are learning is to do the above with a single encoder. This will simplify the wiring so that it’s not so much of a source of errors. Once you get one encoder working over the serial interface you can daisy-chain the others. The software flow doesn’t really change (timing limitations - caveat emptor) just the bit depth.