Jump to content
43oh

TI Launchpad plays Bad Apple


Recommended Posts

this is my entry to 2011 Nov/Dec POTM.

 

been a while since my last project. the "bad apple" sound and sight reminds me of days when i spend afternoons in video arcade shop/parlor/institute? wasting my time/life. hope u enjoy.

 

this is not an original project, rather a mesh up of what i can google for my target toy instrument. original source / site are credited in the source code and mentioned.

 

 

description

 

. reproduction of the internet meme "bad apple" sound and sight, in a self contained device

. ti launchpad / msp430 low end device demo

. msp430 spi usage, bit-bang style, on two devices

. lcd module access demonstrated

. sd / mmc low level access demonstrated

. polyphonic tone generation via pwm demonstrated

 

post-83-135135525948_thumb.jpg

 

schematic

 

//               MSP430F20x2/3       ----------o--------------o Audio out
//             -----------------     |         |              o 
//         /|\|              XIN|-   |        ---             |
//          | |                 |   .-.       --- 10-500nF    |
//          --|RST          XOUT|-  | | 1-10K  |              |
//            |                 |   |_|        |---------------
//      LED <-|P1.0             |    |        ___                               
//            |                 |    |        ///    SD / MMC card      /|\
//            |    pwm out  P2.6|-----           ---------------------   |
//            |                 |               |                Vcc 4|---
//            |    as CS    P1.7|-------------->|1 CS, select device  |
//            |    as MOSI  P1.6|<--------------|7 MISO, data out     |
//            |                 |   ----------->|2 MOSI, data in      |
//            |                 |   | --------->|5 CLK, spi clock     |
//            |                 |   | |         |                Gnd 3|---
//            |                 |   | |          ---------------------   |
//            |                 |   | |                                 ---
//            |                 |   | |           Nokia 5110 breadout   ///
//            |                 |   | |   ----------------------------- 
//            |    as SCLK  P1.1|---|-o->|7 SCLK, spi clock            |
//            |    as MISO  P1.2|---o--->|6 MOSI, data in              |
//            |    as D/C   P1.3|------->|5 D/C, data or control       |
//            |    as RST   P1.4|------->|4 RST, reset, low active     |
//            |    as SCE   P1.5|------->|3 SCE, select , low active   | /|\
//            |                 |    ----|2 Gnd                        |  |
//            |                 |    |   |                        Vcc 1|---
//                                  ---   -----------------------------
//                                  ///
//
//        SD (back side)                          Micro-SD (back side)
//        __________________                      __________________
//       /  1 2 3 4 5 6 7 8 | 1. CS      .. SEL  /  1 2 3 4 5 6 7 8 | 1. NC            
//       |9                 | 2. DATAIN  .. SDO  |                  | 2. CS      .. SEL
//       |                  | 3. GND     .. Gnd  |                  | 3. DATAIN  .. SDO
//       |  S O - + C   I   | 4. 3.3V    .. Vcc  |    S O + C - I   | 4. 3.3V    .. Vcc
//       |                  | 5. CLK     .. Clk  |                  | 5. CLK     .. Clk
//       |                  | 6. GND/NC  .. Gnd  |                  | 6. GND/NC
//       |                  | 7. DATAOUT .. SDI  |                  | 7. DATAOUT .. SDI
//       |                  | 8. DAT1            |                  | 8. DAT1
//       |                  | 9. DAT2            |                  | 9. DAT2

the circuit is consist of three modules.

 

. a sd / mmc module that reads content from sd / mmc card

. a lcd module that show video on nokia 7110 or 5110 lcds

. a polyphonic pwm output implementation, 8 channels are used in this project

. the sd / mmc module and the lcd module shares some pins

. both sd / mmc module and the lcd module are isolated and can be included in other projects

. the core part of the code implements pwm sound and controls timing for content reads and displays

 

firmware

 

the firmware was done under ubuntu 11.10 w/ mspgcc4 + mspdebug as programmer. it is also test built under windows 7 with cygwin environment, mspgcc4 is also used and a MSP430Flasher.exe (command line programmer released by TI) is used to program the launchpad. it should build also w/ CCS as i had compiler directives to switch code portions. however i did not verify, you are on your own if you are on CCS or IAR.

 

the are additional details / options that you can tweak, they are explained in the source code. they are not listed here as you only need them if you built the project.

 

content generation

 

data content for both the video and sound can be created via the supplied zcontent.pl script. input for content includes an avi video file and a midi file. this script can be used to generated alternate contents for most avi and midi files.

 

the followings are needed for content generation

. we need an avi file for video

. we need a midi file for audio, prefer about 8 channel simple paino instrument

. supporing utility / tools

. should be done in a linuxish machine or w/ cygwin

. unixish bin-utils, etc. we need "sort" for sure

. perl, the internet duct tape to tie things together

. certian perl modules, like "Image::BMP", "POSIX"

. midicsv and whatever he requires, this is for midi extraction

. ffmpeg to extract bitmaps from video

. dd utility (part of linux / cygwin) to write content binary to sd / mmc card

 

