PICAXE + FDD for Musical FDD?

SolidWorksMagi

Senior Member
Hi,

I got the basic control of the FDD down ... but now I need to figure out how to create musical tones with the FDD head movements. Any ideas on the loop needed for middle C?


RoboGuts + FDD + Thoughts a 531 Byte BASIC Language Program



' PICAXE+FDD+Thoughts.bas

#picaxe 28x2

' FDD IDE 34-PIN Connector
' ==============================================================================
' PIN Number: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34
' Control I/O [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
' All GND [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
' PIN Number: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33
' ==============================================================================

' Note Pitch Numerics after Testing;
' Note00 = 7 = Highest Usable Pitch
' Note01 = 8
' Note02 = 9
' Note03 = 10
' Note04 = 11
' Note05 = 12
' Note06 = 13
' Note07 = 14
' Note08 = 15
' Note09 = 16
' Note10 = 17
' Note11 = 18
' Note12 = 19
' Note13 = 20
' Note14 = 21
' Note15 = 22
' Note16 = 23
' Note17 = 24
' Note18 = 25 = Lowest Usable Pitch

' Thoughts =
' 9,9,-,9-,7,7,8-,9-
' 12,12,-,12,10,10,11-,12-
' 13,13,-,13,11,11,12-13-
' 9,9,-,9-,7,7,8-,9-
' 7-,9-,11-,12-

' BEGIN Declare and Initialize Variables * * * * * * * * * * * * * * *
' Drive Select PIN 12 on FDD Grounded to "select" the FDD
Symbol StepPin1 = B.0 ' Step PIN 20 on FDD Select GND to move FDD R/W Head
Symbol Direction1 = B.1 ' Direction PIN 18 on FDD Select +V or GND for direction

Symbol StepPin2 = C.0 ' Step PIN 20 on FDD Select GND to move FDD R/W Head
Symbol Direction2 = C.1 ' Direction PIN 18 on FDD Select +V or GND for direction

symbol pitch = b0 ' Pause Counter to determine Note Frequency
symbol Steps = b1 ' 0 - 79 to find greatest distance available

symbol i = b3 ' For/Next Counter to determine Note Duration

symbol RLED = B.7
symbol GLED = B.6
symbol BLED = B.5

' END Declare and Initialize Variables * * * * * * * * * * * * * * * *
' Begin Main Body * * * * * * * * * * * * * * *
Steps = 79 ' Note Duration
Pitch = 7 ' Note Pitch
low Direction2 ' Move Head OUT
gosub NoteFDD2
pause 500
Steps = 79 ' Note Duration
Pitch = 7 ' Note Pitch
high Direction2 ' Move Head IN
gosub NoteFDD2
'pause 250
'Steps = 79 ' Note Duration
'Pitch = 7 ' Note Pitch
'low Direction2 ' Move Head OUT
'gosub NoteFDD2

pause 1000

do
gosub Verse1
pause 500
gosub Verse2
pause 500
gosub Verse3
pause 500
gosub Verse1
gosub Verse4
pause 3000
loop
' END Main Body * * * * * * * * * * * * * * * *
end
' Begin Subroutines * * * * * * * * * * * * * * *
' Begin Music Subroutine * * * * * * * * * * * * * * *

' Thoughts =
Verse1:
Steps = 19 ' Note Duration
Pitch = 15 ' Note Pitch
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 15
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 150
Steps = 29
Pitch = 15
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 12
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 50
Steps = 9
Pitch = 12
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 49
Pitch = 14
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 150

Steps = 79
Pitch = 15
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 500
return

Verse2:
Steps = 19 ' Note Duration
Pitch = 12 ' Note Pitch
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 12
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 150
Steps = 29
Pitch = 12
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 8
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 50
Steps = 9
Pitch = 8
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 49
Pitch = 10
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 150

Steps = 79
Pitch = 11
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 500
return

Verse3:
Steps = 19 ' Note Duration
Pitch = 10 ' Note Pitch
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 10
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 150
Steps = 29
Pitch = 10
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 19
Pitch = 7
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 50
Steps = 9
Pitch = 7
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 50
Steps = 49
Pitch = 9
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 150

Steps = 79
Pitch = 10
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 500
return

Verse4:
Steps = 49
Pitch = 8
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 250

Steps = 49
Pitch = 10
high Direction1 ' Move Head IN
gosub NoteFDD1
pause 250

Steps = 49
Pitch = 13
low Direction1 ' Move Head OUT
gosub NoteFDD1
pause 250

Steps = 79
Pitch = 15
high Direction1 ' Move Head IN
gosub NoteFDD1
return

' END Music Subroutine * * * * * * * * * * * * * * * *
' Begin Note Subroutines * * * * * * * * * * * * * * *
NoteFDD1:
gosub red
for i = 0 to Steps ' Note Duration 79 = Whole Note, 39 = Half Note, 19 = Quarter Note, 9 = Eighth Note, 5 = Sixteenth Note
high StepPin1
pause Pitch ' Note Frequency using a relative scale: 20 = C
low StepPin1
next i
gosub LEDsOFF
return

NoteFDD2:
gosub blue
for i = 0 to Steps ' Note Duration 79 = Whole Note, 39 = Half Note, 19 = Quarter Note, 9 = Eighth Note, 5 = Sixteenth Note
high StepPin2
pause Pitch ' Note Frequency using a relative scale: 20 = C
low StepPin2
next i
gosub LEDsOFF
return
' END Note Subroutines * * * * * * * * * * * * * * * *
end
' Begin LED Subroutines * * * * * * * * * * * * * * *
LEDsOFF:
high RLED
high GLED
high BLED
return

red:
low RLED
high GLED
high BLED
return

green:
high RLED
low GLED
high BLED
return

blue:
high RLED
high GLED
low BLED
return

pink:
low RLED
high GLED
low BLED
return

teal:
high RLED
low GLED
low BLED
return
' END LED Subroutines * * * * * * * * * * * * * * * *
' END Subroutines * * * * * * * * * * * * * * * *
end




Lessons how to use various Electronic Components, Structured Computer Programming, Phonemes for Speech &Song in any language, and Art (3D Printing, Finishing, Painting.)

RoboGuts™ Intelligent content for 3D printing, a S.T.E.A.M. Education Program http://www.r2pv1.com/
 
Last edited:
Top