introduction and overviewmodernplayerpiano.com/modernplayerpiano_chapter1.pdfhouses the arduino mega...

8
1 CHAPTER 1 Introduction and Overview First Steps T his project all began because of my son Steve and his interest in antique doorbell chimes. You’re probably familiar with them, they play the “Westminster Chimes” notes on 4 tuned brass tubes about three feet long. Depending on the length of the tubes, they produce the notes F, A, G, C when they are tapped sharply at the top. Steve owned a unit possibly 100 years old that was beyond salvation. The oil in the motor had congealed, the insulation was falling from the wires and the contacts of the distributor had burned out due to numerous short circuits. After some debate, (Steve was not one to give up easily when it came to preserving the originality of a precious antique) we decided to replace the guts of the chimes: the motor, the control unit and the solenoids that propel the plunger onto the tube. We picked an Arduino “Uno” the smallest computer of the Arduino family as the electronic brain to replace the motor and the distributor. The Arduino family of computers is programmed using a derivative of the programming language called C. Simon Monk’s excellent book for beginners “Programming Arduino” is perfect for those who might like to get more familiar with this subject but—have no fear, it is not necessary to do any programming in order to complete this project. Steve who like me worked at IBM for many years was an expert in C and C++ and did all the work for us. A Thoroughly Modern Player Piano Charles A. Mathys PART 1

Upload: others

Post on 09-Aug-2020

92 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

11

CHAPTER 1

Introduction and Overview

First Steps

This project all began because of my son Steve and his interest inantique doorbell chimes. You’re probably familiar with them,

they play the “Westminster Chimes” notes on 4 tuned brass tubesabout three feet long. Depending on the length of the tubes, they produce the notes F, A, G, C when they are tapped sharply at the top.

Steve owned a unit possibly 100 years old that was beyond salvation.The oil in the motor had congealed, the insulation was falling fromthe wires and the contacts of the distributor had burned out due tonumerous short circuits. After some debate, (Steve was not one togive up easily when it came to preserving the originality of a preciousantique) we decided to replace the guts of the chimes: the motor, thecontrol unit and the solenoids that propel the plunger onto the tube.We picked an Arduino “Uno” the smallest computer of the Arduinofamily as the electronic brain to replace the motor and the distributor.

The Arduino family of computers is programmed using a derivativeof the programming language called C. Simon Monk’s excellentbook for beginners “Programming Arduino” is perfect for those whomight like to get more familiar with this subject but—have no fear,it is not necessary to do any programming in order to complete thisproject. Steve who like me worked at IBM for many years was anexpert in C and C++ and did all the work for us.

A Thoroughly Modern Player Piano Charles A. Mathys

PART 1

Page 2: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

The chime project was very successful and it still operates the chimesin his house to this day. This got me thinking that the keys of a pianocould also be depressed by using solenoids as mini-robots under thecontrol of a small computer. I was bored and between projects at thetime and started researching the idea a couple of years ago.

Player Pianos/Keyboards

While researching player pianos, I soon discovered that my idea wasfar from unique. Piano manufacturers like Steinway and Yamaha already sell pianos with the player capability but the prices are steep.Steinway sells a kit that can be added to their $40,000 grand pianofor an additional $20,000 to $30,000, while Yamaha sells a less expensive grand with the player piano feature for about $20,000.

Obviously, replacing the piano with a keyboard will result in a substantial saving but it has other benefits as well. These include:being light in weight, easy to move around and never having to betuned. The volume is adjustable and it can even be played with earphones for completely quiet operation. And the new models alsohave a long list of built-in accompaniments such as a base or drums.

Although the keyboard’s electronic imitation of the sound of thepiano is very good and getting better, it will never match the soundof a hammer hitting a taut set of strings and therefore will never satisfy the purist. Nevertheless, keyboards are gradually being accepted and used more regularly. In a small church in Maine, a versatile musical director has a Yamaha keyboard just like mine.When he is not playing his guitar, he plays the keyboard alternatingbetween piano and organ. Here in Naples, Florida, the church hallhas a very good 88-key electronic piano, which makes beautifulmusic through a system of multiple speakers.

