final report03

Upload: apache2

Post on 30-May-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Final Report03

    1/54

    Autica Final Report

    Group #42 (aka R2D2)

    Ryan Saunders Ryan Sullenberger

    Dan Yacobucci Dan Marvin

  • 8/14/2019 Final Report03

    2/54

    1

    Table of Contents

    Table of Contents.....1

    Picture of Project......2

    Design Overview..3

    List of Components..4

    Details of Design..5

    Method of Song Programming.....7

    Photos of the Project....9-12

    Software Flowchart.....14

    Functional Diagram.....15

    Detailed Wiring Diagrams.............16-18

    Partial Parts List..........................19

    Project Evaluation.......20

    Program Source Code ............... 23

    Sample Excel Music Spreadsheets......42

  • 8/14/2019 Final Report03

    3/54

    2

    Picture of Final Project

  • 8/14/2019 Final Report03

    4/54

    3

    Design Overview

    The goal of the Audica is to create a self-playing instrument in which the user can select from alist of pre-programmed songs, which can then be played back on the melodica in real time. Amelodica is a reeded instrument in which the user blows into the mouthpiece and presses keys on

    the outside. When a button is pressed air is directed over a reed and a note is produced. Oursystem will control 2 octaves of the melodica or 25 notes.

    The instrument is controlled by PIC micro controllers, which will take input from the user andcomplete the necessary actions to start and play a song. The unit is powered on with toggleswitches at the back of the control box and begins a countdown sequence ending with a beepindicating it is ready for song selection. Songs are listed next to the display and are played byentering the coorisponding song number into the 12 key keypad. Once the number has beentyped, the name of the song will appear on the LCD display above the keypad along with songduration and playback begins.

    This begins a succession of events. Air, which is supplied via compressed air tank, is turned onby a valve allowing it to flow through the instrument. Using solenoids, the PIC activates theproper notes in succession and the song is played. When the song is finished the air valve closesand the system waits for the next command.

  • 8/14/2019 Final Report03

    5/54

    4

    List of Components

    A. Output Display

    LED (2 Indicates signal output from pic to relays)

    LED (Input received indicator) LCD (Display song name and track information)

    B. Audio Output Device

    Speaker with software-generated sound effects (signal all clear) Melodica air powered keyboard instrument

    C. Manual Data Input

    Switch (turn on/off air valve)

    Keypad (select song number, select manual or automatic mode)

    D. Automatic Sensor Input

    Light sensor (for automatic song selection based on ambient light level)E. Actuators

    25 Solenoids (to press Melodica keys) 25 Relays 1 Air Valve

    F. Logic, Counting, Integration, and Control

    Programmed logic Menu-driven software (LCD instructions) Multiple PIC microcontrollers

    o 2 PIC16F88o 2 PIC18F4680

  • 8/14/2019 Final Report03

    6/54

    5

    Details of Design

    At the heart of the design is the control box where all of the input, actuators and circuitry arehoused. The back panel of the box holds computer power supplies which take wall power andconvert it to 5V and 12V DC and is used to power the circuits and solenoids respectively.

    On the front of the control box is the control panel which houses a 12 key keypad, lcd displayand PC speaker. Wires run from the panel to the circuit board inside. The melodica sits on top ofthe control box with two slits just in front of it. Under each slit are the mounted solenoids whichare spaced to be underneath the respective keys they control. Solenoids for the white keys are onthe front of the board and black keys on the back. Using bent coat hanger wire the pull typesolenoids are connected to the keys on the melodica.

    Inside the control box is the main circuit board which holds all of the components of the circuitin the functional diagram. The circuit consists of 4 PIC microcontrollers and as can be seen fromthe functional diagram, each PIC serves a unique purpose. Because PICs can only execute single

    commands in succession we opted to use 4 to ensure smooth playback and operation of thedevice. Also mounted on the circuit board are 3 LED indicator lights. One red light remains onwhenever power to the circuit is present and dims for a half of a second whenever input isreceived from the keypad. This helps with troubleshooting the system. The other two LEDs (redand yellow) flash alternatively to indicate when the pic has output a new signal to the relays.

    The first PIC is a PIC18F4680 which connects to all input and serves strictly as system control. Itreceives input from the keypad and light sensor system (explained later). The PIC is programmedto interpret keystrokes and correlate them with a database of songs stored in EEPROM. Oncerecognized, it outputs the name, duration and number of the track on the LCD display andplayback mode begins. The song number is output serially to the music playback PIC

    (PIC18F4680). The music playback PIC recalls four 8-bit note patterns which are stored in itsmemory for each note of the song. Each 8-bit pattern corresponds to set combinations of the 25output pins, setting them to either high or low. A pin on high indicates the note is on, whilelow is an indication the note is off. Each pin out is connected to the IDE output connection onthe back circuit board. When the song has completed the system waits for the next inputcommand.

    An IDE cable runs from the control board to the relay board. Contained on this board are 25relays where the input leads from the bus are connected to each relay. 12V power is supplied tothe relays so when a 5 volt signal is received the relay turns on and passes high power signal tothe respective solenoid, thus playing the appropriate note. High power output is sent via IDEconnection from the relay board to the solenoid mounting board.

    When power is first supplied to the system, the PIC automatically initiates the power upsequence and outputs an audio signal to the speaker which sounds like a series of musical beepsindicating that the system is ready and it lights the red LED giving the All Clear. This entiresequence is pre programmed into the PICs EEPROM.

  • 8/14/2019 Final Report03

    7/54

  • 8/14/2019 Final Report03

    8/54

    7

    Method of Song Programming

    By using a spreadsheet to declare the output settings of PORTA, PORTB, PORTC, and PORTDof a 40-pin PIC, potentially any musical composition can be converted into a form in whichPICBASIC can read and therefore output to the melodica.

    In the spreadsheet, the first eight columns will represent PORTA, which will correspond tomusical notes F to C. The second set of eight columns will represent PORTB (corresponding tomusical notes C# through G#) and so on. There will also be a column for the duration of the noteconfiguration (in ms). A 1 entered into any cell means that the corresponding note is on, anda 0 means that the corresponding note is off. After the set duration for any given noteconfiguration has passed, the new note configuration and duration is read from the next row.

    Example showing what the F-major scale would look like:

    F F# G G# A A# B C C# D D# E F Duration PORTA PORTB

    1 500 %10000000 %00000000

    1 250 %00100000 %00000000

    1 250 %00001000 %00000000

    1 250 %00000100 %00000000

    1 250 %00000001 %00000000

    1 250 %00000000 %01000000

    1 250 %00000000 %00010000

    1 500 %00000000 %00001000

    1 250 %00000000 %00010000

    1 250 %00000000 %01000000

    1 250 %00000001 %00000000

    1 250 %00000100 %00000000

    1 250 %00001000 %00000000

  • 8/14/2019 Final Report03

    9/54

    8

    1 250 %00100000 %00000000

    1 500 %10000000 %00000000

    After a song entry is completed, columns containing data for the Duration, PORTA, PORTB andso on are transposed into rows. This allows easy export as common separated values (CSV).Using the comma separated value export, the data can be copied and pasted into a PICBASICarray containing all of the values. By using a loop and counter in PICBASIC PRO, the notepatterns in the arrays can be obtained one after the other and held for the given duration.

  • 8/14/2019 Final Report03

    10/54

    9

    Photos of the Project

    Figure 1 : The solenoid board before interfaced to the melodica. The solenoids in the picture are for the white keys.

    The black key soleno ids are located on the back of the board.

    Figure 2 : IDE cable for sending the proper signal to the solenoids.

  • 8/14/2019 Final Report03

    11/54

  • 8/14/2019 Final Report03

    12/54

    11

    Figure 5 : The top of the relay board.

    Figure 6 : The bottom of the relay board showing soldering connections.

  • 8/14/2019 Final Report03

    13/54

  • 8/14/2019 Final Report03

    14/54

    13

    Figure 9: The front side of the final product showing the LCD, keypad, speaker holes and the magical blue light

    coming f rom inside o f the box.

  • 8/14/2019 Final Report03

    15/54

    14

    Software Flowchart

    Master PIC Music Playing PIC

    START

    Define I/O pins

    Define constants and

    variables

    Initialize LCD and

    await inst ruction

    from keypad

    Has a button on

    the keypad

    been pressed?

    NO

    Display

    corresponding song

    on LCD

    Send the music p laying

    PIC instructions.

    YE

    START

    Define I/O pins

    Define constants and

    variables

    Has the PIC

    received

    instructions

    yet? NO

    Return to main menu

    Turn on solenoids

    END

    YE

  • 8/14/2019 Final Report03

    16/54

    15

  • 8/14/2019 Final Report03

    17/54

    16

  • 8/14/2019 Final Report03

    18/54

    17

  • 8/14/2019 Final Report03

    19/54

    18

  • 8/14/2019 Final Report03

    20/54

    19

    Partial Parts List

    Item Quantity Description Supplier Part

    Number

    Price

    PIC16F88 2 10-bit A/D, 18 pin, PWM Microchip PIC16F88-I/P

    Free

    PIC18F4680 2 10-bit A/D, 40 pin, PWM Microchip PIC18F4680-I/P

    Free

    SH9543 25 24VDC PULL-TYPE SOLENOID AllElectronics

    SOL-58 $1.50

    Aromat S4E13 13 4A1/20HP/125,250VAC,3A,30VDCRelay

    LSI N/A Free

    Aromat ST2E-DC5V

    12 8A1/4HP/125,250VAC Relay LSI N/A Free

    TEMT6000 1 Ambient light sensor, analog, NPNtransistor SparkFunElectronics COM-08348 $1.25

    Melodica 1 Horner Student 32 Key Melodica MusiciansFriend

    702712 $40

    Keeping costs down on this project was a priority for us both because we didnt have much to

    spend and because it forced us to be more creative. When it was possible we borrowed and had

    parts donated. LSI Logic donated all of the relays, proto-boards and other miscillaneous supplies

    for the project.

  • 8/14/2019 Final Report03

    21/54

  • 8/14/2019 Final Report03

    22/54

    21

    a darkened, but not dark, room. We were successfully able to implement the sensor into our

    project.

    Actuators

    25 relays and 25 solenoids were employed to mechanically operate the keyboard of the melodica.

    Considerable research went into finding solenoids that had the displacement and force we needed

    at a cost which was reasonable for our project. The solenoids we found require a lot of current

    and it became obvious that relays were going to be needed. Additional research and some trial

    and error resulted as there is no specification for the instantaneous power on current

    requirements for the solenoids and we had no accurate way to measure it. Also, relays that could

    handle our current requirements were prohibitively expensive and forced us to find an alternative

    source. LSI Logic donated the relays for the entire project. Once the relays were found,

    considerable time and effort was put into sodering them in an organized fashion such that the

    100+ wires were organized and manageable.

    Logic, Counting, Integration and Control

    A total of 4 PICS were interfaced and programmed to work together as a whole. Research went in

    to the operation of 40 pin PICS and their available memory for song storage. Memory storage

    was extremely important to us because of the large amount of data it takes to store all of our

    songs. It was found that the PIC18F4680 would work the best for us because of its 64 Kbytes of

    program memory size, allowing us plenty of storage for our songs without having to use an

    external EEPROM.

    With the use of the 40 pin PICS we had to learn about MPASMWIN and how to use it. The 18F

    and 18C series PICmicrocontrollers require a different assembler than the 16F series. Most of the

    programming of the PICs was able to be done in house without having to utilize the mechatronics

    engineering lab using simple JDM serial programmers. They were able to handle any of the types

    of PICs that we needed.

    One of the major tasks with our circuit was to find a method for all of the PIC microcontrollers to

    communicate with one another. Serial communication came to mind, but noticing that all of ourPICs had many pins to spare, we decided to invent our own 4-bit communication protocol. How

    it works is a handshake line goes HIGH from the master PIC which triggers all of the PIC

    microcontrollers (mainly the LCD PIC and the music playing PIC) to listen for a signal. Using 4

    pins on each PIC, a 4-bit number was sent after the handshake lines went high. This was a simple

    yet extremely efficient way to communicate and send commands between one chip and another.

  • 8/14/2019 Final Report03

    23/54

    22

    This method limits the entire system to 16 commands, but with only 9 songs requiring

    commands to be played, this was not a problem for our project.

    Obviously a lot of logic went into the programming of the music for the melodica, having to read

    the next set of notes from an array everytime a note changes and holding it for a given amount oftime. This is of course explained in much greater detail in the section titled Method of Song

    Programming above.

    Qualitative Adjustments

    There are two categories in which our project really stands out. When we decided to program

    songs into the pic microprocessor we realized how tedious this would be if we had to input each

    note into PicBasic one by one so a better solution was sought. After searching through alternative

    methods of musical input revealed additional expense to the project, a custom software solution

    was written. The details of this solution were explained on page 7 and involved using MS Excel

    to graphically input each note and its duration. From there it was a simple cut and paste

    operation that saved our group countless hours of programming and troubleshooting as we

    solved timing issues. Without the aid of sheet music for several of our songs, programming was

    largely trial and error and would not have been possible without this method.

    Additionally, the components internal to the melodica are put together in an organized and clean

    fashion. The use of standardized IDE cables makes the project both clean and reproducable. With

    25 relays needing 4 wires each, 25 solenoids needing 2 wires each, 2 40 pin pics and 2 18 pin

    pics, there are hundereds of wiring connections in the project. All of which were done neatly andprofessionally as detailed in the pictures presented previously.

    We feel that these two atributes go above and beyond the normal expectations outlined in the

    project objectives.

  • 8/14/2019 Final Report03

    24/54

    23

    PROGRAM SOURCE CODE:

    '//////////////////////////////////////////////////////////////////////////////'

    ' MUSIC DELIVERY MICROCHIP - MAIN CONTROLLING CHIP' ==============================================================

    ' Date: November 24, 2008' Author: Ryan Sullenberger' Group: 42 (R2D2)

    ' Colorado State University, Mechanical Engineering'

    ' PIC18F4510

    ''//////////////////////////////////////////////////////////////////////////////

    DEFINEOSC8 ' Tells the PIC what clock we are using

    OSCCON.4=1 ' Sets the internal oscillator frequency to 8 MHz

    OSCCON.5=1

    OSCCON.6=1

    ADCON1=15 ' Turns off analog to digital conversion

    CMCON=7 ' Turns off analog comparison pins

    'VARIABLES

    Cnt VAR word

    'TRIS SETTINGS

    TRISA=%00000000 ' Set all PORTA pins to OUTPUTS

    TRISB=%00000000 ' Set all PORTB pins to OUTPUTS

    TRISC=%11111111 ' Set all PORTC pins to INPUTS

    TRISD=%11111111 ' Set all PORTD pins to INPUTS

    INPUTPORTA.2

    INPUTPORTA.5

    PORTB=%00000000 ' Initially set all PORTB pins to 0

    'BLINK POWER LED TO INDICATE CIRCUIT IS ON

    LOWPORTA.1

    PAUSE500

    HIGHPORTA.1

    PAUSE500

    'SIGNAL ALL CLEAR THROUGH SPEAKER'///////////////////////FREQOUTPORTB.7,125,2500

    PAUSE125

    FREQOUTPORTB.7,125,2250

    PAUSE125

    FREQOUTPORTB.7,125,2000

    PAUSE125

    FREQOUTPORTB.7,125,1750

    PAUSE2000

    '////////////////////////

    PORTB=%00000000 ' Initially set all PORTB pins to 0

    'MAIN LOOPmain: ' This loop waits for input from keypad and sends the corresponding data to the LCD PIC

    and the music playing PIC

    IFPORTD.0=1THEN ' Button 1

    TOGGLEPORTA.1

    PORTB=%00000011 ' Send bit-pattern to play song number 1

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTD.1=1THEN ' Button 2

    TOGGLEPORTA.1

    PORTB=%00000101 ' Send bit-pattern to play song number 2

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIFIFPORTD.2=1THEN ' Button 3

    TOGGLEPORTA.1

    PORTB=%00000111 ' Send bit-pattern to play song number 3

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTD.3=1THEN ' Button 4

    TOGGLEPORTA.1

    PORTB=%00001001 ' Send bit-pattern to play song number 4

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTC.4=1THEN ' Button 5

  • 8/14/2019 Final Report03

    25/54

    24

    TOGGLEPORTA.1

    PORTB=%00001011 ' Send bit-pattern to play song number 5

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTC.5=1THEN ' Button 6

    TOGGLEPORTA.1

    PORTB=%00001101 ' Send bit-pattern to play song number 6

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000ENDIF

    IFPORTC.6=1THEN ' Button 7

    TOGGLEPORTA.1

    PORTB=%00001111 ' Send bit-pattern to play song number 7

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTC.7=1THEN ' Button 8

    TOGGLEPORTA.1

    PORTB=%00010001 ' Send bit-pattern to play song number 8

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTD.4=1THEN ' Button 9

    TOGGLEPORTA.1

    PORTB=%00010011 ' Send bit-pattern to play song number 9

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTD.5=1THEN ' Button *

    TOGGLEPORTA.1

    PORTB=%00010101 ' Send bit-pattern to display automatic mode on LCD

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    PAUSE6000

    GOTOAUTOMATIC

    ENDIF

    IFPORTD.6=1THEN ' Button 0

    TOGGLEPORTA.1

    PORTB=%00010111 ' Send bit-pattern to display fun message on LCD

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    ENDIF

    IFPORTD.7=1THEN ' Button #

    TOGGLEPORTA.1

    PORTB=%00011001 ' Send # bit-pattern to LCD. Does not really do anything.

    PAUSE1000

    TOGGLEPORTA.1PORTB=%00000000

    ENDIF

    GOTOmain

    'AUTOMATIC MODE

    AUTOMATIC:

    IFPORTA.5=1&&PORTA.2=0THEN ' The light is DIM! Send the appropriate signal to the music playing PIC,

    TOGGLEPORTA.1 ' and blink the indicator light quickly.

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    TOGGLEPORTA.1

    PAUSE50

    HIGHPORTA.1

  • 8/14/2019 Final Report03

    26/54

    25

    TOGGLEPORTA.1

    PORTB=%00010001 ' Send the "light is dim" bit-pattern.

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    PAUSE5

    PORTB=%00010101 ' Send the "return to main menu" bit-pattern to the LCD PIC.

    PAUSE1000

    PORTB=%00000000

    GOTOmain

    ENDIF

    IFPORTA.2=1&&PORTA.5=0THEN ' The light is ON! Send appropriate signal.TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    TOGGLEPORTA.1

    PAUSE250

    HIGHPORTA.1

    TOGGLEPORTA.1

    PORTB=%00010011 ' Send "light is on" bit-pattern.

    PAUSE1000

    TOGGLEPORTA.1

    PORTB=%00000000

    PAUSE5

    PORTB=%00010101 ' Return the LCD to it's main menu.

    PAUSE1000

    PORTB=%00000000

    GOTOmain

    ENDIF

    GOTOAUTOMATIC

  • 8/14/2019 Final Report03

    27/54

    26

    '//////////////////////////////////////////////////////////////////////////////

    '' MUSIC DELIVERY MICROCHIP - MUSIC DELIVERY MICROCHIP

    ' ==============================================================' Date: November 23, 2008' Author: Ryan Sullenberger

    ' Group: 42 (R2D2)' Colorado State University, Mechanical Engineering

    '' PIC18F4680'

    '//////////////////////////////////////////////////////////////////////////////

    DEFINEOSC8 ' Tells the PIC what clock we are using

    OSCCON.4=1 ' Sets the internal oscillator frequency to 8 MHz

    OSCCON.5=1

    OSCCON.6=1

    ADCON1=15 ' Turns off analog to digital conversion

    CMCON=7 ' Turns off analog comparison pins

    'DEFINE ALL VARIABLESCnt VAR Word

    CntTotal VAR Word

    Choice VAR Byte

    PatternB VAR Byte

    PatternC VAR Byte

    PatternD VAR Byte

    PatternA VAR Byte

    Time VAR Word

    'TRIS SETTINGSTRISB=%00000000

    TRISC=%00000000

    TRISD=%00000000

    OUTPUTPORTA.0 ' Set PORTA.0 as an output for solenoid #25

    'SEND ALL CLEAR SIGNAL TO THE INDICATOR LEDsPAUSE500

    HIGHPORTA.1

    HIGHPORTA.2

    PAUSE250

    LOWPORTA.1

    LOWPORTA.2

    PAUSE250

    HIGHPORTA.1

    HIGHPORTA.2

    PAUSE250

    LOWPORTA.1

    LOWPORTA.2

    PAUSE250

    HIGHPORTA.1

    HIGHPORTA.2

    'LOOP THAT CHECKS FOR SIGNAL THAT TELLS WHICH SONG TO PLAY:

    SONGCHECK:

    IFPORTA.3=1THEN

    PAUSE50

    IFPORTE.2=1&&PORTE.1=0&&PORTE.0=0&&PORTA.5=0THEN

    Choice=1

    GOTOmain

    ENDIF

    IFPORTE.2=0&&PORTE.1=1&&PORTE.0=0&&PORTA.5=0THEN

    Choice=2

    GOTOmain

    ENDIF

    IFPORTE.2=1&&PORTE.1=1&&PORTE.0=0&&PORTA.5=0THEN

    Choice=3

    GOTOmain

    ENDIF

    IFPORTE.2=0&&PORTE.1=0&&PORTE.0=1&&PORTA.5=0THEN

    Choice=4

    GOTOmain

    ENDIF

    IFPORTE.2=1&&PORTE.1=0&&PORTE.0=1&&PORTA.5=0THENChoice=5

    GOTOmain

    ENDIF

    IFPORTE.2=0&&PORTE.1=1&&PORTE.0=1&&PORTA.5=0THEN

    Choice=6

    GOTOmain

    ENDIF

    IFPORTE.2=1&&PORTE.1=1&&PORTE.0=1&&PORTA.5=0THEN

    Choice=7

    GOTOmain

    ENDIF

    IFPORTE.2=0&&PORTE.1=0&&PORTE.0=0&&PORTA.5=1THEN

    Choice=8

    GOTOmain

  • 8/14/2019 Final Report03

    28/54

    27

    ENDIF

    IFPORTE.2=1&&PORTE.1=0&&PORTE.0=0&&PORTA.5=1THEN

    Choice=9

    GOTOmain

    ENDIF

    ENDIF

    GOTOSONGCHECK

    'MAIN MUSIC PLAYING LOOP

    main:

    HIGHPORTA.1 ' Indicator of note progression on

    HIGHPORTA.2 ' Indicator light initially onCnt=0 ' Initialize CNT to 0

    NXT:

    IFChoice=1THEN ' Song 1 was selected. Find the note patterns for song

    GOSUBNOTEA1 ' Find the bit pattern to send to PORTA

    GOSUBNOTEB1 ' Find the bit pattern to send to PORTB

    GOSUBNOTEC1 ' Find the bit pattern to send to PORTC

    GOSUBNOTED1 ' Find the bit pattern to send to PORTD

    GOSUBDURATION1 ' NOTE: This is the same for selections

    GOSUBSONGLENGTH1 ' 2 - 9 below, all depending on which song

    ENDIF ' is being played.

    IFChoice=2THEN ' Song 2 was selected. Find the note patterns for song

    GOSUBNOTEA2

    GOSUBNOTEB2

    GOSUBNOTEC2

    GOSUBNOTED2

    GOSUBDURATION2

    GOSUBSONGLENGTH2

    ENDIF

    IFChoice=3THEN ' Song 3 was selected. Find the note patterns for song

    GOSUBNOTEA3

    GOSUBNOTEB3

    GOSUBNOTEC3

    GOSUBNOTED3

    GOSUBDURATION3

    GOSUBSONGLENGTH3

    ENDIF

    IFChoice=4THEN ' Song 4 was selected. Find the note patterns for song

    GOSUBNOTEA4

    GOSUBNOTEB4

    GOSUBNOTEC4

    GOSUBNOTED4

    GOSUBDURATION4

    GOSUBSONGLENGTH4

    ENDIF

    IFChoice=5THEN ' Song 5 was selected. Find the note patterns for song

    GOSUBNOTEA5

    GOSUBNOTEB5

    GOSUBNOTEC5

    GOSUBNOTED5

    GOSUBDURATION5

    GOSUBSONGLENGTH5

    ENDIF

    IFChoice

    =6THEN ' Song 6 was selected. Find the note patterns for songGOSUBNOTEA6

    GOSUBNOTEB6

    GOSUBNOTEC6

    GOSUBNOTED6

    GOSUBDURATION6

    GOSUBSONGLENGTH6

    ENDIF

    IFChoice=7THEN ' Song 7 was selected. Find the note patterns for song

    GOSUBNOTEA7

    GOSUBNOTEB7

    GOSUBNOTEC7

    GOSUBNOTED7

    GOSUBDURATION7

    GOSUBSONGLENGTH7

    ENDIF

    IFChoice=8THEN ' Song 8 was selected. Find the note patterns for song

    GOSUBNOTEA8

    GOSUBNOTEB8

    GOSUBNOTEC8

    GOSUBNOTED8

    GOSUBDURATION8

    GOSUBSONGLENGTH8ENDIF

    IFChoice=9THEN ' Song 9 was selected. Find the note patterns for song

    GOSUBNOTEA9

    GOSUBNOTEB9

    GOSUBNOTEC9

    GOSUBNOTED9

    GOSUBDURATION9

    GOSUBSONGLENGTH9

    ENDIF

    ' SEND MUSIC PATTERN TO ALL PORTS

    PORTA.0=PatternA

    PORTB=PatternB

    PORTC=PatternC

    PORTD=PatternD

    PAUSETime ' Play the selected notes for the given duration.

  • 8/14/2019 Final Report03

    29/54

    28

    PORTA.0=0 ' Reset all notes to NULL

    PORTB=%00000000 ' Reset all notes to NULL

    PORTC=%00000000 ' Reset all notes to NULL

    PORTD=%00000000 ' Reset PORTD.0 to NULL

    Cnt=Cnt+1 ' Cnt ++

    IFCnt>CntTotalTHENGOTOENDSONG ' If the song has played it's last note, end the song.

    GOSUBBLINK ' Toggle the note progression LED.

    GOTONXT ' Go gather the next note pattern to play.

    ' ************************** SONG 1 - Test Pattern

    ' **************************' ************************** In these sections you will find the song length (note count),

    ' ************************** and all of the note patterns that need to be sent to the' ************************** different ports to played select music.' **************************

    SONGLENGTH1:

    CntTotal=236

    RETURN

    NOTEB1:

    ' Find which note to play.Lookup

    Cnt,[%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%10000000,%01000000,%00100000,

    %00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%0000001

    ,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%0000

    0010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%001

    00000,%01000000,%10000000,%00000000,%10000000,%00100000,%00000010,%00000100,%00001000,%00000000,%00000000,%00000100,%00100000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000010,%00000100,%00000010,%00000001,%00000010,%

    00000100,%00001000,%00010000,%00100000,%01000000,%10000000],PatternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC1:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%010

    00000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00100000,%01000000,%00000000,%00000100,%00001000,

    %00010000,%00100000,%01000000,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%01000000,%00100000,%00010000,%00001

    000,%00000100,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED1:' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%10000000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000001,%000000

    0,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000

    000,%01000000,%00100000,%00010000,%00001000,%00000100,%00000010,%00000001,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%0

    0100000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%01000000,%00100000,%00010000,%

    00001000,%00000100,%00000010,%00000001,%00000000,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

  • 8/14/2019 Final Report03

    30/54

    29

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%01000000,%00010000,%00000100,%00000001,%00000000,%00000001,%00000000,%00000001,%00000000,%00000001,%00000000,%0

    0000001,%00000000,%00000001,%00000000,%00000001,%00000000,%00000001,%00000010,%00000001,%00000010,%00000001,%00000010,%00000001,%0000001

    ,%00000100,%00000010,%00000100,%00000010,%00000100,%00000010,%00000100,%00000010,%00001000,%00010000,%00100000,%01000000,%10000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA1:

    ' Find which note to play.Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURNEND ' End of program, in case PIC gets "lost"

    DURATION1:

    ' Find out how long to play each note.Lookup2

    Cnt,[500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,50

    0,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,1000,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,1

    25,125,125,125,125,125,125,125,125,500,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,1

    25,1000,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,6

    0,60,60,60,60,60,60,60,1000,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50

    ,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,5

    0,50,50,50],Time ' LOOKUP takes a given segment from an array.

    RETURN

    END ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 2 - LEGEND OF ZELDA' *************************************************************' *************************************************************

    ' *************************************************************' *************************************************************

    ' *************************************************************

    SONGLENGTH2:

    CntTotal=145

    RETURN

    NOTEB2:

    ' Find which note to play.Lookup

    Cnt,[%00000100,%10000000,%00000000,%10000000,%00000100,%00010000,%01000000,%00010000,%00000100,%01000000,%00000000,%01000000,%00000100,%

    00001000,%00100000,%00001000,%00000000,%00000100,%10000000,%00000000,%00000100,%00000100,%00000001,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000001,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%10000

    000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%1

    0000000,%00000000,%10000000,%00000100,%10000000,%00000000,%00000100,%00000100,%00000001,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000100,%00000001,%00000000,%

    00000001,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%1000000

    0,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000,%00000000,%10000000],PatternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC2:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00100000,%00001000,%0000000

    0,%00001000,%00000000,%00001000,%00000100,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000100,%00000001,%00000100,%00001000,%00000000,%00001000,%00100000,%00000000,%00100000,%00001000,%00000100,%00001000,%00100000,%10000000,%00000000,%10000000,

    %00100000,%00001000,%00100000,%10000000,%00000000,%00000000,%00000000,%01000000,%00010000,%00000010,%00001000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00100000,%00001000,%00000000,%0000100

    ,%00000000,%00001000,%00000100,%00000001,%00000000,%00000000,%00000000,%00000000,%00001000,%00000100,%00000000,%00000000,%00001000,%0000

    0000,%00001000,%00000100,%00000000,%00000000,%00001000,%01000000,%00100000,%00000100,%00001000,%10000000,%00000000,%00000000,%00000000,%

    00000000,%01000000,%00010000,%00000010,%00001000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED2:

    ' Find which note to play.

    Lookup

  • 8/14/2019 Final Report03

    31/54

    30

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00000000,%01000000,%00000000,%01000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%01000000,%00001000,%00010000,%10000000,%00000000,%00000000,%01000000,%10000000,%00000000,%0000

    0000,%00000000,%00000000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA2:

    ' Find which note to play.

    Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURN

    END ' End of program, in case PIC gets "lost"

    DURATION2:

    ' Find out how long to play each note.Lookup2

    Cnt,[1668,284,50,334,334,167,167,2334,1668,284,50,334,334,167,167,1667,667,667,667,334,334,167,167,167,167,1618,50,284,50,167,334,167,1

    668,167,117,50,167,334,167,501,167,1284,50,667,284,50,167,167,1334,334,334,284,50,167,167,1334,334,334,284,50,167,167,1334,667,334,107,5

    0,107,50,284,50,107,50,107,50,284,50,107,50,107,50,284,50,334,667,667,334,334,167,167,167,167,1618,50,284,50,167,334,167,2001,667,667,1

    334,667,2001,667,667,1284,50,667,2001,667,667,1334,667,2001,667,667,1334,667,284,50,167,167,1334,667,334,107,50,107,50,284,50,107,50,107

    ,50,284,50,107,50,107,50,284,50,334],Time ' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 3 - GREENSLEEVES' *************************************************************' *************************************************************

    ' *************************************************************' *************************************************************

    ' *************************************************************

    SONGLENGTH3:

    CntTotal=40

    RETURN

    NOTEB3:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%10000000,%10000000,%10000000,%10000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000001,%00000001,%00000001,%00000000,%10000000,%10000000,%10000000,%10000000,%10000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000001,%00000001,%10000000,%00000000,%10000000],Pat

    ternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC3:

    ' Find which note to play.

    Lookup

    Cnt,[%00001000,%00000001,%00000000,%00000000,%00000000,%00000000,%00100000,%00100010,%00100000,%00101000,%00100010,%10000001,%10001000,%

    10000000,%10001000,%10010000,%10001000,%00000010,%00010000,%00000000,%00001000,%00000001,%00000000,%00000000,%00000000,%00000000,%0010000

    0,%00100010,%00100000,%00101000,%00100010,%10000001,%10000010,%10001000,%00010000,%01000000,%00010000,%00001000,%00000000,%00001000],Pat

    ternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED3:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%01000000,%00010000,%00001000,%00010000,%01000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00010000,%00001000,%00010000,%0100000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000],Pat

    ternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA3:

    ' Find which note to play.

    LookupCnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

  • 8/14/2019 Final Report03

    32/54

    31

    RETURN

    END ' End of program, in case PIC gets "lost"

    DURATION3:

    ' Find out how long to play each note.Lookup2

    Cnt,[500,1000,500,750,250,500,1000,500,750,250,500,1000,450,50,750,250,500,1000,500,1000,500,1000,500,750,250,500,1000,500,750,250,500,

    750,250,500,750,250,500,1450,50,1500],Time ' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 4 - CHICKEN DANCE

    ' *************************************************************' *************************************************************' *************************************************************

    ' *************************************************************' *************************************************************

    SONGLENGTH4:

    CntTotal=117

    RETURN

    NOTEB4:' Find which note to play.Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000001],PatternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC4:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000010,%00000000,%00000010,%

    00000000,%00000010,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000010,%00000000,%00000010,%00000000,%00000010,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00001000,%00010010,%00001000,%00000000,%00001000,%000

    00000,%00001000,%00000010,%00000000,%00000010,%01000000,%00000000,%01000000,%00001000,%00000000,%00001000,%00000000,%00001000,%00000010,%00000000,%00000010,%01000000,%00000000,%01000000,%00001000,%00000000,%00001000,%00000000,%00001000,%00000010,%00000000,%00000010,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00010010,%00001000,%00000000,%00000010,%00000000,%00000010,%00000000,%00000010,%00000000,%0

    0000000,%00000000,%00010000,%00000000,%00010000,%00000010,%00000000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%0001000

    ,%00000000,%00010000,%00000010,%00000000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00010010,%00001000,%00000010,%00010000],PatternC

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTED4:

    ' Find which note to play.Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%10000000,%00000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%1000000

    0,%00000000,%10000000,%00010000,%00000000,%00010000,%00100000,%00000000,%00100000,%10000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00100

    000,%00000000,%00100000,%10000000,%00000000,%00000000,%10000000,%10010000,%00100000,%00000000,%00000000,%00000000,%00000000,%10000000,%0

    0000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%10000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%10000000,%00010000,%00000000,%00010000,%0010

    0000,%00000000,%00000000,%10000000,%00100000,%00010000],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA4:

    ' Find which note to play.

    Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURN

    END ' End of program, in case PIC gets "lost"

    DURATION4:

    ' Find out how long to play each note.Lookup2

  • 8/14/2019 Final Report03

    33/54

    32

    Cnt,[375,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,150,150,300,3

    00,300,300,300,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,300,150

    ,300,300,300,300,300,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,263,38,113,38,150,113,38,150,113,38,150,1

    50,150,300,300,300,375],Time' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 5 - SMALL WORLD' *************************************************************

    ' *************************************************************' *************************************************************' *************************************************************' *************************************************************

    SONGLENGTH5:

    CntTotal=68

    RETURN

    NOTEB5:

    ' Find which note to play.Lookup

    Cnt,[%00000000,%00000001,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%

    00000000,%00000010,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%0000000

    1,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%00000000,%00000001,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%00000000,%00000001],PatternBRETURNEND ' End of program, in case PIC gets "lost"

    NOTEC5:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000010,%00010000,%00000010,%00000000,%00000010,%00010000,%00000010,%00000000,%00000010,%00001000,%00000010,%

    00000010,%00000000,%00000010,%00001000,%00000010,%00000000,%00000010,%00001000,%00000010,%00000000,%00000010,%00001000,%00000010,%0000000

    0,%00000010,%00010000,%00000010,%00000010,%00000000,%00000010,%00010000,%00000010,%00000000,%00000010,%00010000,%00000010,%00000000,%000

    00010,%00010000,%00000010,%01000000,%00000010,%00001000,%00000010,%00000010,%01000000,%00000010,%00000100,%00000010,%00000000,%00000000,

    %00001000,%00000000,%01000000,%00001000,%00010000,%01000000,%00000000,%00000010,%00010000,%00000010,%00000000],PatternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED5:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00010000,%00010000,%00000000,%00010000,%00000001,%00000001,%00010000,%00010000,%00000100,%00000100,%00000000,%00000100,%

    00000000,%00000100,%00000100,%00000100,%00000000,%00000100,%00000100,%00000000,%00000100,%00000000,%00000000,%00000100,%00000100,%0000000

    1,%00000001,%00000000,%00000001,%00000000,%00000001,%00000001,%00000001,%00000000,%00000001,%00000001,%00000000,%00000001,%00000000,%00000000,%00000001,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%10000000,%10000000,

    %10000000,%10000000,%00100000,%00100000,%00100000,%00100000,%00010000,%00010000,%00010000,%00010000,%00000000],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA5:

    ' Find which note to play.Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0],PatternA

    RETURNEND ' End of program, in case PIC gets "lost"

    DURATION5:

    ' Find out how long to play each note.

    Lookup2

    Cnt,[500,200,200,200,200,200,200,200,200,200,200,200,170,30,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,30,170,200,

    200,200,200,200,200,200,200,200,200,200,200,200,200,170,30,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,500],Time

    ' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 6 - TEQUILA' *************************************************************' *************************************************************' *************************************************************

    ' *************************************************************' *************************************************************

  • 8/14/2019 Final Report03

    34/54

    33

    SONGLENGTH6:

    CntTotal=151

    RETURN

    NOTEB6:

    ' Find which note to play.Lookup

    Cnt,[%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000010,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000],PatternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC6:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%00000000,%01000000,%00010000,%00000000,%00000000,%00000000,%00000000,%

    00010000,%00000000,%00010000,%01000000,%00000100,%00000000,%01000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%0100000

    0,%00000100,%00000000,%01000000,%00010000,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%000

    00000,%01000000,%00010000,%00000000,%00000000,%01000000,%00010000,%00000010,%00010000,%00000000,%00000000,%01000000,%00010000,%00000010,

    %00010000,%00000000,%00000000,%01000000,%00010000,%00000010,%00010000,%00000000,%00000100,%00000000,%00000100,%00000000,%00000100,%00000

    000,%00000100,%00000000,%00000100,%00000000,%00000100,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%00000000,%01000000,%00010000,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%0000000

    ,%01000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%00000000,%01000000,%00010000,%00000000,%0000

    0000,%00000000,%00000000,%00010000,%00000000,%00010000,%01000000,%00000100,%00000000,%01000000,%00010000,%00000000,%00000000,%01000000,%

    00010000,%00000010,%00010000,%00000000,%00000000,%01000000,%00010000,%00000010,%00010000,%00000000,%00000000,%01000000,%00010000,%000000

    0,%00010000,%00000000,%00000100,%00000000,%00000100,%00000000,%00000100,%00000000,%00000100,%00000000,%00000100,%00000000,%00000100,%000

    00000,%00000000,%00000000],PatternC

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTED6:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00100000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00100000,%00000000],PatternD

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTEA6:

    ' Find which note to play.Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURNEND ' End of program, in case PIC gets "lost"

    DURATION6:

    ' Find out how long to play each note.

    Lookup2

    Cnt,[167,167,167,167,167,167,167,167,167,167,167,750,167,167,167,167,167,167,167,167,167,1000,167,167,167,167,167,167,167,167,167,167,1

    67,500,167,167,167,167,167,167,167,167,167,750,167,167,167,1000,167,1000,167,167,167,1000,167,1000,167,167,167,1000,167,1000,122,20,122,20,122,20,122,20,122,20,122,20,122,334,167,167,167,167,167,167,167,167,167,167,167,750,167,167,167,167,167,167,167,167,167,1000,167,167,

    167,167,167,167,167,167,167,167,167,500,167,167,167,167,167,167,167,167,167,750,167,167,167,1000,167,1000,167,167,167,1000,167,1000,167,

    167,167,1000,167,1000,122,20,122,20,122,20,122,20,122,20,122,20,122,334],Time' LOOKUP takes a given segment from an array.

    RETURN

    END ' End of program, in case PIC gets "lost"

    ' ************************************************************* SONG 7 - MNT KING' *************************************************************' *************************************************************

    ' *************************************************************

  • 8/14/2019 Final Report03

    35/54

    34

    ' *************************************************************

    ' *************************************************************

    SONGLENGTH7:

    CntTotal=151

    RETURN

    NOTEB7:

    ' Find which note to play.

    Lookup

    Cnt,[%00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000001,%00000010,%00000001,%

    00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%0000100

    0,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000001,%00000010,%00000001,%00001000,%000

    00010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0001,%00000000,%00000001,%00000010,%00000001,%00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000001,%00000000,%00000000,%00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%0000000

    0,%00000001,%00000010,%00000001,%00001000,%00000010,%00000001,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00001,%00000000,%00000000],PatternB

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTEC7:

    ' Find which note to play.Lookup

    Cnt,[%00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%01000000,%00000000,%01000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%00000000,%00000010,%00010000,%00000000,%00010000,%00000010,%0000000

    0,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%01000000,%00000000,%01000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%01000000,%00010000,%01000000,%00010000,%00000000,%00000010,%00010000,%00000000,%00010000,%00000010,%01000000,%00010000,

    %00001000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%01000000,%00010000,%00001

    000,%00000010,%00000000,%00000010,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00010000,%00001000,%00000010,%00000000,%0

    0000010,%00000000,%00000000,%00000000,%00000000,%00000000,%00000010,%00000000,%01000000,%00010000,%00001000,%00000010,%00000000,%0000001

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%01000000,%0000

    0000,%01000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%00000000,%00000010,%

    00010000,%00000000,%00010000,%00000010,%00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%01000000,%00000000,%0100000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01000000,%00010000,%01000000,%00010000,%00000000,%00000010,%00010000,%000

    00000,%00010000,%00000010],PatternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED7:

    ' Find which note to play.Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%10000000,%00000000,%10000000,%01000000,%10000000,%01000000,%10000000,%00000000,%10000000,%00000000,%00000000,%00000

    000,%00000000,%10000000,%00000000,%10000000,%01000000,%10000000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%10000000,%0

    0000000,%10000000,%01000000,%10000000,%01000000,%10000000,%00000000,%10000000,%00000000,%00000000,%00000000,%00000000,%10000000,%0000000

    ,%10000000,%01000000,%10000000,%01000000,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000

    0000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%10000000,%00000000,%00000000,%000

    00000,%00000000,%00000000],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA7:

    ' Find which note to play.

    Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURNEND ' End of program, in case PIC gets "lost"

    DURATION7:

    ' Find out how long to play each note.

    Lookup2

    Cnt,[199,199,199,199,199,199,398,199,199,398,199,199,398,199,199,199,199,199,199,199,199,199,199,199,199,796,199,199,199,199,199,199,39

    8,199,199,398,199,199,398,199,199,199,199,199,199,199,199,199,199,199,199,796,199,199,199,199,199,199,398,199,199,398,199,199,398,199,19

    9,199,199,199,199,398,199,199,398,796,199,199,199,199,199,199,398,199,199,398,199,199,398,199,199,199,199,199,199,398,199,199,398,796,19

    9,199,199,199,199,199,398,199,199,398,199,199,398,199,199,199,199,199,199,199,199,199,199,199,199,796,199,199,199,199,199,199,398,199,19

    9,398,199,199,398,199,199,199,199,199,199,199,199,199,199,199,199,796],Time ' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

  • 8/14/2019 Final Report03

    36/54

    35

    ' ************************************************************* AUTO - LIGHT OFF - TAPS

    ' *************************************************************' *************************************************************

    ' *************************************************************' *************************************************************' *************************************************************

    SONGLENGTH8:

    CntTotal=27

    RETURN

    NOTEB8:

    ' Find which note to play.

    Lookup

    Cnt,[%00100000,%00000000,%00100000,%00000001,%00100000,%00000001,%00000000,%00100000,%00000001,%00000000,%00100000,%00000001,%00000000,%

    00100000,%00000001,%00000000,%00000001,%00000000,%00000000,%00000000,%00000001,%00100000,%00000000,%00100000,%00000000,%00100000,%0000000

    1],PatternB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC8:

    ' Find which note to play.Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00000000,%00010000,%

    00000000,%00000000,%00010000,%00000000,%00010000,%00000010,%00010000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternC

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTED8:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0],PatternD

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEA8:

    ' Find which note to play.

    LookupCnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURN

    END ' End of program, in case PIC gets "lost"

    DURATION8:

    ' Find out how long to play each note.Lookup2

    Cnt,[563,25,188,2250,563,188,2250,375,375,750,375,375,750,375,375,2250,563,1878,1500,750,750,2250,25,563,25,188,2250],Time ' LOOKUP

    takes a given segment from an array.RETURN

    END ' End of program, in case PIC gets "lost"

    ' ************************************************************* AUTO - LIGHT ON - REV

    ' *************************************************************' *************************************************************' *************************************************************' *************************************************************' *************************************************************

    SONGLENGTH9:

    CntTotal=107

    RETURN

    NOTEB9:

    ' Find which note to play.

    Lookup

    Cnt,[%00100000,%00000001,%00000000,%00000001,%00100000,%00000000,%00000001,%00000000,%00000001,%00100000,%00000000,%00000001,%00000000,%

    00000001,%00100000,%00000001,%00000000,%00000001,%00100000,%00000001,%00000000,%00000001,%00100000,%00000000,%00000001,%00000000,%0000000

    1,%00100000,%00000000,%00000001,%00000000,%00000001,%00100000,%00000000,%00100000,%00000001,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000001,%00000000,%00000001,%00000000,%00000001,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%00000000,%00000

    001,%00100000,%00000000,%00100000,%00000001,%00100000,%00000001,%00000000,%00000001,%00100000,%00000000,%00000001,%00000000,%00000001,%0

  • 8/14/2019 Final Report03

    37/54

    36

    0100000,%00000000,%00000001,%00000000,%00000001,%00100000,%00000001,%00000000,%00000001,%00100000,%00000001,%00000000,%00000001,%0010000

    ,%00000000,%00000001,%00000000,%00000001,%00100000,%00000000,%00000001,%00000000,%00000001,%00100000,%00000000,%00100000,%00000001],Patt

    ernB

    RETURNEND ' End of program, in case PIC gets "lost"

    NOTEC9:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%

    00000000,%00000000,%00000000,%00010000,%00000000,%00000000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%000

    10000,%00000000,%00010000,%00000000,%00010000,%00000010,%00010000,%00000000,%00010000,%00000000,%00010000,%00000000,%00010000,%00000000,

    %00010000,%00000000,%00010000,%00000000,%00010000,%00000000,%00010000,%00000000,%00010000,%00000010,%00010000,%00000000,%00010000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%0

    0000000,%00010000,%00000000,%00010000,%00000000,%00000000,%00000000,%00010000,%00000000,%00000000,%00000000,%00010000,%00000000,%0000000

    ,%00010000,%00000000,%00010000,%00000000,%00000000,%00010000,%00000000,%00010000,%00000000,%00000000,%00000000,%00000000,%00000000],Patt

    ernC

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTED9:

    ' Find which note to play.

    Lookup

    Cnt,[%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%

    00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    0,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%000

    00000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,

    %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000

    000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0

    0000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%0000000

    ,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000],PatternD

    RETURN

    END ' End of program, in case PIC gets "lost"

    NOTEA9:

    ' Find which note to play.Lookup

    Cnt,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],PatternA

    RETURNEND ' End of program, in case PIC gets "lost"

    DURATION9:

    ' Find out how long to play each note.Lookup2

    Cnt,[199,199,99,99,199,199,199,99,99,199,199,199,99,99,199,199,398,199,199,199,99,99,199,199,199,99,99,199,199,199,99,99,199,50,199,597

    ,179,20,179,20,179,20,179,20,179,398,199,199,199,199,199,199,398,199,179,20,179,20,179,20,179,20,179,398,199,199,199,199,199,50,199,597

    ,199,199,99,99,199,199,199,99,99,199,199,199,99,99,199,199,398,199,199,199,99,99,199,199,199,99,99,199,199,199,99,99,199,50,199,597],Ti

    me ' LOOKUP takes a given segment from an array.

    RETURNEND ' End of program, in case PIC gets "lost"

    ' ************************************************************* END OF SONGS

    ' *************************************************************' *************************************************************' *************************************************************' *************************************************************' *************************************************************

    BLINK:

    TOGGLEPORTA.1 ' Toggle the note progression LED and return.

    RETURN

    ENDSONG:

    PORTA=%00000000 ' Set all ports to NULL at the end of the song.

    PORTB=%00000000

    PORTC=%00000000

    PORTD=%00000000

    PAUSE1500

    PAUSE500 ' Blink the LEDs to signal that the song has successfully completed.

    HIGHPORTA.1

    HIGHPORTA.2

    PAUSE250

    LOWPORTA.1

    LOWPORTA.2

    PAUSE250

    HIGHPORTA.1

    HIGHPORTA.2

  • 8/14/2019 Final Report03

    38/54

    37

    PAUSE250

    LOWPORTA.1

    LOWPORTA.2

    PAUSE250

    HIGHPORTA.1

    HIGHPORTA.2

    GOTOSONGCHECK

  • 8/14/2019 Final Report03

    39/54

    38

    '//////////////////////////////////////////////////////////////////////////////

    '' LCD PIC - DISPLAY MODULE FOR AUTICA

    ' ==============================================================' Date: November 24, 2008' Author: Ryan Sullenberger

    ' Group: 42 (R2D2)' Colorado State University, Mechanical Engineering

    '' PIC16F88'

    '//////////////////////////////////////////////////////////////////////////////

    ' LCD should be connected as follows:' LCD PIC' DB4 PortA.0' DB5 PortA.1

    ' DB6 PortA.2' DB7 PortA.3' RS PortA.4 (add 4.7K pullup resistor to 5 volts)' E PortB.3' RW Ground

    ' Vdd 5 volts' Vss Ground' Vo 20K potentiometer (or ground)' DB0-3 No connect

    DEFINEOSC8 ' Tells PIC which clock we are using

    OSCCON.4=1 ' Sets the internal oscillator frequency to 8 MHz

    OSCCON.5=1

    OSCCON.6=1

    ansel=0 ' Turns off analog to digital conversion. Refer to

    ' Threaded Design Example A.4 p.296-299 of the textbook' for an example of how to configure and use A/D conversion

    'VARIABLES

    Cnt VAR Byte

    'INITIAL VALUESCnt=1

    Pause500 ' Wait for LCD to startup

    LCDOUT $fe,1 ' Initially clear LCD

    'MAIN LOOP

    LCDFUN:

    ' If Cnt = 1 then we have returned to the main menu. Display the main menu message.IFCnt=1THEN

    Lcdout $FE,1,"WELCOME TO AUTICA WHERE", $FE, $C0,"MAGIC HAPPENS" ' Clear LCD screen

    ENDIF

    ' Await instruction from the main master PIC. Once instruction is known, execute the instructions.IFPORTB.1=1THEN

    PAUSE50

    IFPORTB.4=1&&PORTB.5=0&&PORTB.6=0&&PORTB.7=0THEN

    GOTONUMBERONE

    ENDIF

    IFPORTB.4=0&&PORTB.5=1&&PORTB.6=0&&PORTB.7=0THEN

    GOTONUMBERTWO

    ENDIF

    IFPORTB.4=1&&PORTB.5=1&&PORTB.6=0&&PORTB.7=0THEN

    GOTONUMBERTHREE

    ENDIF

    IFPORTB.4=0&&PORTB.5=0&&PORTB.6=1&&PORTB.7=0THEN

    GOTONUMBERFOUR

    ENDIF

    IFPORTB.4=1&&PORTB.5=0&&PORTB.6=1&&PORTB.7=0THEN

    GOTONUMBERFIVE

    ENDIF

    IFPORTB.4=0&&PORTB.5=1&&PORTB.6=1&&PORTB.7=0THEN

    GOTONUMBERSIX

    ENDIF

    IFPORTB.4=1&&PORTB.5=1&&PORTB.6=1&&PORTB.7=0THEN

    GOTONUMBERSEVEN

    ENDIF

    IFPORTB.4=0&&PORTB.5=0&&PORTB.6=0&&PORTB.7=1THEN

    GOTONUMBEREIGHT

    ENDIF

    IFPORTB.4=1&&PORTB.5=0&&PORTB.6=0&&PORTB.7=1THENGOTONUMBERNINE

    ENDIF

    IFPORTB.4=0&&PORTB.5=1&&PORTB.6=0&&PORTB.7=1THEN

    GOTONUMBERSTAR

    ENDIF

    IFPORTB.4=1&&PORTB.5=1&&PORTB.6=0&&PORTB.7=1THEN

    GOTONUMBERZERO

    ENDIF

    IFPORTB.4=0&&PORTB.5=0&&PORTB.6=1&&PORTB.7=1THEN

    GOTONUMBERPOUND

    ENDIF

    ENDIF

    Cnt=Cnt+1

    IFCnt>254THENCnt=2 ' Set Cnt = 2 to avoid re-writing the same menu message to the LCD more than once

  • 8/14/2019 Final Report03

    40/54

    39

    GOTOLCDFUN

    NUMBERONE:

    Lcdout $FE,1,"#1: TEST PATTERN"

    PAUSE2000

    Lcdout $FE,1,"#1: TEST PATTERN", $FE, $C0,"DURATION: 1:00 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERTWO:

    Lcdout $FE,1,"#2: LEGEND OF ZELDA"

    PAUSE2000

    Lcdout $FE,1,"#2: LEGEND OF ZELDA", $FE, $C0,"DURATION: 1:04 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERTHREE:

    Lcdout $FE,1,"#3: GREENSLEEVES"

    PAUSE2000

    Lcdout $FE,1,"#3: GREENSLEEVES", $FE, $C0,"DURATION: 0:25 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERFOUR:

    Lcdout $FE,1,"#4: CHICKEN DANCE"

    PAUSE2000

    Lcdout $FE,1,"#4: CHICKEN DANCE", $FE, $C0,"DURATION: 0:16 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERFIVE:

    Lcdout $FE,1,"#5: SMALL WORLD"

    PAUSE2000

    Lcdout $FE,1,"#5: SMALL WORLD", $FE, $C0,"DURATION: 0:13 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERSIX:

    Lcdout $FE,1,"#6: TEQUILA"

    PAUSE2000Lcdout $FE,1,"#6: TEQUILA", $FE, $C0,"DURATION: 0:18 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERSEVEN:

    Lcdout $FE,1,"#7: HALL OF MNT KING"

    PAUSE2000

    Lcdout $FE,1,"#7: HALL OF MNT KING", $FE, $C0,"DURATION: 0:37 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBEREIGHT:

    Lcdout $FE,1,"#8: TAPS"

    PAUSE2000

    Lcdout $FE,1,"#8: TAPS", $FE, $C0,"DURATION: 0:15 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERNINE:

    Lcdout $FE,1,"#9: REVEILLE"

    PAUSE2000

    Lcdout $FE,1,"#9: REVEILLE", $FE, $C0,"DURATION: 0:18 - ENJOY"

    PAUSE2000

    Lcdout $FE,1

    Cnt=1

    PAUSE10

    GOTOLCDFUN

  • 8/14/2019 Final Report03

    41/54

    40

    'AUTOMATIC MODENUMBERSTAR:

    Lcdout $FE,1,"YOU HAVE SELECTED AUTO"

    PAUSE2000

    Lcdout $FE,1,"ENTERING AUTOMATIC MODE"

    PAUSE2000

    Lcdout $FE,1,"TAKING IN READING FROM", $FE, $C0,"LIGHT SENSOR"

    Cnt=1

    GOTOAUTOMATIC

    NUMBERZERO:Lcdout $FE,1,"YOU HAVE SELECTED 0"

    PAUSE2000

    Lcdout $FE,1,"HAVE A NICE DAY,", $FE, $C0,"MECHATRONICS WARRIOR"

    PAUSE2000

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    NUMBERPOUND:

    Lcdout $FE,1,"YOU HAVE SELECTED #"

    PAUSE2000

    Cnt=1

    PAUSE10

    GOTOLCDFUN

    AUTOMATIC:

    ' WAIT UNTIL THE LIGHT READING HAS BEEN MEASURED AND THEN EXIT AUTOMATIC MODEIFPORTB.4=0&&PORTB.5=1&&PORTB.6=0&&PORTB.7=1THEN

    Lcdout $FE,1,"EXITING AUTOMATIC MODE"

    PAUSE2000

    Cnt=1GOTOLCDFUN

    ENDIF

    GOTOAUTOMATIC

  • 8/14/2019 Final Report03

    42/54

    41

    '//////////////////////////////////////////////////////////////////////////////

    '' LIGHT SENSOR A/D CONVERSION - A/D MODULE FOR AUTICA

    ' ==============================================================' Date: November 27, 2008' Author: Ryan Sullenberger

    ' Group: 42 (R2D2)' Colorado State University, Mechanical Engineering

    '' PIC16F88'

    '//////////////////////////////////////////////////////////////////////////////

    ' PicBasic Pro program to display result of' 8-bit A/D conversion on LCD'' Connect analog input to channel-0 (RA0)

    DEFINEOSC8

    OSCCON.4=1 'Sets the internal oscillator frequency to 8 MHz

    OSCCON.5=1

    OSCCON.6=1

    adval var byte ' Create adval to store result

    ADCON1=%00000010 ' Set PORTA analog and LEFT justify result

    ADCON0=%11000001 ' Configure and turn on A/D Module

    Pause50 ' Wait .05 second

    adconvert: ADCON0.2=1 ' Start Conversion

    notdone:Pause5

    IfADCON0.2=1ThenGOTOnotdone ' Wait for low on bit-2 of ADCON0, conversion finished

    adval=ADRESH ' Move high byte of result to adval

    IFadval

  • 8/14/2019 Final Report03

    43/54

    42

    Excel Music Spreadsheet

  • 8/14/2019 Final Report03

    44/54

    43

  • 8/14/2019 Final Report03

    45/54

    44

  • 8/14/2019 Final Report03

    46/54

    45

  • 8/14/2019 Final Report03

    47/54

  • 8/14/2019 Final Report03

    48/54

    47

  • 8/14/2019 Final Report03

    49/54

    48

  • 8/14/2019 Final Report03

    50/54

    49

  • 8/14/2019 Final Report03

    51/54

    50

  • 8/14/2019 Final Report03

    52/54

    51

  • 8/14/2019 Final Report03

    53/54

    52

  • 8/14/2019 Final Report03

    54/54