Turning a PIC into a keyboard

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
asm_2750
Posts: 19
Joined: Sun Oct 24, 2004 1:01 am
Contact:

Turning a PIC into a keyboard

Post by asm_2750 »

I love music, the only problem, I would love to make a keyboard, I like the Pic alot and I would enjoy trying to turn one into a keyboard or something that plays music, my only problem I dont know where to start. What I have at my disposal is two 16F877As and a 16F84A, I would like to use the 84A since it is a good one to play with when you are a newbie with such devices. Any help will be appreciated.
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

Welcome to the forum.<p>This is a hard one to answer with out knowing what you are trying to do. When you say keyboard, do you mean the electromechanical aspects of getting keys to work, wave form synthesis, midi interface, ... The range is too broad to even hazard a guess.<p>Selecting the components before having a basic design idea is probably a mite premature.<p>Phil
Engineer1138
Posts: 458
Joined: Thu Feb 05, 2004 1:01 am
Location: Minneapolis, MN
Contact:

Re: Turning a PIC into a keyboard

Post by Engineer1138 »

The book, _Musical Applications of Microprocessors_ used to be the standard reference... well, 20 years ago anyway. Amazon has it at http://www.amazon.com/exec/obidos/ASIN/ ... 07-5992659<p>Can't believe I remember that. Well, that's why I never lose at Trivial Pursuit :-)
asm_2750
Posts: 19
Joined: Sun Oct 24, 2004 1:01 am
Contact:

Re: Turning a PIC into a keyboard

Post by asm_2750 »

Something to make sound I would say, and then maybe a midi interface in the future. Mostly I just want it to be able to play notes and such. I've seen an toy organ made with just a 555 a bunch of switches and resistors, but I would like to have something closer to a keyboard you can just pick up at a radioshack. <p>Really all in all, a note is just a soundwave at a certain pitch and amplitude. As for interfaceing input, heck, an AT keyboard would work as an input device. As for speaker output, I woulden't know, might need a DAC or a device to convert for a normal speaker.
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

there are lots of ways to make a sound from a PIC. the most obvious is to take 8 lines out of the PIC and into an 8 bit DAC. The rate at which you output the values to make a sine wave determines the frequency. Not super high quality but not too bad. 12 bit DACs start to get decent and 16 bit can be very good.<p>You can get serial DACs that dont require a lot of pins. Maxim has a bunch and good sample policies so my might get them free.<p>You could also fake a DAC with PWM though i wonder how good quality you'd get.<p>Now, here's the fun part, with a little math, you can create envelopes for your sine waves to create interesting sound effects. Don't forget reverb and other cool effects.
User avatar
Chris Smith
Posts: 4325
Joined: Tue Dec 04, 2001 1:01 am
Location: Bieber Ca.

Re: Turning a PIC into a keyboard

Post by Chris Smith »

I use the standard Key board, or a Yamaha keyboard, with a standard windows midi program. <p>Great sounds, & nothing you cant do. <p>And best part is,...no reinventing the wheel.
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

but Chris, he wants to reinvent the wheel. It sounds (no pun intended) kind of fun to me.
asm_2750
Posts: 19
Joined: Sun Oct 24, 2004 1:01 am
Contact:

Re: Turning a PIC into a keyboard

Post by asm_2750 »

Yes I feel like reinventing the wheel. Also It helps me learn a good deal of the capablities of what a pic can do. Cant learn how to be an engineer if you dont try.
User avatar
Chris Smith
Posts: 4325
Joined: Tue Dec 04, 2001 1:01 am
Location: Bieber Ca.

Re: Turning a PIC into a keyboard

Post by Chris Smith »

Philba
You need to expand the NV forum here to include a separate section called,...”Reinventing the wheel” ....by Pic.<p> That way as you journey through life in your endeavor to reinvent the transistor, resistor, diode, and all the other things a Pic can do, we can proceed with more serious business of electronics? <p>We have been there, so you can imagine the snicker factor of those who want to [re] invent, what has already been invented.<p> Not to spoil your day, but come on, we have been there, we have done that, and we don’t see the need or desire to reinvent any wheel?<p>I would like to see the Pic utilitized to its max as a bio fed back heart monitor, a dialysis machine, or even guiding a rocket to Mars,... but a flasher, a midi keyboard,[???] come on, get your imagination drooling and inventing for gods sake? <p>How about a pin diode, into a Starlight scope, feeding and controlling the 10kv PS so that it cant be burnt out? <p>Don’t you guys have any imagination?
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

