Converting a Yamaha keyboard assembly with a Teensy to a MIDI controller

Status
Not open for further replies.
There is this spec, which does in fact look like the one you need!! note the baud rate 2400 ... must be simple signalling ... its one wire plus power which looks like your scheme .... so I think maybe you are right ... the micro controllers are masters pushing data... although when you look at the spec its open to guesses as to how its setup on the keyboard ... there is no clock line pulled high or low like with i2c ... I wonder .... does anding the clk and data effectively remove the clock .... ebus looks not too different from a simple uart with a bit of fancy signalling like a basic stack .... don't quite get how it handles collisions though ... anyway
 
There is this spec, which does in fact look like the one you need!! note the baud rate 2400 ... must be simple signalling ... its one wire plus power which looks like your scheme .... so I think maybe you are right ... the micro controllers are masters pushing data... although when you look at the spec its open to guesses as to how its setup on the keyboard ... there is no clock line pulled high or low like with i2c ... I wonder .... does anding the clk and data effectively remove the clock .... ebus looks not too different from a simple uart with a bit of fancy signalling like a basic stack .... don't quite get how it handles collisions though ... anyway

Thank you for your information. I think Yamaha named it as EBUS, however it is still a I2C bus or maybe a hybrid. I look at the schematic again. The two signal SDA and SCL come out from the keyboard which are connected to the chip PCA9564. This chip is Parallel bus to I2C-bus controller. And I look at the controller chip on the keyboard (PD780031AYGK), the datasheet shows it is compatible with I2C bus. This IC provides the conversion from 8 bit parallel to I2C bus. It looks like the main CPU communicates with the keyboard by using this chip. I am confusing now. I am not sure the bus is EBUS, I2C, or a hybrid one. Here is the picture of the chip:
PCI bus controller.jpg
 
Last edited:
Thank you for your information. I think Yamaha named it as EBUS, however it is still a I2C bus or maybe a hybrid. I look at the schematic again. The two signal SDA and SCL come out from the keyboard which are connected to the chip PCA9564. This chip is Parallel bus to I2C-bus controller. And I look at the controller chip on the keyboard (PD780031AYGK), the datasheet shows it is compatible with I2C bus. This IC provides the conversion from 8 bit parallel to I2C bus. It looks like the main CPU communicates with the keyboard by using this chip. I am confuse now. I am not sure the bus is EBUS, I2C, or a hybrid one. Here is the picture of the chip:
View attachment 7835

I am confused about the bus too ....the joys of reverse engineering ... I guess that it is serial!!! but even then I'm not sure! good luck!
 
I am confused about the bus too ....the joys of reverse engineering ... I guess that it is serial!!! but even then I'm not sure! good luck!