i don't want to put full details in this post as it may be too long to read. and it can be found here at http://www.simpleavr.com/msp430-projects/bad-apple. comments / suggestions are most welcomed.

 

source tarball is available here as attachment. binaries (contents + firmware) are available at the mentioned link.

bad_apple_src.tgz

Link to post
Share on other sites

And I'm posting AGAIN (sorry) - I noticed on your schematic that you list the device as MSP430F20x2/3. You also note that a 2MB SD card is used - do you mean GB? Also - you published the raw files for the SD card to your website, but didn't publish sound.h or content.h. I'd love to see the Midi and AVI files as well (unless there are copyright issues of course).

 

Regarding my earlier comment about windows - looks like I could set up Cygwin - sorry I didn't notice that in your post. I'm excited to try this one out.

Link to post
Share on other sites
Long time SimpleAVR.

Nice project.

 

and the POTM prizes are getting more and more attractive. :)

 

And I'm posting AGAIN (sorry) - I noticed on your schematic that you list the device as MSP430F20x2/3. You also note that a 2MB SD card is used - do you mean GB? Also - you published the raw files for the SD card to your website, but didn't publish sound.h or content.h. I'd love to see the Midi and AVI files as well (unless there are copyright issues of course).

 

thanks for your interest.

 

i had put a compressed avi and midi file (got them off forums and youtube links) in my project page. these are the exact same ones i used in my build.

 

the device that i tried includes F2012, G2211, G2231, G2452, G2553. u will need to substitute header files to match your chip. we just need devices w/ a timerA.

 

you only need 2MB (byte) SD space, the smallest card i own is 16Mb mmc from years ago which could fit nicely, i am using a micro sd 1Gb for the project as i am using a SD adapter as a sleeve. originally i intend to use serial eeproms and i figure out it will be more expensive.

 

the raw files are to be ghosted / burnt via "dd" to your sd card, the one for 7110 lcd is about 1.5Mb and for 5110 lcd is about 1.2Mb. "dd" under cygwin works but u need to find out your raw device name. usually /dev/sdb or similar. i built this originally on a 7110 lcd which match the avi very nicely (being 96x64 pixel) but eventually that hardware setup failed (i did not used a breakout and was soldering smt size wires on a perfboard.

 

i did not include the generated content.h and sound.h because i had deleted them, u will get them again after running zcontent.pl. they are only useful if u have small content that u like to link them as part of the firmware. for example, on a 16K G2553 device, u can have a few seconds of movie plus a song built w/ your firmware, and eliminate the need for a sd card.

 

i attempted to do a build w/ CCS, can get the thing compile but failed the final linking due to some "target device" setup. as i am constantly switching between devices, my CCS project setup is a mess and i decide to abandon. if u are familiar w/ CCS, i am sure it is a no-issue.

Link to post
Share on other sites

thanks a ton SimpleAVR!

I'll look at getting the code running with CCS. That's all I've been using so far, but I've found most issues simple to fix.

 

I have a couple of ideas for just the audio as well. I have a bunch of small mint tins from Trader Joes, and several left-over 2211 chips - it would be neat to create something my kids could plug in and listen to a Christmas song.

Link to post
Share on other sites

I have a couple of ideas for just the audio as well. I have a bunch of small mint tins from Trader Joes, and several left-over 2211 chips - it would be neat to create something my kids could plug in and listen to a Christmas song.

 

that's not a bad idea, the sound is actually quite decent. i did not invest my time in doing good on the low-pass filter, which would definitely improve the quality. u can also adjust how many channels u need via zcontent.pl. but a 2k device (w/o SD card) might not hold a lot of midi data.

 

Looking at the code, it seems that you ignored all the SPI peripheral devices and opted for software bit banged SPI.

Did you do that because you wanted the same code across all the chips, or was there some other reason?

 

i just want it be more flexible, not just in terms of multiple devices, but also the freedom to layout projects. ex. w/ s/w spi i can attach the lcd breakout directly to the launchpad via headers. like so.

 

post-83-135135526246_thumb.jpg

Link to post
Share on other sites

I managed to get Cygwin installed this weekend, and compiled a file with the MIDI input. Still have to download some of the components for the video - but I managed to write a file to the SD card as well. Hopefully my LCDs will be arriving in the mail any day.

 

For people looking to attach the SD card to the breadboard - this looks like a good tutorial (love Instructables).

Link to post
Share on other sites

project update / improvement / alternate build

alternatively, for contents that are short and simple, we can omit the sd card and have a compact built.

 

w/ an 8k / 16k device, a music / video box can be constructed w/o breadboard or pcb.

 

this is the "nyan cat", another internet meme, i reckon there are already versions on propeller, arduino, etc.

 

post-83-135135526969_thumb.jpg

 

the video content is actually from a 6 frame animated gif and the midi uses 2 channel only. the firmware was done at less than 6 k and it's running off a g2452. the 5110 breakout has all pins align to one side of the launchpad and is powered via p2.0 and p2.1. this eliminate use of breadboard or shields.

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...