Embedded Keyboard Project, Part 4

Hello, this is just another update on our keyboard project. I feel we got a *LOT* done since the last time I posted. The project is now going very smoothly, and we feel we are meeting our schedule very well. I feel like we are around 80% done. Anyway, I wanted to share with you the following recording:

Okay, I guess that’s not my best recording yet, but after a few frustrating days of trying to get our ATSAM2195 Atmel synthesizer chip to work, we finally were able to produce sound output. This note was our first recording of the sound output off the chip.

Our final project circuitry actually fits on only one breadboard. We have a pic microcontroller, which has the task of reading all the key states, and generating NOTE ON and NOTE OFF commands to the synthesizer chip whenever a key changes value. The commands are then converted to MIDI messages, and sent to the ATSAM2195 synth chip.

Final project layout

In the image above, you can see our entire final project, minus the Arduino and LCD display, and minus the audio amplifier my lab partner built for this occasion. We decided to switch to parallel mode communication with the synthesizer chip, simply because we felt it was a bit easier to get going. Anyway, here is a quick and dirty c file we wrote for the PIC18LF4525, with which we were able to communicate with the synth chip:


Next we need to integrate all the code for the keyboard controller, so actual key events on the keyboard trigger MIDI commands.

What I spent most of my time on lately was creating drivers for the Crystalfontz CFA533-YYH-KL LCD screen, which is a 2-row 16-character LCD display with 6 navigation buttons. We’re having an Ardueno Duemilanove control the LCD through a RS-232 connection. The navigation menu allows configuration of various things such as instrument, master volume levels, reverb, and chorus. We uploaded a list of the 128 different instrument sounds incorporated on the synthesizer chip.

We also incorporated commands to save current settings into the Arduino’s EEPROM, and restore to default settings. The settings are coordinated with the keyboard controller via I²C connection.

Testbench for LCD display controller

The I²C communication ended up not being straight forward, since I had trouble getting the Wire.h Arduino library to trigger interrupts in the PIC controller when the Arduino is asking for a byte of data. I ended up writing my own Master I²C drivers, which pretty much bit-bang the SCL and SDA signals. Using my library, I was able to get the Arduino talking quite nicely with the PIC controller.

Our current code files for the LCD display and menu drivers are as follows:

  • arduino_module.pde – Arduino project main file
  • common.h – Shared constants between keyboard controller and LCD driver
  • eeprom_driver.cpp
  • eeprom_driver.h
  • i2c_driver.cpp
  • i2c_driver.h
  • lcd_driver.cpp
  • lcd_driver.h
  • menu_items.h – List of items in the LCD menu

Download: arduino.zip

As of now, the LCD driver is mostly complete, besides some later proof-reading. Also, I can think of a few more features I would like to incorporate if I find the time such as transposition, and I want to change some things about how the menu is displayed.

Anyway, next time I post, the project might be completely done, perhaps just over the 3-day weekend. I have just one more week to work on this project, during which time I’ll be finishing the final project, preparing a 20-minute presentation on the project, writing one of Dr. Peckol’s typically long lab reports, and conducting a demo of our design.

8 Replies to “Embedded Keyboard Project, Part 4”

  1. Hi Jon, nice work, you are the first to post something on this wonderful midi synth chip. I found your post just in time. I've just finished assembling the ATSAM2195-EK circuit and it does not work. I'm sending midi messages from my Boarduino to the ATSAM2195 but I have no audio. Can you tell me what happened when you were sending midi direct to the chip? I understand that you had to leave that and send midi on parralel input. Thanks.

  2. Hello, Miroslaw,

    I also followed the ATSAM2195-EK schematic. I have been using the Parallel mode for the synth chip, but because you asked, I just tried using Serial mode, and I was able to get it working. Are you sure you're sending data 31250 baud, no parity? Also, you need to realize that the output signal will be really small, so you might actually be getting sound, but not realize it.

  3. Hello, thank you for answering. I'm sending midi at 31250 without parity, also there's no audio out even on my oscilloscope. Are you sending midi at full 5V or 3.3V? Also I see that you did not use those tantalum capacitors and those fancy EMI filters, besides that did you follow the schematics to the letter? Thanks, Miroslaw.

  4. Hello, Miroslaw,

    If you're sending serial MIDI in at 5V, you're probably damaging the chip, since it isn't 5V tolerant. If you check out page 8 of the datasheet, the absolute maximum voltage for any input pin is 3.3+0.3V. I am running the chip in 3.3V supply mode.

    I didn't realize it was asking for a specific type of capacitor. I also didn't use inductors (or ferrite beads), and I made digital and analog ground the same.

    If you can, I would recommend setting up a test circuit in parallel mode, because that way, it would be easier to tell if the microprocessor inside the chip is even running. If you send the chip the Parallel initialization command, it should then output high on the IRQ pin, and you should then be able to read 0xFE on the data bus from the chip.

  5. Great news, I got it to work in serial midi in, the parallel is more complicated. I asked Atmel about the 5v input and they said that this chip accepts it cause there's a 220ohm resistor to protect the chip. This is an excellent new chip for all intermediate electronic fans. I think that you'll have no problem if I send a link to your site in the Arduino forum/site? If only you could explain the parallel input some more (so some college level guys/gals can understand)? That will help the whole internet community. Thanks again.

  6. Congrats! Have fun with the chip. I didn't realize it had circuit protection in it. I was being meticulously careful in how I handled the chip, and I was even nervous to touch the pad connections for fear of frying the chip with static charge.

    I'm planning to post this myself on the Arduino forum some time next week. I should maybe post that on Wednesday next week, after I write my report. We could have easily made this entire project with just one Arduino Duemilinove, since there should be more than enough pins if I switch to serial mode; that would also make it more accessible to the online community.

  7. The protection resistor is in your circuit, it's the R6 resistor between the J1B and pin 10, so keep your static to yourself, hehe.
    Looking forward for your report on the Arduino forum. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.