Computer Engineering Activities Interfacing Music Box Project ACSE 2004

52
Computer Engineering Computer Engineering Activities Activities Interfacing Interfacing Music Box Project Music Box Project ACSE 2004 ACSE 2004 Graham Smyth Graham Smyth

description

Computer Engineering Activities Interfacing Music Box Project ACSE 2004. Graham Smyth. Computer Engineering Units. Grade 10/11/12 1. Hardware 2. Networking 3. Integrated Circuits 4. Programming 5. Interfaces. Interfacing Activities. Grade 10 One bit Three LEDs - PowerPoint PPT Presentation

Transcript of Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Page 1: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Computer Engineering Computer Engineering ActivitiesActivities

InterfacingInterfacing

Music Box ProjectMusic Box Project

ACSE 2004ACSE 2004Graham Smyth Graham Smyth

Page 2: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Computer Engineering UnitsComputer Engineering Units

Grade 10/11/12

1. Hardware1. Hardware

2. Networking2. Networking

3. Integrated Circuits3. Integrated Circuits

4. Programming4. Programming

5. 5. InterfacesInterfaces

Page 3: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Interfacing ActivitiesInterfacing Activities

Grade 10• One bit• Three LEDs• LED simulators• ASCII• Binary counting• Light patterns• Intersections• AC ???

Grade 11• One bit• One byte• DC motor• Bi-directional • LED traffic light• LED intersection• Demultiplexer• GUIs• Mouse control• AC ??

Page 4: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Interfacing ActivitiesInterfacing ActivitiesGrade 12• One byte• LED intersection• Stop Lights AC?• Vehicles• Security systems• Drag strips• Music Box• Latches• Marquees• GUIs/Mouse Control

Page 5: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Introduction to Traffic Lights Introduction to Traffic Lights

Page 6: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Traffic Lights Traffic Lights

Page 7: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Traffic Lights Traffic Lights

Page 8: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Introduction to MotorsIntroduction to Motors

Page 9: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

MotorsMotors

Page 10: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Introduction to Music Introduction to Music

Page 11: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music BoxMusic Box

Note indicator Light Note push button

Page 12: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music: Pipe OrganMusic: Pipe Organ

Page 13: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Breadboard ConnectionsBreadboard Connections

Connected

Connected

HighFives

DividerLowFives

Page 14: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box SoftwareMusic Box Software

Turing

• parallelput(number) - reads 8 pins• put parallelget - reads 5 pins• mousewhere(x,y,click)• play(“CDEFG”)• drawline(x1,y1,x2,y2,red)• FREE!!!

Page 15: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Computer Computer Interface Peripheral Interface Peripheral

Interfacing SystemInterfacing System

Unit 5

• Parallelport • Wires• ICs• Resistors• Capacitors• Transistors

• LED's• Motors• Lights• Robots• Music Box •Joysticks

Wires Wires

Page 16: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box HardwareMusic Box Hardware

• Five male pins • One D sub connector • Cable 1 – D sub to Breadboard• Four N.O. pushbuttons

• Four Resistors (Brown/Black/Orange)• One Breadboard• Extra wire• Enhancement hardware ????

Page 17: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Hardware - ResistorMusic Box Hardware - Resistor(Four Required)

Brown Black Orange Gold

1 0 X 103

Tolerance+-5%

Page 18: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Resistor ChartResistor Chart

BAND 1 BAND 2 BAND 3 BLACK 0 0 1 BROWN 1 1 10

RED 2 2 100 ORANGE 3 3 1 000 YELLOW 4 4 10 000 GREEN 5 5 100 000 BLUE 6 6 1 000 000

VIOLET 7 7 10 000 000 GRAY 8 8 100 000 000 WHITE 9 9 1 000 000 000

Page 19: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Hardware Music Box Hardware Cable: D sub to BreadboardCable: D sub to Breadboard

Male Pin Insulated Wire

Large Crimp Tab Stripped Wire

