• Modifying the pedal inputs and rotary encoder

    Bjørn Brandal08/21/2020 at 10:22 1 comment

    While working on the firmware implementation I found a few small things that had to be modified.

    Rotary encoder

    The rotary encoder on the KORE unit has its common connection to 5V, while the Arduino libraries I found expect the rotary encoder common input to be connected to ground. Also as the itsybitsy board will be handling any menu system and configuration I wanted the rotary encoder to be connected directly to the itsybitsy board. As such rotary encoders are also fairly noisy, I wanted to add some hardware filtering.

    I cut the three pins and bent them out so there were no connections to the PCB except for the side-pins holding the rotary encoder in place. I connected a screened cable cut from an USB cable and connected the other end to the USB connection prototyping PCB.

    On this prototyping PCB I connected the common pin of the rotary encoder to ground and added simple RC filters to the rotary encoder A and B outputs for hardware de bouncing.

    The internal pull-ups on the nRF52840 are in the 10-13K range, so it is important that the filter resistors are small enough to pull the input voltage close enough to ground, as they will act as a voltage divider together with the internal pull-ups. I used 1K resistors with 10n capacitors. This gives a good result and pulls the input voltage down to around 7-9% of VCC. From this filter I connected a cable to the itsybitsy pins 12 and 13.

    Pedal Inputs

    For the expression pedal inputs the Zener diode circuit limits the maximum voltage, and although I could scale and compensate for this in the ADC measurements, there is not really any need for this zener circuitry as expression pedals are passive and consist of a simple potentiometer. I also wanted to implement code to detect whether or not a pedal is connected, and to check if the ring connection is shorted to ground before outputting VCC to drive the pedal. Such short-circuit would happen if a mono-plug or a foot switch is connected instead of an expression pedal, and also for a short period when hot-plufgging an expression pedal.

    To be able to detect this I needed to have both the ring and the tip connected to an ADC input. I therefore changed the connections to have the pedals connected to A0-A3, and the foot switches to be connected to the digital inputs.

    I also connected pin 4 of the jack plugs to ground so that when there is no plug inserted the tip connection is grounded. 

    The following schematics shows how the pedal detection and enabling works. 

    With no pedal connected the internal pull-up pulls A0 to VCC, and A2 is connected to ground through the internal switch in the pedal input jack. With a pedal connected, the expression pedal pot and the internal pull-up forms a voltage divider. The level on A2 is dependent upon the pedal position.

    The firmware first checks if the voltage of the ring connection (A0) is at max level. If so, there is no pedal connected. Otherwise if the voltage is lower than max, there is something connected, and the firmware checks if the voltage level is (close to) ground. If so there is a short and an error status is indicated. Otherwise if A0 is not shorted to ground, and not pulled up to VCC there is a pedal connected. A0 is changed to output driving VCC to the pedal potentiometer, and the pedal position is read from the voltage on A2.

    The picture below shows pedal 1 not connected and pedal 2 at around mid position (85 of 127). It also shows footswitch 1 activated. Second picture shows the error message when any of the pedal ring-connections are shorted to ground.

  • Finishing up with 3D printed covers

    Bjørn Brandal08/09/2020 at 13:41 0 comments

    As the MIDI plugs have been removed to make space for the Itsybitsy to protrude through the encapsulation I designed some plastic covers using Autodesk Fusion 360.

    I had never used fusion 360 before but it was very easy to get started and get the designs done. Especially as both Autodesk and other users provide a lot of great tutorials on Youtube.

    I designed one big cover for both MIDI holes, but as I am thinking of maybe adding a MIDI-IN function later I also designed a circular snap-in cover as an alternative so I can choose to plug either just one or both of the MIDI inputs. I have added the Fusion 360 design files and the 3D files (STEP and STL) in the files section.

    I do not own any 3D printer, but I am lucky enough to live in Hong Kong where access to third party manufacturing services are abundant. So I ordered these parts from http://www.hk3dprint.com.hk who have a simple online quotation and ordering system, speedy processing and very affordable pricing.

    The covers came out looking great. The snaps for the round covers were a little tight, and same for the mounting holes on the square cover. But this has been fixed in the latest 3D files. If you print any of these please let me know in the comments if there are still tolerance adjustments needed.

    With this final little touch the hardware modification is now complete, and only completing the firmware remains.

  • Adding OLED display

    Bjørn Brandal08/03/2020 at 08:46 0 comments

    The final part of the electronics modification was to add a new display. The old display did not only have a very low contrast and some “striping”, but also had an unknown display driver and I couldn't be bothered to try to reverse engineer the communication to guess which controller is being used. 

    After searching for a long time I found the perfect replacement display, the REX012864GW OLED Chip on glass module. As this OLED module required 12V-13V and also had a 0.5mm pitch cable I made a breakout board, see here for details:https://hackaday.io/project/173753-oled-breakout-board-with-dc-dc-step-up .

    I removed the old display and backlight module from the clear plastic display holder and attached the new OLED module using double sided tape.

    The OLED breakout PCB fits perfectly within the limited space available and is connected to the Itsybitsy board as follows: 


    OLED breakout

    Itsybitsy nRF52840 pin

    1 (RES#)


    2 (+5V)


    3 (D/C#)


    4 (+3V3)


    5 (CLK)


    6 (CS#)


    7 (MOSI)


    8 (GND)


    I added some double sided tape on the backside of the breakout board and placed it inside the unit.

    The cable chaos is complete...but working :)

    I wrote some simple code that output the knob values on the display. For the final firmware I will use a scalable font and make sure there is some clearance between the text and the edges of the display window. But for now this works.

  • Putting it all together

    Bjørn Brandal07/10/2020 at 09:58 0 comments

    To fit the itsybitsy board through the MIDI connector hole I had to file some small ridges on each side, see picture below. With this done the itsybitsy fits snuggly to the platic frame.

    Due to the tight space inside the encapsulation, I used a drill and made an indent in the bottom cover to accommodate for the XTAL on the ATmega2560 board. With this indent in place I was able to get the bottom cover of the KORE correctly put back in place. 

    Pedal inputs

    Note: While working on the firmware I decided to modify the pedal connections. Check this post for the latest update: https://hackaday.io/project/171550-ble-midi-controller-conversion-of-ni-kore/log/182494-modifying-the-pedal-inputs-and-rotary-encoder

    For the pedal inputs I plan to keep it as for the original KORE, with two digital pedals and two expression pedal inputs. However to make sure I could later change this by just changing the firmware I wired all the pedal input jacks in the same way. To protect the itsybitsy from over voltage should someone plug in anything that provides more than 3,3V out I added input protection in the form of 3,3V zener diodes and 100 ohm series resistors.

    E.g. if someone attaches a 9V signal, the voltage across the resistor will be (9V-3.3V) 5,7V. This will give a current through the resistor of (5,7V/100ohm) 57mA and a dissipated power of (5,7V * 57mA) 0.325W. So a normal 1/2W resistor works fine.

    The picture below shows how these components could easily and neatly be added to the Jack plugs.

    The tip of the jacks will contain the analog signal from a plugged expression signal, so all the tips were connected to analog inputs A0-A3 on the itsybitsy. And the ring will either output 3.3V for expression pedals or read a digital input for foot switch, so they were connected to digital IO 11,10,9 and 7. The sleeve should be connected to ground.


    USB connection

    For the USB and power connection I took a piece of prototyping board and soldered the USB connector from the KORE controller to it, in such a way that it fit right back into the cut-out in the encapsulation. And then i cut a piece from a micro-USB cable, soldered it to the connector, and plugged the microUSB end into the Itsybitsy. Due to limited space I had to remove the insulation of the micro USB cable, bend it at a slight angle and put insulating tape around it.


  • Getting the Adafruit itsybitsy nRF52840 connected

    Bjørn Brandal06/02/2020 at 09:45 0 comments

    As mentioned earlier, the Adafruit board runs on 3.3V IO voltage, so a level converter is needed, and a bi-directional level shifter can easily be made with two mosfets and two resistors. However the Adafruit Bi-directional logic level converter board is the fast track to get this up and connected without any breadboarding. The Atmega2560 PRO is connected to the “Hv” side, and the Adafruit itsybitsy to the “Lv” side. Picture below shows where I placed the level converter and how it is hooked up to the mega2560 board. 

    Here is the connection diagram for the I2C wiring and level converter.

    Make sure the wires are long enough for the itsybitsy board to be mounted through the MIDI OUT hole in the encapsulation. And it should be mounted with its top-side up in the finished unit, i.e. bottom side up when seen from the bottom/wiring side.

    The USB pin of the itsybitsy is 5V out from the USB connection and can be used to power the entire 5V domain of the unit so everything can be powered from a single USB connection to the itsybitsy board.

    Connect a wire to the “USB” pin of the itsybitsy, and one to the big ground pad at the USB connector, and then connect these to GND and 5V on the main PCB.

    The following diagram (also available under files) shows the full power wiring. The big green background represents the KORE main PCB with the pots and switches.Although the "USB" pin (5V) on the itsybitsy is said to be an output only, I checked the schematics and it can also be used as an input to power the Itsybitsy board. this means whenever the ATmega2560 Arduino needs to be programmed, it should be OK to just leave that board connected to USB, and the Itsybitsy will then be powered from the Atmega2560 Arduino 5V output through its "USB" pin.

    To test that everything is correctly connected I programmed the itsybitsy board with the same I2C slave code as in previous log posting and checked that the data was correctly output on the serial monitor. And then I also tested by combining the Adafruit BLE Midi example with the I2C slave code, and voila, the KORE could now BOTH play the arpeggios from the BLE midi example file AND output to the serial port monitor the value of the pots and buttons.

  • Change in plans...

    Bjørn Brandal05/28/2020 at 03:15 0 comments

    After some more thinking, looking into physical space available, wondering about how to get the BLE signal to reach out of the metal enclosure etc I decided to do some changes to the system partitioning and components.

    Instead of the Feather nRF52840 Express I will instead use the Adafruit itsybitsy nrf52840 express. The itsybitsy version is much smaller, and I should be able to have the antenna portion poke out of one of the MIDI connector openings to ensure the BLE signal is not attenuated too much by the enclosure. 

    Further, although the nRF52840 Voltage range is up to 5.5V, I discovered that the IO is powered by the internal regulator with a programmable voltage from 1.8 - 3.3V, and the Adafruit itsybitsy nRF52840 Express actually uses an IO voltage of 3V. Because of this, and the fact all the buttons are active HIGH with a 5V output, I decided to wire ALL buttons to the ATmega2560 PRO arduino, and use the Adafruit board only for BLE, pedal inputs and a possible serial MIDI in case I decide to add that as well. I also have plans to add a serial Display, which would then be added to the Adafruit board as well.

    As the power is different between the two boards, a voltage level converter is needed for the I2C lines. It is very easy to make such with a few resistors and two MOSFETs, but for ease of implementation and lack of time I just ordered a ready made level converter from Adafruit.

    The new design partitioning now looks like this:

    And the updated Arduino 2560 connection diagram:

    I connected the remaining wiring (Navig switches, Function switches and Rotary Encoder) to the mega 2560 board.

    I also added I2C code and to test it I added a second (normal) ATmega2560 Arduino, actually a clone called Funduino, running a simple I2C slave to serial implementation, based on Nicholas Zambetti’s example code for the wire library:

    #include <Wire.h>
    void setup() {
      Wire.begin(8);                // join i2c bus with address #8
      Wire.onReceive(receiveEvent); // register event
      Serial.begin(115200);         // start serial for output
      Serial.print("I2C slave");    // print the character
    void loop() {
    // function that executes whenever data is received from master
    // this function is registered as an event, see setup()
    void receiveEvent(int howMany) {
      while (1 < Wire.available()) { // loop through all but the last
        int c = Wire.read();    // receive byte as a integer
        Serial.print(c);        // print the integer
        Serial.print(",");      // print spacing comma
      int x = Wire.read();      // receive byte as an integer
      Serial.println(x);        // print the integer

    This is the debug output from the second Arduino showing the data received over I2C with every other knob/button turned to max/on.

    So far so good.. Now I just have to wait for Digikey to deliver my new Adafruit itsybitsy board...

  • Getting the Mega 2650 Pro Embed Arduino hooked up, spaghetti-style

    Bjørn Brandal05/25/2020 at 07:46 0 comments

    With all the buttons, pots and LEDs wired it was time to connect it all to the  Mega 2650 Pro EmbedArduino board. 

    As earlier mentioned I plan to use two Arduinos, one ATmega2560 based and one Adafruit feather nRF52840 Express. I made the following sketch to show how the different parts will be partitioned between the two arduinos.

    UPDATE: I later found that a different partitioning was better where the ATmega2560 reads all buttons and knobs except the rotary encoder. See later update.

    The following diagram (also available under files section) shows where the different buttons and pots should be connected to the Mega 2650 Pro Embed Arduino.

    With so many pots and buttons connected with cables, the connections are deemed to get a bit messy. Also the space in the KORE encapsulation is really tight, and the only viable place I found for the Arduino is on the backside, opposite side of the PCB as compared to the LCD display. It is actually a bit too tight, and with the backside cover in place the Arduino will be forcefully pressed against the PCB.

    Notice that my original wiring with wires crossing over the PCB edge at the bottom had to be re-done as there is not room inside the encapsulation to have any wires going over the bottom edge. Luckily there is a hole in the PCB which can be used to pull wiring through. 

    This is how the new wiring looks from the top side:

    I also added power and I2C wiring, and soldered wires to the Rotary encoder.

    To be able to reassemble the plastic frame on top of the PCB some openings must be cut to accommodate the wiring.

    Several openings had to be made and will depend a bit on your actual wiring. So make sure that as you attach the wiring you also check with the plastic frame to make sure there are as few conflicts as possible, and then make cut-outs as needed.

    As already mentioned the space inside the encapsulation is very tight, and the Arduino will be pressed hard down towards the PCB. So you have to make sure that anything soldered to the Arduino does not stick out on the back side to keep profile as low as possible, and also avoid anything digging through the insulation tape and shorting to the pot/button PCB.

    Current plan is to just screw the back cover on as it is. But I might potentially have to bend it a bit to make some more room for the Arduino. Or possibly 3D print some plastic to fill the gap.

  • Wiring up the LEDs

    Bjørn Brandal05/22/2020 at 17:12 0 comments

    The KORE controller have LEDs for all potmeters, buttons and the rotary encoder. In previous log I showed how to connect the transistor controlling the LEDs for the rotary encoder to keep them constantly on. These are the only LEDs controlled as a group by a transistor. All other LEDs have individual control lines.

    The ATmega2560 has enough IO driving strength to directly control the LEDs. It can sink currents up to 10-20mA pr pin and 100-200mA pr port (varies from port to port and VCC voltage). So LEDs can either be wired to be constantly on or controlled directly by IO pins on the ATmega2560 as you see fit. I decided to only control the LEDs for the 8 buttons by the potentiometers, and the 4 playback control buttons (Stop, Play, Record and Speaker symbol) from the ATmega2560. All the other LEDs I wired to be constantly on.

    The board was originally designed for 3.3V operation, so the existing series resistors for the LEDs would be a bit too weak for 5V. They can just be left in place, and I added instead new 2K2 ohm series resistors to ground to power the LEDs from 5V. This gives a good brightness at a moderate ~3mA pr LED.

    The LEDs are active low, so for the ones that should be wired to constant on, connect the 2K2 ohm resistor to the LED, and the other end of the resistor to GND. To find out which terminal of the LED to connect to, you can make a probe with a cable connected to ground attached to a 2K2 ohm resistor, and use the other pin of the resistor to check which LED pin makes the LED light up.

    This picture show the wiring for the 8 LEDs for the buttons by the potentiometers. The resistors should be connected to the top pin of the LEDs

    Wiring for the playback control button LEDs to be connected to the Arduino (the 4 resistors at the bottom), and the LEDS for the control and navigation buttons connected via the resistors directly to GND to stay constant on. The black insulation tape is the area where the mega2560 Arduino will be placed.

    Next step: get it all connected to the Arduino board.

  • Wiring up the KORE PCB potentiometers and buttons

    Bjørn Brandal05/22/2020 at 09:02 0 comments

    UpdateMay 25th: NOTICE: In the pictures of the wiring shown below the wires goes across the PCB both on the upper and lower edge. I later discovered that there was no room in the housing to allow wires to run over the lower edge, so I had to redo some of the wiring. This will be shown in the next update. I didn't update the pictures in this posting, partly as the Hackaday editor is VERY unstable when it comes to replacing/editing the pictures, partly because I think it is nice the logs correctly reflect the actual  process ;)

    Dismantling the KORE controller was pretty straight forward. Just notice that the red transparent round covers on the potentiometers and rotary encoder are actually threaded on the shafts. So these must be unscrewn to loosen the PCB from the plastic frame.

    As there are 8 of the 360 degree eternal rotation potentiometers, each having two outputs, I needed an Arduino board with 16 analog inputs. And the ATmega2560 PRO with onboard CH340G USB to UART bridge is perfect. The ATmega2560 also have enough driving strength on the IO (typ 20mA sink current pr IO / 200mA pr port) to directly drive the onboard LEDs.

    First you have to desolder all the ICs on the PCB. This can be done by applying generous amount of fresh solder over the pins on one side, and make sure to heat all the pins while carefully lifting that side of the IC up from the PCB using a pair of thins tweezers. Secondly do the same for the other side. This will leave a lot of solder residue on the PCB.

    Finish off by removing all the residue solder with a solder wick.

    Make sure all the ICs are removed. Also cut the wires for the LCD backlight.
    Use a pair of sharp wire cutters and cut pin 1 and 3 of each of the potentiometers, and bend the pins outwards, and solder wires to the pins, long enough to reach around to the back-side where the Arduino will be mounted.
    Next, solder wires to the 8 buttons. These buttons are active high, and pulled low by resistors when not activated. Picture below shows which button pin to attach the wire to. If you are unsure, use a multimeter and check with pin goes high when button is pushed

    NOTE: As mentioned in the update, this picture shows wires going across both top and bottom of the PCB, but due to space constraints, all wires need to go on top of the PCB. See pictures in later updates.

    Next solder wires to the other buttons on the PCB

    The board originally ruins off 3.3V, but with all the ICs removed it can be powered by 5V, which is desired as this is the IO voltage required by the ATmega2560 Arduino PRO board. The power connection is pins 1 (GND) and 9 + 10 (VCC) on the flat cable connected to the PCB.

    If you power it up you will see the LEDs around the rotary encoder might light up and fade away. This is due to a floating pin on the transistor controlling the LEDs. So Solder a wire between VCC and the top pin of R96. This will ensure the transistor is on and therefore also the LEDs are on. This gives a nice light-effect around the rotary encoder knob.

  • Getting BLE MIDI running

    Bjørn Brandal05/21/2020 at 09:43 0 comments

    So I realized so many of my other hobby projects usually start by massive excitement, then buying everything I need, or think I might need, only to fizzle out by not getting around to get the base and fundamental implementation running. So this time I decided to start from the right end, getting fundamental functionality running FIRST.

    So... time to get a running BLE MIDI prototype up.

    This is all based on Adafruits' excellent Arduino Core for Adafruit Bluefruit nRF52 Boards. I already had an nRF52840-DK around, so following the instructions from Adafruit I quickly got the dev kit running with Arduino.

    Notice that the nRF52840 has on-chip USB in addition to the Jlink programmer USB on the developmment kit. So make sure you are connected to the J-link USB for programming the arduino bootloader, and then change to the "Arduino USB" for the actual Arduino functionality

    Install MIDI library

    In Arduino, go to Sketch>include library>Library Manager

    Chose communication category and search for "MIDI"

    Install "MIDI library by Francois Best, lathoub". NOTE: make sure you select and install version 4.3.1. Version 5 and above currently doesnt work ith the Adafruit BLE Midi example, but gives compile error MIDI.hpp:457:20: error: 'class BLEMidi' has no member named 'beginTransmission'

    Open midi BLE example from Examples>Adafruit Bluefruit nRF52 Libraries>Peripheral>blemidi

    Open the serial monitor and the application will start to run. When code is running you will see LED blink when advertising. And in the serial monitor will show ‘Adafruit Bluefruit52 MIDI over Bluetooth LE Example’

    Testing connection (Android)

    Install "MIDI BLE Connect" on your Android device. This app is used to route BLE MIDI messages to MIDI capable apps.

    Open MIDI BLE Connect and click on the Bluetooth scan button.

    Choose "Bluefruit52 MIDI", and as  soon as connected you should see the blinking LED on nRF52840-DK changing to steady on.

    Download a MIDI keyboard/synth, for example this:

    When opened, click on the MIDI input/output icons and choose "Bluefruit52 MIDI" as the interface

    You should now hear the arpeggio play, and also see the midi data from any keys you play in the serial monitor in Arduino.

    Getting this up and running so quickly (again BIG thanks to the excellent folks at Adafruit) really fueld my enthusiasm and motivation, and I got cranking on wiring up the KORE controller with Arduino.