***  Mike's PIC Microcontroller based Midi kick pedal  ***

(Also, my NEW Amateur Radio Electronic Projects page) click here

Mike's misc Tech linx

Get a GoStats hit counter

***HELP SAVE AMERICAN JOBS click here to find out how***

            

                                                                                                                    (my actual prototype board)

This page was created to provide a worthwhile project for electronics hobbyists (like myself), who enjoy designing circuits with microcontroller chips. Hopefully it will also serve as a useful device for percussionists, who might be in need of a simple circuit to midi trigger a kick drum sound in an external tone generator. To date I have found no other Midi (musical instrument digital interface) projects based on the Microchip PIC microcontroller, so this may be a first.

The circuit is of simple design, with most of the work being done through the program. In essence, a SPDT switch is depressed by linkage to a kick drum pedal. The routine for switch processing stores a value (the velocity byte) in a register, based on the time elapsed from the opening of the normally closed contact to the closing of the normally open contact. Serial data transmission then begins, transferring the byte hex99 (to play a note on midi channel 10), the byte retrieved from the port attached to the DIP switch (the key number to be played), and finally the velocity value saved previously. The communication routine is fairly simple, using 1 start, 8 data, and 1 stop bits. Logic levels are inverted, and the 5mA current loop ON is the logic zero start bit, to begin transmission at the midi rate of 31.25Kbaud (more on this through the links below).

Working as a maintenance electrician for a major steel producer here in northern West Virginia, I enjoy designing my own projects in my spare time for recreation (and an occassional actual need for a custom design). Other Midi based projects I have designed with the PIC chip include a stage lighting sequencer, which I dubbed "MIDILITE" (triggered off a keyboard player's first note, for hands free operation), and a Midi data logging and viewing device (which works well, but turned out to be a heavy financial burden, as well as a marketing flop).

My thanks go out to Uncle Joe, for coming up with the suggestion of building such a device, based on his own needs in the live performance music business (sorry for the long wait...). It took some time to debug and finish the source code, but it is finally complete.

Thanks to Microchipfor putting out such a great device (they have other even more versatile PIC chips, with larger program space, built in A/D conversion, etc...).Parallax Corporation's PASM assembler, as well as all the application notes they offer at their web site proved extremely helpful, and their PIC16Cxx programmer for these chips works great.Jan Axelson's LakeView Research is a great site for getting ideas on designing with microcontrollers (as well as PC port information, and more). For more on Midi protocol & hardware details/requirements,Harmony Central and MidiWebare excellent informational sites.

Below is a GIF image of the Midi kick pedal circuit (please forgive the quality, as this was done via pasting and freehand work in MS Paint, then converted from .bmp to .gif). note: my own version is powered by a 9 volt battery through a 78L05 regulator IC.     Note: click here for a recently added circuit modification to the triggering circuit.

Below are some highlights from the source code (which you can download/view here as a text file). This can be renamed directly with a .src extension, and compiled with Parallax's PASM assembler (note: you may want to change the header Device designation from pic16c56 to pic16c54. I used an eprom version of the 56 for development, but the code will fit into the 54). I have attempted to be as thorough as possible in commenting the code, without becoming overly verbose.

Switch transition to velocity byte conversion :

call debounce
:loop jb switch_up,timer ;If switch is logic high, continue
jmp :loop

timer mov pause,#255 ;This line sets delay time
:loop nop
djnz pause,:loop ;Remain in loop until zero
jnb switch_dn,send ;or switch reaches bottom
djnz vel_byte,timer ;Decrement & re-check if not 0

Loading of the data bytes to be transmitted (a subroutine):

datastor
cje msg_cntr,#0,byte1 ;Check counter, to see which
cje msg_cntr,#1,byte2 ;byte is needed next. Then jump
cje msg_cntr,#2,byte3 ;below, to store that byte.

byte1 mov xmt_byte,#99h ;Note on, midi channel 10
ret
byte2 mov xmt_byte,note ;Note value = DIP switch setting
ret
byte3 mov xmt_byte,vel_byte ;Velocity variable
ret

Midi transmission of the data:

send
:again mov bit_cntr,#8 ;Eight bits in a byte
call datastor ;Get the next byte from storage

setb serial_out ;Send start_bit
call bit_delay ;Wait 1 bit period (32 uSec)

:xmit rr xmt_byte ;Rotate bits of byte being sent, into carry

movb serial_out,/c ;Send a bit out
call bit_delay ;Wait 1 bit period (32 uSec)
djnz bit_cntr,:xmit ;Not 8 bits yet? Send next bit

clrb serial_out ;Send stop bit
call bit_delay ;Wait 1 bit period (32 uSec)
inc msg_cntr ;Add 1 to byte pointer(next byte)

cjbe msg_cntr,#2,:again ;More bytes to send? Then repeat.

:loop jnb switch_up,over
jmp :loop ;Stay here until pedal is up

over jmp start ;Restart the program (next kick)

I hope this page will prove useful, as well as serve to generate more interest in both Microcontroller design and Midi applications development.

Sincerely, Mike Whitco, CET

*** This page supported by http://www.digibid.com/ online musical equipment auction ***