Well, I read the document you sent. The physical layer of eBUS shows the voltages are not compatible with what the piano uses. First of all, the eBUS serves mutual communications between heating components. Secondly, the logical high asks for >15VDC and logical low is >=8VDC. By this I can draw the conclusion this piano keyboard is not using eBUS but it is I2C or a hybrid (Yamaha's way). However it is compatible with I2C bus, I will sniff the data on it to see what going on...
 
Last edited:
Yes, I didn't read it thoroughly enough

No problems. By the way, maybe Yamaha used this signal EBUS-DATA (output of the AND gate) to trigger the CPU (like an interrupt) or this is compatible with an asynchronous protocol like RS-232.
If Yamaha called this is EBUS for their own purpose, then I would say the physical layer of this bus is I2C and the higher layer will work as an EBUS. This way, the AND gate will get the result data and will be equivalent to the RS-232 data. This is what I am guessing.

Here is what I intend to do. I don't need a Bus Pirate, just a Teensy will do the job.
- Connect Teensy I2C signal lines to the keyboard, load up a program to find out any slave address on the bus.
- If there is none, the controllers on the keyboard can be masters.
- Write a program to loop through from 0-127 as the address of the slave to listen for the masters (controllers on the keyboard), while at the same time the program runs, press the keyboard many times to see any traffic on the bus. The program will change the its slave address every half second until it goes through the counting from 0-127. This way we know for sure the keyboard sends out any data on the bus.
I need your all inputs on this exercise.
 
Last edited:
No problems. By the way, maybe Yamaha used this signal EBUS-DATA (output of the AND gate) to trigger the CPU (like an interrupt) or this is compatible with an asynchronous protocol like RS-232.
If Yamaha called this is EBUS for their own purpose, then I would say the physical layer of this bus is I2C and the higher layer will work as an EBUS. This way, the AND gate will get the result data and will be equivalent to the RS-232 data. This is what I am guessing.

I think this is a pretty good guess

Here is what I intend to do. I don't need a Bus Pirate, just a Teensy will do the job.
- Connect Teensy I2C signal lines to the keyboard, load up a program to find out any slave address on the bus.
- If there is none, the controllers on the keyboard can be masters.
- Write a program to loop through from 0-127 as the address of the slave to listen for the masters (controllers on the keyboard), while at the same time the program runs, press the keyboard many times to see any traffic on the bus. The program will change the its slave address every half second until it goes through the counting from 0-127. This way we know for sure the keyboard sends out any data on the bus.
I need your all inputs on this exercise.

Sounds like a plan....!
 
Hello everyone,

I have good news. I use an Arduino Mega 2560, connect all pins to the Yamaha keyboard (+5V, GND, Reset, SDA, SCL) with pull up resistors. I downloaded the I2c scanner program on the web. Here is the results:

/**
* I2CScanner.ino -- I2C bus scanner for Arduino
*
* 2009,2014, Tod E. Kurt, http://todbot.com/blog/
*
*/

#include "Wire.h"
extern "C" {
#include "utility/twi.h" // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr,
void(*callback)(byte address, byte result) )
{
byte rc;
byte data = 0; // not used, just an address to feed to twi_writeTo()
for( byte addr = from_addr; addr <= to_addr; addr++ ) {
rc = twi_writeTo(addr, &data, 0, 1, 0);
callback( addr, rc );
}
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
Serial.print("addr: ");
Serial.print(addr,DEC);
Serial.print( (result==0) ? " found!":" ");
Serial.print( (addr%4) ? "\t":"\n");
}


byte start_address = 8; // lower addresses are reserved to prevent conflicts with other protocols
byte end_address = 119; // higher addresses unlock other modes, like 10-bit addressing

// standard Arduino setup()
void setup()
{
Wire.begin();

Serial.begin(115200); // Changed from 19200 to 115200 for speed
Serial.println("\nI2CScanner ready!");

Serial.print("starting scanning of I2C bus from ");
Serial.print(start_address,DEC);
Serial.print(" to ");
Serial.print(end_address,DEC);
Serial.println("...");

// start the scan, will call "scanFunc()" on result from each address
scanI2CBus( start_address, end_address, scanFunc );

Serial.println("\ndone");

// Set pin mode so the loop code works ( Not required for the functionality)
pinMode(13, OUTPUT);
}

// standard Arduino loop()
void loop()
{
// Nothing to do here, so we'll just blink the built-in LED
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13,LOW);
delay(1000);
}

The Serial monitor output:

I2CScanner ready!
starting scanning of I2C bus from 8 to 119...
addr: 8
addr: 9 addr: 10 addr: 11 addr: 12
addr: 13 addr: 14 addr: 15 addr: 16 found!
addr: 17 found! addr: 18 found! addr: 19 addr: 20
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 30 addr: 31 addr: 32
addr: 33 addr: 34 addr: 35 addr: 36
addr: 37 addr: 38 addr: 39 addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 50 addr: 51 addr: 52
addr: 53 addr: 54 addr: 55 addr: 56
addr: 57 addr: 58 addr: 59 addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68
addr: 69 addr: 70 addr: 71 addr: 72
addr: 73 addr: 74 addr: 75 addr: 76
addr: 77 addr: 78 addr: 79 addr: 80
addr: 81 addr: 82 addr: 83 addr: 84
addr: 85 addr: 86 addr: 87 addr: 88
addr: 89 addr: 90 addr: 91 addr: 92
addr: 93 addr: 94 addr: 95 addr: 96
addr: 97 addr: 98 addr: 99 addr: 100
addr: 101 addr: 102 addr: 103 addr: 104
addr: 105 addr: 106 addr: 107 addr: 108
addr: 109 addr: 110 addr: 111 addr: 112
addr: 113 addr: 114 addr: 115 addr: 116
addr: 117 addr: 118 addr: 119
done

The program found 3 MCU on the Yamaha keyboard at the addresses: 16, 17, and 18.

Can someone suggest what I should do next?

Thank you,
 
You should rejoice!! those must be the keyboard matrix mcus you identified earlier! I suppose you will be able to press a key and see what change in the i2c traffic occurs, maybe using an oscilliscope or some simple print to serial i2c program.... Hopefully an i2c expert will happen along .... but you are in the game!! i guess there must be an easy way to capture what byte etc is sent when you press a key ...
 
I tried to run an I2C sniffer program downloaded from the web. I pressed many keys many times but nothing happened. It looks like the 3 MCUs on the keyboard are slaves, not masters. I tried to write a program to read bytes from one of them with known addresses (16, 17, and 18) but returned 255, 255, 255...
I am stuck at this time...
 
I tried to run an I2C sniffer program downloaded from the web. I pressed many keys many times but nothing happened. It looks like the 3 MCUs on the keyboard are slaves, not masters. I tried to write a program to read bytes from one of them with known addresses (16, 17, and 18) but returned 255, 255, 255...
I am stuck at this time...