2

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

Page 3: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

My Yamaha Keyboard

I started out with a visit to my local music store where I picked outa 76-key middle of the line Yamaha YPG-235. The special of theday included the stand and the “survival” kit which the salesman alsothrew in, bringing my purchase to a grand total of $268. The “survival” kit is a necessity. It includes the 120-volt power supply(this keyboard also operates on batteries), the earphones and the sustain pedal. Assuming that you assemble and wire the electronicparts yourself and that 50 of the 76 keys (much more on that subjectlater) are implemented, the cost of the rest of the project is about$380 for a total of $650.

As I mentioned in the preface, I envision this project as somethingthat a father-daughter or a high school team might tackle as a winterproject with the goal of building a modern, operational player piano.An important secondary goal is learning how to read sheet music andbecoming familiar with basic technologies ranging from electronicsto robots and computer software.

Photo 1.1 – Yamaha Keyboard With Soundproof Cover and Control Box

3

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

Page 4: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

4

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

Photo 1.1 on page 3 shows the bottom of the solenoids (mini-robots)above the keyboard’s keys (the cover is removed in Photo 2.4). The solenoids are connected with cables to the control box whichhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control box, a cable can be connected to the USB port of any laptop or PC in order to upload themusic to the Mega computer.

My intention is not just to describe how to build the control box butto explain the purpose of the components and how they work. The electronic board in the control box is shown in Photo 7.1. It looksvery complicated at first sight. Upon closer inspection, however, youwill see that there is only one unique Mosfet drive circuit with just four components, and that this exact drive circuit with four components is duplicated for each key. For the black keys, the electronic circuit going to the Mosfet drivers is slightly more complicated because the location of each black key is coded. I willbe sure to explain how and why that is necessary when we get to it.Only two other circuits are needed—one for the volume control andone to activate the sustain capability of the keyboard. Of course,these circuits are already designed and checked out for you. Only thework of assembling and wiring them needs to be done.

The Author’s Experience

I started working for IBM in 1956 at the very beginning of the computer era. At that time, computers had radio tubes and each bitof memory was a little core (like a bead) strung on four tiny wires. I have seen great changes in the last 60 years particularly in the enormous power of the microprocessors and their amazingly steepdecrease in price. The Mega computer used here ($13) has morepower than a room full of computer racks worth millions of dollars60 years ago.

Page 5: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

5

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

My interest in music started at a young age. My mother liked to bragabout her precocious child (that would be me) by telling this storyevery chance she had. It seems that a group of her adult friends werediscussing music and musical instruments. I was two or three yearsold at the time and only spoke French. When I was asked which instrument I would like to learn to play, I told them that I liked “la machine de Dame-Dame.” Dame-Dame’s machine was an oldstyle wind-up Victrola! I was already interested in mechanical thingsat this tender age and, apparently, I recognized my lack of talent toplay musical instruments.

Organization of the Book

The next chapter of Part One of the book is devoted to the processof constructing a player piano using the Yamaha keyboard. We willbe able to mount a bar supporting the solenoids and modify thevolume and sustain circuits without making any visible changes tothe Yamaha keyboard as attested by Photo 1.1.

Next, we will learn all about musical symbols and how to read sheetmusic. Finally, we will explore the design of the electronic circuitswhich are used to drive the solenoids as well as two other circuits:the volume control and the sustain operation.

Part Two of the book is all about making the Arduino Mega computerplay music. Why Arduino? The most important reason is that thereis an appropriate computer model to do the job, namely, the Megamicroprocessor with its large number of ports. The popularity of theArduino family of computers, their high quality and their low pricewere added bonuses.

The hardware section describes how to connect the electronic circuitsdesigned in Part One to the Mega. We will see that the wiring consists

Page 6: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

6

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

of plugging 53 wires in 53 of the 54 output ports and connecting afew low voltage wires from the appropriate outputs of the computerto the solenoid drivers. The USB cable is the only connection neededfrom the Mega to the PC.