Small Crimp Tab

Page 20: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

3 Pair Cable3 Pair Cable

White/Green

Green/ White

Orange/ White

White/Orange Blue/ WhiteWhite/ Blue

Page 21: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Cable with Male PinsCable with Male Pins

Page 22: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Hardware:Music Box Hardware:Normally Open SwitchNormally Open Switch

1

2

1 2

Physical Schematic

Page 23: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Inputting DataInputting Data

Page 24: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Hardware : Music Box Hardware : ParallelportParallelport

View from View from backback of Computer of Computer

13 12 11 10 9 8 7 6 5 4 3 2 1

25 24 23 22 21 20 19 18 17 16 15 14

OutputD0 – D7

InputI0 – I3

Input I4 Grounds18 - 25

Page 25: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub Connector /HarnessD Sub Connector /Harness

Page 26: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub Connector Colour Code D Sub Connector Colour Code

Pin Pin ##

ColourColour

22 White/ GreenWhite/ Green

1010 Green/ WhiteGreen/ White

1111 Orange/ WhiteOrange/ White

1212 White/ OrangeWhite/ Orange

1313 Blue/ WhiteBlue/ White

1818 White/ BlueWhite/ Blue

Page 27: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub ConnectorD Sub Connector

Pin 2

Pin 18

D sub Connector

Pin 10

Page 28: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub ConnectorD Sub Connector

Check

Pin 2

Bottom, 2 Down

Page 29: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub ConnectorD Sub Connector

Total of six wires from D sub connector

Pin 2, Bottom, 2 Down

Pin 18, Top, 5 Down

Pin 10, Bottom, 10 Down

Pin 11

Pin 12

Pin 13

Check

Page 30: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

BreadboardBreadboard

Switches Span Divider

Page 31: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Breadboard with ResistorsBreadboard with Resistors

Resistors to Top Rail

Brown/Black/Orange

Align

Page 32: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub to Breadboard Cable D Sub to Breadboard Cable To Pin 2

White/Green

To Pin18 White/Blue

Four Wires

Switch to Ground

Page 33: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

D Sub to Breadboard Cable D Sub to Breadboard Cable

Pin18 White/Blue

Pin 2White/Green

Pin 10Green/ White

Pin 11Orange/ White

Pin 12White/Orange

Pin 13Blue/ White

Page 34: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

The hardware is complete.The hardware is complete.

Now to the software Now to the software

Page 35: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 1Assignment 1

Write a program that will continuously scan for input values from the MUSIC BOX.

Page 36: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box SoftwareMusic Box SoftwareAssignment 1Assignment 1

parallelput(1)loop % Start of infinite loop. put parallelget % Returns input pin values.end loop % End of loop.

Page 37: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Note MatrixMusic Box Note Matrix

Switch Note Parallelget Value

1 C

2 D

3 E

4 G

Remember these Numbers

Page 38: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 2Assignment 2

Write a program that will play the notes “CDEG” each as quarter notes.

Page 39: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 2Assignment 2

parallelput(1)var value : intloop

value := parallelgetif value = ______ then

play (“C”)elsif value = _____ then

play (“D”)

EtcSave as MusicBox2

Page 40: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 3Assignment 3

Write a program that will play the notes “CDEG” each as quarter notes and at the same time display a GUI representing the played notes.

Page 41: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Adding Graphics ScreenAdding Graphics Screen

(0,0)

(640,400)

Page 42: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 3: A GUI Assignment 3: A GUI part 1part 1

locatexy (300, 300)locatexy (300, 300)put "MUSIC BOX PLAYER"put "MUSIC BOX PLAYER"locatexy (200, 140)locatexy (200, 140)put "C D E G"put "C D E G"% drawing 4 circles with perimeter black% drawing 4 circles with perimeter blackdrawoval (200, 200, 40, 40, black)drawoval (200, 200, 40, 40, black)drawoval (300, 200, 40, 40, black)drawoval (300, 200, 40, 40, black)drawoval (400, 200, 40, 40, black)drawoval (400, 200, 40, 40, black)drawoval (500, 200, 40, 40, black)drawoval (500, 200, 40, 40, black)