Maybe you need to consider pullup resistors on the i2c lines?? I think i2c on teensy requires that?
 
I had the pull-up resistors. Didn't you read the previous post I used an I2C scanner program and found the addresses of the MCUs on the keyboard? The addresses of the 3 MCUs are 16, 17, and 18. Without pull-up resistors, it does not work!
 
This keyboard was used in Yamaha cvp409 and other models. These pianos have a split function. It means when it is split, the keyboard becomes two 44-key keyboards. This helps a teacher and a student play together.

Now, I don't know this function is emulated in the keyboard by it self or in the main CPU. If it is in the keyboard then the main CPU has to send commands to this keyboard to turn it on and off. If that case. This is what I don't want to see. Unless I have a real Yamaha piano to sniff the traffic on the I2C bus to learn or I will not make this keyboard to work as a MIDI controller.

Can someone help me to find out the commands send to this keyboard?
 
Last edited:
Here is another output from another I2C scanner program:

Scanning:
.....................................................................................................................

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 03 04 05 06 07 -- -- -- -- -- -- -- --
01: 10 11 12 -- -- -- -- -- -- -- -- -- -- -- -- --
02: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
03: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
04: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
05: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
06: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
07: -- -- -- -- -- -- -- --

Pausing for 5.00 seconds

It found the I2C addresses: Hex: 10, 11, 12 as decimal: 16, 17, 18.
They are the same addresses as the previous scanner program.
 
Last edited:
Here is my own I2C monitor program. This sketch will monitor a LOW state on pin 30 and 31. During the sketch was running, I tried to pull both pin 30 & 31 to GND, the outputs showed exactly the program was working. Next, both SDA and SCL were pulling high with 2 resistors. During the program was running, I pressed continuously many keys on the keyboard. The outputs were still High. This means there were no activities or transmissions on the I2C bus (SCL will go low to start a transmission).

Because of this, I think the MCUs on the keyboard are slaves and are polled by the main CPU or the keyboard needs to be initialized first.

MY SIMPLE I2C MONITOR SKETCH:

int sSDA = 30; // set pin 30 for SDA
int sSCL = 31; // set pin 31 for SCL


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(sSDA, INPUT); // SDA
pinMode(sSCL, INPUT); // SCL
Serial.begin(115200);
}

// the loop function runs over and over again forever
void loop() {
if (digitalRead (sSDA) == LOW) {
Serial.print("SDA = Low ");
}
else {
Serial.print("SDA = High ");
}


if (digitalRead (sSCL) == LOW) {
Serial.print("SCL = Low ");
}
else {
Serial.print("SCL = High ");
}

Serial.println();
delay (1000);
}


Serial Output:

SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
SDA = High SCL = High
.....................
 
Last edited:
I think Yamaha CP4 Stage keyboard has the same keyboard assembly. If someone has it and wants to sniff the I2C traffic, please let me know.
Thank you,
 
I think Yamaha CP4 Stage keyboard has the same keyboard assembly. If someone has it and wants to sniff the I2C traffic, please let me know.
Thank you,

Old thread, but in case anyone's still reading. I was interested in the same thing, and used a logic analyzer with I2C analysis to figure it out.

It's 400 kHz I2C (I'm seeing 300-350 kHz)

The keybed is writing to device "0x10" with the key down/vel/key up information. The format is similar to MIDI:
keydown 20 9n kk vv
keyup 20 80 kk ff


- kk is the key, on the MOXF6 it's 0x24 .. 0x60, per the standard MIDI keymap.
- vv is the velocity.

Note pressure on these keyboards comes in from a resistive strip that needs to be fed into an ADC.
 
Old thread, but in case anyone's still reading. I was interested in the same thing, and used a logic analyzer with I2C analysis to figure it out.

It's 400 kHz I2C (I'm seeing 300-350 kHz)

The keybed is writing to device "0x10" with the key down/vel/key up information. The format is similar to MIDI:
keydown 20 9n kk vv
keyup 20 80 kk ff


- kk is the key, on the MOXF6 it's 0x24 .. 0x60, per the standard MIDI keymap.
- vv is the velocity.

Note pressure on these keyboards comes in from a resistive strip that needs to be fed into an ADC.

Did you happen to catch the initialization sequence? I have one with a dead main board and would like to just turn it into a dumb keyboard.
 
Did you happen to catch the initialization sequence? I have one with a dead main board and would like to just turn it into a dumb keyboard.

I did not, but I have since taken a different approach of simply reading all 176 switches directly from the keybed with timers and outputing USB. It's wired same as a push-button key matrix so no magical code here. This way I can produce much higher resolution velocities as well!

So wonderul Yamaha makes schematics so readily available.

Greg
 
Status
Not open for further replies.
Back
Top