PIC24 drum machine prototype

This is a project I’ve been working on for over a year but haven’t had the time to complete yet. Electronics takes second place to children… 🙂

It’s a mini drum machine modelled on classic machines like the Roland TR808. My version is digital, playing samples rather than analogue and uses a single pic24 to do the work.

At the moment the software is not complete, in fact the interface is pretty poor, but it is working and can function as a simple drum machine and is quite good fun to play with.

As it stands it has the following features;

  • 16 different instruments stored in Flash (Dependant on PIC flash size and sample quality/size).
  • 16 step patterns with 16 patterns per song.
  • 16 songs loaded and saved to FAT formatted SD card.
  • 8 sample polyphony, mixed in software.
  • 8bit, 16khz instruments sampled from classic drum machines.
  • Analog mono output filtered from an 8bit 156khz PWM signal.
  • Drives headphones directly or a speaker via a TPA301 audio amp (Thanks TI).
  • 16 buttons for beat input plus 4 more and 4-way joystick for interface.
  • 20 leds driven by a Maxim 6957 LED driver to provide feedback.
  • Nokia 5110 B/W LCD displays user interface.
  • Songs are stored as plain text in JSON format to allow some human readability.

Here’s a quick overview and demo video.

Features I think could be implemented in this prototype (not yet though);

  • Master and track specific volume controls. This would give more control over feel of the songs.
  • Real time sample volume manipulation to provide ADSR envelope for more sound variety.
  • Reverb/Echo using some spare RAM to add effects to output.
  • Better interface over all, maybe switch to a colour LCD.
  • Variable pitch sample playback. Use some sort of interpolation to allow playing samples back at other than their native sample rate. Again this would give some nice audio variety.

Apart from my general lack of free time, one reason for lack of development is that I feel that I might be better abandoning this prototype and switch to a larger version of the Pic, one with more spare I/O pins (pinnier) to allow more interface options such as potentiometers or rotary encoders, or drive a larger colour LCD in 8bit/16bit mode. I recently bought a ChipKIT Uno32 for a bit of experimenting and it’s kind of sidetracked my limited time whilst I play with it and a 320×240 colour LCD.  The ChipKITs are based on the pic 32 series, have loads of Ram and Flash and run at up to 80Mhz… It could probably load songs and play multiple samples direct from the SD card giving loads of free ram for effects and things… But that’s another idea.

Slightly dodgy green wire prototype

Anyway, some more info;

The SD card, the Nokia LCD and the Maxim LED driver all run on the hardware SPI bus.

I used ChaNs FatFS library to run the SD card and Dave Gambles cJSON library to parse the song files. I heavily pruned the cJSON library to remove features such as unicode that I didn’t need.

I created my own libraries for the Nokia LCD and Maxim LED driver. They’re fairly standalone but as they share the same hardware SPI peripheral they rely on a simple SPI library and a set of common defines to setup the hardware properly. If you are interested in these you can download the whole MPLAB X project and see how they fit together.

You can download the entire project if you want to have a look.

When I started out I built the project with a couple of smaller, more common PICs, the PIC24FJ64GA102 and PIC24FJ48GA002. I soon ran out of Flash rom but I’ve left in the conditional macros so it should still compile for them if you remove some samples.

Have fun and let me know if you have any questions.

Advertisements

12 thoughts on “PIC24 drum machine prototype

  1. This looks very cool Matt! All it needs is a good old fashioned MIDI output for other synths 🙂 I can’t wait to try this one out!

  2. Catmacey, you’ve done a really great job with the drum machine! What really interested me on the video is the joystick and the thin wires you are using on the proto board. Can you please tell me where did you get these from?

    • Hi Sparks. Thanks for the compliment.
      The Joystick is from Seedstudio it’s made by ALPS and I think I’ve seen it in some other shops too (Yes, nkcelectronics.com have them too). The wire is wire-wrap wire that they sell at at a local electronics shop. But I bought some from Ebay too, do a search for “kynar wire” and you’ll get lots of options. Some places seems to charge a lot for it though so check all your options before you buy.

  3. Hello Catmacey
    How are you? I’m Emmanuel; living in Toulouse (France). I study electronic at the university of science of Toulouse. I’m kind of PIC application
    I ask you, if you have made projects of synthesizer or drum machine with PIC 16F or 18F? I know these PICs very well and it’s easier for me
    Pleased, send me schématics and program files Thanks a lot, best regards
    Emmanuel

    • Hi Emmanuel. Sorry I’ve not done much with 8 bit PICs. I’m sure your could do something but the 32bit PICs are so much easier to work with and have a lot more RAM.

  4. first of all congratulations for the project is very interesting … I’m Javier and I live in Cusco (Peru). For days I have tried to use the MLA library (fileio) in the pic24hj128gp502 but I can not get it. I see that in your project you used an sd_card with the same pic, I just want to be able to write data in the sd_card help me please. By the way try to compile your project with MPLAB Xc16 v4.05 but I receive the same error as in my project:
    nbproject / Makefile-default.mk: 176: recipe for target ‘build / default / production / _ext / 812168374 / spi.o’ failed

    • Hi Javier,
      I’m not sure I can help you. I moved this project to a PIC32 and haven’t touched a PIC24 for a long time.
      However I can suggest that you have a look at Elm Chan’s FatFs project. It’s what I used to access the SD card.
      I believe that there is even a sample project for PIC24.

  5. Thanks for taking the time to answer. I could already solve my problem with the MPLAB library anyway I will review what you suggest

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s