Page 43: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 3: A GUI Assignment 3: A GUI part 2part 2

% filling 4 circles with white% filling 4 circles with white

drawfilloval (200, 200, 40, 40, white, black)drawfilloval (200, 200, 40, 40, white, black)

drawfilloval (300, 200, 40, 40, white, black)drawfilloval (300, 200, 40, 40, white, black)

drawfilloval (400, 200, 40, 40, white, black)drawfilloval (400, 200, 40, 40, white, black)

drawfilloval (500, 200, 40, 40, white, black)drawfilloval (500, 200, 40, 40, white, black)

Page 44: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 3: A GUIAssignment 3: A GUI part 3part 3

parallelput(1)var value : intloop

value := parallelgetif value = ______ then

% fills “C” GUI with red drawfilloval (200, 200, 40, 40, red, black)drawfilloval (200, 200, 40, 40, red, black)

% plays C for a quarter noteplay “C”% sets “C” GUI back to whitedrawfilloval (200, 200, 40, 40, white, black)drawfilloval (200, 200, 40, 40, white, black)

Page 45: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 3: A GUIAssignment 3: A GUI part 4part 4

elsif value = _____ then

% fills “D” GUI with red

drawfilloval (300, 200, 40, 40, red, black)drawfilloval (300, 200, 40, 40, red, black)

play “D”

% sets “D” GUI back to white

drawfilloval (300, 200, 40, 40, white, black)drawfilloval (300, 200, 40, 40, white, black)

Similarly for notes E and GSave as MusicBox3Save as MusicBox3

Page 46: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box TuneMusic Box TuneMary Had a Little

Save as MusicBox4Save as MusicBox4

Mary had a little lambE D C D E E E restLittle lambD D D restLittle lambE G G restMary had a little lambE D C D E E E restWhose fleece was white as snowE D D E D C

Page 47: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music TheoryMusic Theory play (“8CDEFGAB>C”) – plays one octave play (“8CDEFGAB>C”) – plays one octave

of 8of 8thth notes from middle C notes from middle C play(“<BAGFEDC”) – plays scale in reverse play(“<BAGFEDC”) – plays scale in reverse

in 8in 8thth notes if it follows previous line notes if it follows previous line play (“>4CDEFGAB”) – plays one octave of play (“>4CDEFGAB”) – plays one octave of

quarter notes one octave up from middle Cquarter notes one octave up from middle C play (">6CpC+pC-") – plays one octave up play (">6CpC+pC-") – plays one octave up

from middle C, a C 16from middle C, a C 16thth note, a rest, C note, a rest, C sharp, a rest, and a C flatsharp, a rest, and a C flat

play(“1C2C4C6C”) – plays whole, half, play(“1C2C4C6C”) – plays whole, half, quarter, and 16quarter, and 16thth C note C note

Page 48: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 4Assignment 4

Write a program that will:• play a tune • display a GUI of the notes being played• change the colour of the note name.

Save as MusicBox5Save as MusicBox5

Page 49: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Music Box Software Music Box Software Assignment 5Assignment 5

Write a program that will automatically play “Mary Had a Little Lamb”.

Save as MusicBox6Save as MusicBox6

Page 50: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

Additional Music Box Additional Music Box Software Software

Additions• Add an LED above each key on the keyboard• Add additional keys to the keyboard• Store a tune• Test a users ability to replay the tune

Page 51: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

More Hands-On ActivitiesMore Hands-On Activities

• Keyboard• Intersection• Robot• World’s Largest Joystick

Page 52: Computer Engineering Activities Interfacing Music Box Project ACSE 2004

AddressesAddresses

[email protected]

www.classictechnology.ca

www.holtsoft.com