Then we get immersed in software. Several chapters are devoted tothe player piano sketches (in the world of Arduino, the software programs are called sketches). The purpose of this software is totransform the sheet music information so that the keyboard will playthe correct notes and sounds. This software, named “Robo” and written by Steve is highly efficient. A minute’s worth of musicalnotes (about 200 notes) requires about 3000 bytes out of the 258,048bytes of the available memory in the Mega. Therefore, more than 90minutes worth of music can be played with one upload to the Mega.

The next chapters in Part Two, describe how the notes are coded sothat they can be interpreted by the Robo sketch. Each coded note haseight features which describe the note (such as its beat or whether itis part of a chord). Considering the amount of repetition there is inmusic, the coding may be tedious but it is not difficult.

And, finally, we describe diagnostic programs which can be used to play the scales by activating one key at a time to check out the operation of the solenoids or to troubleshoot a problem.

The Challenges

For me, making sense out of the little ovals with tails sitting on orbetween the 10 lines of the sheet music turned out to be my biggestchallenge during this project. Learning anything new is, of course,always a challenge.

When selecting the electronic parts, the main challenge is to find apush type solenoid with the right form factor (it has to fit in less space

Page 7: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

than the width of a key) yet it has to be powerful enough to depressthe key. The plunger travel has to move at least 3/8 of an inch to depress a key fully. In addition, because we need so many solenoids,they have to be inexpensive. The ones that I selected meet the specifications but they are too noisy for this application and need tobe modified. I would have been happier with a higher-quality solenoid but I could not find one at a good price.

Another challenge is to make the music sound less robotic (eventhough the mini-robots create it). The volume control and the sustainaction help a lot but more work could be done to make the musicsound as if it is produced by a true musician.

The main challenge writing the player piano sketch “Robo” is codingthe chords (when several keys are depressed at the same time). Especially difficult is Beethoven’s version of chords where some ofthe notes are modified during the time that the chord is being played.I can vouch for the fact that the mini-robots are up to task but I can’teven imagine how an accomplished pianist performs such a feat!

Due to the large number of keys, wiring the control box so that itdoes not look like a rat’s nest turned out to be a challenge. It is important to use as large a breadboard as possible. Using small wireand making neat solder joints also helps.

In the construction of the bar that holds the solenoids, the locationof the mounting hole for the solenoids is critical (otherwise the solenoid plungers will not line up with the middle of the keys). Vertically, the solenoids have to line up perfectly so that they all havea minimum of 3/8 inches of travel. To solve this problem, I made asimple jig which worked out very well.

Beyond these difficulties, the project is very straight forward. Witha lot of time and a good deal of patience, it can be completed by anycompetent do-it yourselfer.

7

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

Page 8: Introduction and Overviewmodernplayerpiano.com/ModernPlayerPiano_Chapter1.pdfhouses the Arduino Mega and the electronics which drive the solenoids. On the right side of the control

8

A Thoroughly Modern Player Piano Chapter 1 – Introduction and Overview

Summary of Chapter 1

To review the main points described in this chapter:

• The construction instructions shown in this book are for aYamahaYPG-235 Keyboard. There are no changes to thekeyboard that would detract from the instrument’s value.Similar keyboards can also be used.

• The computer which controls the operation of the keys isan Arduino Mega. All Arduino software is free and opensource. Using another computer is not recommended.

• Up to 76 solenoids (45 white keys and 31 black keys) canbe mounted on two horizontal bars to activate the keys.

• As shown in the photo, the solenoids are cabled to the control box which houses the Arduino Mega computer andthe solenoid drivers.

• Each of the Mega computer’s ports is wired to a simple fourcomponent Mosfet driver (the circuit diagram and thewiring charts are provided).

• The Arduino sketch “Robo” which interprets the notes andactivates the solenoids is provided.

• The code to transcribe the beat of the music and the musicalnotes from the sheet music to the Arduino Mega is createdon a PC which is attached to the Mega with the USB cable.Once the music has been coded and verified it can be uploaded to the Mega and played as often as desired.

• Musical arrangements with different beats or added pausescan be coded to re-arrange the sheet music or to create entirely new music and tunes.