Let me get this straight, because you think it's a waste of effort, no one should do it? <p>I guess it took me a while to realize you are just trolling for an argument. Oh, well, every forum has at least one.
L. Daniel Rosa
Posts: 400
Joined: Tue Dec 25, 2001 1:01 am
Location: Bellingham, WA
Contact:

Re: Turning a PIC into a keyboard

Post by L. Daniel Rosa »

I am working on something slightly similar to this, but without the ability to read a keyboard.<p>I suggest breaking the project into smaller parts and tackling them independantly. The '84 can take caree of reading an AT type keyboard and converting the keystrokes into whatever format you want (probably MIDI compatible). You'll probably wnat to have an LCD on the '84 to let you know what keys it thinks it's transmitting to the part(s) that play the sounds. The screen will make debugging a lot faster.<p>
The '877 would be set up as a slave device to receive serial data from the keyboard interpreter and play the sounds. It has three 8 bit I/O ports available, but I suggest not using portC for the sound as that has communication hardware multiplexed with it and you will probably want to use it.<p>You will want a few lookup tables to save time. One will have a 256 sample sime wave. Other waveforms may be available as well. Another wil have the notes in 24 bit precision. The way the note is generated is by adding the 24 bit value to a three byte sum, the top byte of which is used to fetch a value from the wave table which is then put in the port output latch. External parts (whether an R2R ladder or a DAC chip) will take the output and convert it into an analog signal for the amplifier.<p>The polling of the serial I/O, fetching of note values, wave table positions, and general housekeeping is done in a timed loop- possibly locked to TMR1 or TMR2. No interrupts should be used except to maintain timing.<p>Once you get the thing to play one note you'll probably want it to be able to play more than two. I thought of degrading the sound quality to as low as 6 bits to be able to cram 4 into one port. With two '877s, at two ports each that's sixteen notes at once. Sound quality won't win any awards, but it'll be more versatile than the RatShack plink'a'key.
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

Getting to multiple voices is going to be a challenge with a PIC. One approach could be to use serial DACs. With parallel DACs, you could use a couple of I/O pins to multiplex chip select signals to the various DACs. If it were me, I'd go with serial - a lot easier to add additional DACs. <p>To get to higher quality, I'd move up to a 12 bit (or even 16 bit) DAC but that means a pretty big look up table for the sine values. 8 bit devices run out of gas pretty fast when deal with larger data sets.<p>[ January 29, 2005: Message edited by: philba ]</p>
asm_2750
Posts: 19
Joined: Sun Oct 24, 2004 1:01 am
Contact:

Re: Turning a PIC into a keyboard

Post by asm_2750 »

So if I use a 16F84 as a type of input interface and have it give input data to the 877 over part of port C then maybe I can use port A and B and the rest of C to send infomation to two 4 channel serial input DACs correct(http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1376/ln/ MAX514)? That could probably give me 8 voices to play with. Adding flating and sharping could probably be done using op-amps or maybe some other form of circuit, but as long as I can get A B C D E F G notes out first its ok. But now if I have 8 12-bit voices, is there a way to tie them all into one amp and just one speaker, or am I looking at a complex circuit dealing with multiple amps and speakers?
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Turning a PIC into a keyboard

Post by philba »

you are rapidily exceeding my skill level!<p>Sharp/flat is just a different frequency.<p>you can mix the different signals together by capacitively coupling them. Take a look at the mixers circuits on discover - http://www.discovercircuits.com/A/au-mixer.htm<p>By the way, I'm playing with a Renesas 16 bit microcontroller - it has around 100 pins of output, 1/4 meg of flash and runs at 24 mhz. Sounds like a great basis for a synthesizer.
asm_2750
Posts: 19
Joined: Sun Oct 24, 2004 1:01 am
Contact:

Re: Turning a PIC into a keyboard

Post by asm_2750 »

Wow 100 pins, defnately beyond my current pic skills, but I am sure I could find a use for such a device.<p>Btw thanks for the mixer link.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 27 guests