There's a limit to how many characters can be in a picaxe command line. The number of bytes needed for Simple Gifts exceeded the allowed line length.Why did you use only one poke statement in " twinkle" and 3 in " simple gifts"?
I think it's around 128 characters in a line, maybe 127.I see! And what is the limit?
Right.That would include commas and spaces and everything correct?
I counted the bytes which were poked in the previous poke. That gave me the location for the next one.Why did you select poke 56, 90, and 112?
I recall it's over 1000 these days. Probably 1023 or 1024 including CR-LF line endings.I think it's around 128 characters in a line, maybe 127.I see! And what is the limit?
Short on C.0 to ground should not cause it to run through. Short high or pulled high on either C.0 or C.1 would.When we load Twinkle (post 282) on the 40X2 the LEDs do not wait for the hammer strike but run through the whole sequence.
Any ideas!??
EDit, Appears to have a sodering short to ground on pin C.0.............
I got an error when I first tried to poke the whole of "Simple Gifts". I just assumed it was line length. I'll try again--it would certainly be easier if one POKE statement could do the whole thing.I recall it's over 1000 these days. Probably 1023 or 1024 including CR-LF line endings.
' 28SimpleGifts
#picaxe 28x2
symbol _D=B.1
symbol E=B.2
symbol Fs=B.3
symbol G=B.4
symbol _A=B.5
symbol _B=B.6
symbol _C=B.7
symbol DD=B.0
' Twinkle, Twinkle, Little Star
'poke 56,_D,_D,_A,_A,_B,_B,_A, G,G,Fs,Fs,E,E,_D, _A,_A,G,G,Fs,Fs,E, _A,_A,G,G,Fs,Fs,E, _D,_D,_A,_A,_B,_B,_A, G,G,Fs,Fs,E,E,_D, $ff
' Simple Gifts
poke 56,_D,_D,G,G,_A,_B,G,_B,_C,DD,DD,_C,_B,_A,G,_A,_A,_A,G,_A,_B,_A,Fs,_D,_D,G,Fs,G,_A,_B,_C,DD,_B,_A,G,_A,_A,_B,_B,_A,G,G,G,G,DD,_B,_A,_B,_C,_B,_A,G,_A,_B,_B,_C,DD,_A,_A,_B,_A,_D,G,G,_A,_B,_B,_C,DD,_C,_B,_A,_A,_B,_B,_A,G,G,G,$FF
bptr=56 ' above top named variable
do : high @bptr : Do : Loop Until pinC.0 = 1 or pinC.1 = 1 : low @bptrinc : Pause 100 : loop until @bptr = $ff
Excellant!We're assuming both of the input pins must each have a 1k and 10k resister installed as described in Manual 3. Correct?
Edit: Installed resisters as instructed. Inputs are now working properly!
' 40ABC_reader ' plays tune from ABC musical notation
' see here for abc:
' http://abcnotation.com/wiki/abc:standard:v2.2#the_tune_body
#picaxe 40x2
symbol pPiezo=A.4
'RAY 1
symbol _D6=A.7
symbol _C6=C.2
symbol _B5=A.6
symbol _A5=D.1
symbol _G5=D.3
symbol _Fs5=A.3
symbol _E5=C.7
symbol _D5=C.6
symbol _Cs5=A.2
symbol _B4=D.4
symbol _A4=D.2
symbol _Gs4=A.1
'RAY 2 Excluding duplicates
symbol _F5=A.0
symbol _C5=C.5
symbol _G4=D.5
symbol _Fs4=B.7
symbol _E4=D.7
symbol _D4=D.6
symbol _Cs4=B.6
'RAY 3 Excluding duplicates
symbol _Bb4=B.5
symbol _F4=B.4
symbol _C4=B.3
symbol _B3=B.2
symbol _A3=B.1
symbol _G3=B.0
'abc note designation starting with G below treble clef:
'G, A, B, C D E F G A B c d e f g a b c' d'
' additional commas go lower, e.g. "G,,", additional quotes go higher
symbol eeloc=b3 ' eeprom location
symbol abcCh=b4 ' abc notation character
symbol key=b5 ' abc notation character
symbol abcNote=b6 ' abc notation note
symbol abcNoteNo=b7 ' abc notation note number out of "ABCDEFGabcdefg"
symbol octave=b8 '
symbol abcDuration=b9 ' abc note duration: 2=1/4;3=3/8;4=1/2;6=3/4;8=whole
' note picaxe tune only supports 1/8, 1/4, 1/2, 1
symbol note=b10 ' coded for picaxe tune command: duration:octave:note
symbol scratch=b11 '
symbol noteCount=b12 '
' Simple Gifts
' write tune in ABC notation to eeprom
data 0,("K:G D2D2|G4G2A2|B2G2B2c2|d4d2c2|B4A2G2|A4A4|A4G4|A2B2A2F2|D4D4|G2D2G2A2|B4B2c2|d4d2c2|B4A2G2|A4A2A2|B4B2A2|G4G3A|G8||d8|B6A2|B3cB2A2|G6A2|B4B2c2|d4c2B2|A4A2B2|A4D2D2|G4G2A2|B4B2c2|d4d2c2|B4A2G2|A4A4|B4B2A2|G4G4|G4|ZZZ")
eeloc = 0 ' first eeprom location
read eeloc,abcCh
if abcCh = "K" then ' key designation; if absent, assume "D"
eeloc = eeloc + 2 ' skip colon
read eeloc,key
inc eeloc
read eeloc,abcCh ' first note of tune
endif
do
sertxd(abcCh)
if abcCh = " " or abcCh = "|" then ' skip white space
else ' process character
' lookdown abcCh,("ABCDEFGabcdefg"),abcNoteNo
lookdown abcCh,("CDEFGABcdefgab"),abcNoteNo ' abc encoding
if abcNoteNo > 0 then ' it's a note
abcNote = abcCh
inc eeloc
read eeloc,abcCh ' possible octave shift
inc eeloc
if abcCh = "," or abcCh = "'" then ' octave is shifted up/down
else
abcCh = ""
dec eeloc ' move back to read possible next note or duration
endif
if key <> "Z" then ' (all keys)
' for hammer dulcimer, shift everything down one octave
if abcNoteNo > 6 then
octave = 6 ' picaxe middle octave
if abcCh = "'" then : octave = 7 : endif ' octave is shifted up
' note was lower case--make upper
if abcNote > "Z" then : abcNote = abcNote - 32 : endif
else
octave = 5 ' picaxe low octave
endif
else
endif
read eeloc,abcDuration ' possible duration--default is 1/16th
if abcDuration = "2" or abcDuration = "3" or abcDuration = "4" or abcDuration = "6" then
else
abcDuration = ""
dec eeloc ' move back to read possible next note
endif
gosub playnote
endif ' end of "we found a note"
endif
inc eeloc
read eeloc,abcCh ' next note of tune
loop until abcCh = "Z" ' end of tune
end
playnote:
inc noteCount
if noteCount = 21 then
pause 1 '' break simulation here
endif
scratch = abcNote - "A" ' convert to 0-7 for ABCDEFG
' A B C D E F G
lookup scratch,(9,11,0,2,4,5,7),note
select key ' "C" = no sharps
case "D" ' two sharps
if abcNote = "F" or abcNote = "C" then : inc note : endif
case "G" ' one sharp
if abcNote = "F" then : inc note : endif
case "A" ' three sharps
if abcNote = "F" or abcNote = "C" or abcNote = "G" then : inc note : endif
endselect
select octave
case 5 : note = note + %00100000 ' picaxe low octave
case 6 : note = note + %00000000 ' picaxe middle octave
case 7 : note = note + %00010000 ' picaxe high octave
endselect
select abcDuration
case "" : note = note + %01000000 ' 1/8
tune pPiezo,8,(note)
case "2" : note = note + %00000000 ' 1/4
tune pPiezo,8,(note)
case "3" : note = note + %00000000 ' 3/8: 1/4 + 1/8
tune pPiezo,8,(note)
note = note + %01000000 ' 1/8
tune pPiezo,8,(note)
case "4" : note = note + %11000000 ' 1/2
tune pPiezo,8,(note)
case "6" : note = note + %00000000 ' 3/4: 1/4 + 1/2
tune pPiezo,8,(note)
note = note + %11000000 ' 1/8
tune pPiezo,8,(note)
case "1" : note = note + %10000000 ' 1
tune pPiezo,8,(note)
endselect
return
Another alternative is some mobile phone Ring Tone format. The advantage being that there are hundreds of those available, in RTTTL formats and others.The best way to have a large, maybe huge, number of tunes available would be to implement an "abc" notation reader on the picaxe.
Back when this thread began I looked at the ring tone format and (some of) the hundreds/thousands of tunes available. I did not see that there was a good fit between the kinds of tunes available--which, even when what might be wanted were often truncated--and what would be likely to be played on a hammered dulcimer.Another alternative is some mobile phone Ring Tone format. The advantage being that there are hundreds of those available, in RTTTL formats and others.
But ... but ... my practice seems to be, "code first, think later".... might be worth taking a brief step back
I wasn't aware of 'abc' notation but I have to admit you've convinced me.On the other hand, the abc notation is widely and actively used by thousands of players of guitar, fiddle, banjo, mandolin, recorder--it is used by performing musicians.
The POKE statement is used to put bytes of data into a location or a string of locations in the RAM memory of the picaxe (this is volatile memory--the contents are lost if you power-cycle or reprogram). The 28X2 and 40X2 have 255 bytes of RAM memory, as explained in the "Variables - Storage" section of Manual 2. This includes the "General", or named variables, b0-b55, which occupy ram locations 0-55.Could you elaborate some more on how pokes are used?
' 20tune
#picaxe 40x2 '20M2
#no_data
'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16)
'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
'tune 5, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$11,$D1,$4B,$0B)
' omit following line for full tune
''tune 5, 8,($44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$10,$10,$4B,$0B)
'tune 5, 8,($51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2,$49,$51,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)
'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
'tune 5, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2,$49,$51,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)
' Ashokan Farewell
sertxd(cr,lf,"Ashokan Farewell",cr,lf)
tune C.7, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
tune C.7, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2)
tune C.7, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
tune C.7, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)
' Temperance Reel
'sertxd(cr,lf,"Temperance Reel",cr,lf)
'tune C.7, 8,($42,$44,$46,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$52,$49,$46,$07)
'tune C.7, 8,($42,$44,$46,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$C7)
'tune C.7, 8,($4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$49,$52,$52,$54,$12,$52,$54,$56,$52,$59,$56,$57,$56,$54,$52,$4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$4B,$49,$47,$46,$44,$46,$47,$49,$4B,$52,$49,$46,$C7)
'tune C.7, 8,($4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$49,$52,$52,$54,$12,$52,$54,$56,$52,$59,$56,$57,$56,$54,$52,$4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$4B,$49,$47,$46,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42)
Hunting the Snark." Snark super tight all instrument tuner."
Ah, got it. Again, no connection to "+" I think, "-" to 0V, "S" to picaxe ADC pin. For testing, read the pin repeatedly and display the result--maybe 10 times a second. Determine empirically when a note has been struck. The piezo has to be well attached to a vibrating surface on the hammer dulcimer. (At least, on a guitar, they are glued/adhered to the guitar top near the sound hole.)... We want to use the Piezo as an input
do
readadc pinno, b1
sertxd(#b1," ")
pause 100
loop