Shop OBEX P1 Docs P2 Docs Learn Events
Guitar turner circuit — Parallax Forums

Guitar turner circuit

mattm_nsccmattm_nscc Posts: 13
edited 2011-11-19 15:45 in Learn with BlocklyProp
Hello, i am doing a school project and part of it is to build a guitar turner circuit. I have found a thread on this fourm a while back about it and ive attahed the circuit and code below. My questions are, do you think it would be hard to modify the code so it out puts the the LCD and if i went the LCD route would i still need the shift registors ?
thanks Matt M


' TechnoRobbbo's Electric Guitar Tuner V2.0
' {$STAMP BS2}
' {$PBASIC 2.5}
'

'Declarations
tuneTmp VAR Word 'Tuning scratch pad
LoLim VAR Word 'Note Low Limit
HiLim VAR Word 'Note High Limit
tunePos VAR Word 'Note Accuracy 5 = in tune
result VAR Byte 'Look up variable
Note VAR Byte 'LED Note Image
WaveLen VAR Word 'Wave Length BS2 Timing
Zero VAR Word

'Constants and equates
GPin CON 0 'Sound input
DPin CON 3 'Display Data Pin
LPin CON 2 'Display Latch Pin
CPin CON 1 'Clock Pin

'initialize
OUTPUT 4
OUTPUT 5
LOW LPin

SHIFTOUT DPin,CPin,MSBFIRST,[0\16]
PULSOUT LPin,3
'

Main:
DO
'sum 5 full cycles of wavelength
WaveLen=0

PULSIN GPin,1,Wavelen
'18181
IF WaveLen<18182 AND WaveLen>275 THEN
DO WHILE WaveLen>4595
WaveLen=WaveLen>>1
LOOP
ELSE
Wavelen=0
Zero=0
ENDIF

'get index and target - BS2 Timing
IF WaveLen>0 THEN
result=0
LOOKDOWN WaveLen,>=[4416,4168,3934,3713,3505,3308,3122,2947,2781,2625,2478,2339,2208,2084,1967,1856,1752,1654,1561,1473,1390,1312,1239,1169,1104,1042,983,928,876,827,780,736,695,656,619,584,552,521,491,464,438,413,390,368,347,328,309,292,276],result


IF Zero.HIGHBYTE=Zero.LOWBYTE AND Zero.HIGHBYTE=result THEN
Zero=Zero<<8 + result
'Get LED Image
LOOKUP (result//12),[245,253,55,99,107,151,159,115,113,121,246,254],Note

'get limits and calculate tuning position
LOOKUP result,[4677,4415,4167,3933,3712,3504,3307,3121,2946,2780,2624,2477,2338,2207,2083,1966,1855,1751,1653,1560,1472,1389,1311,1238,1168,1103,1041,982,927,875,826,779,735,694,655,618,583,551,520,490,463,437,412,389,367,346,327,308,291],HiLim
LOOKUP result,[4416,4168,3934,3713,3505,3308,3122,2947,2781,2625,2478,2339,2208,2084,1967,1856,1752,1654,1561,1473,1390,1312,1239,1169,1104,1042,983,928,876,827,780,736,695,656,619,584,552,521,491,464,438,413,390,368,347,328,309,292,276],LoLim

'slow down display

tuneTmp = HiLim-LoLim
tuneTmp = (HiLim-WaveLen) * 10 /tuneTmp MAX 9
tunepos=DCD tuneTmp
'Ouput to Display
OUT4=tunepos.LOWBIT(0) 'output extra LEDs
OUT5=tunepos.LOWBIT(1)
tunepos=tunepos >> 2
SHIFTOUT DPin,CPin,MSBFIRST,[Note\8,tunepos.LOWBYTE\8] 'output to daisy chain
PULSOUT LPin,3 'latch display
else
Zero=Zero<<8 + result
ENDIF
ENDIF
LOOP
END
768 x 614 - 78K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-17 09:41
    In the guitar tuner you've shown, the Stamp deals with LEDs directly, lighting segments of a 7-segment display and what looks like a bar display. It uses SHIFTOUT and PULSOUT to control a couple of 74HC595 serial shift registers to get around limitations on the number of I/O pins available. If you use a serial LCD display, you avoid all that. You'd have to discard all the display code and rewrite it for the serial LCD since you're no longer dealing with individual LEDs and you're dealing with characters on a text display (unless you want to use a serial graphics LCD). A serial LCD expects asynchronous serial characters, so you'd use the SEROUT statement which works differently.
  • mattm_nsccmattm_nscc Posts: 13
    edited 2011-11-17 11:24
    thank you for the reply.... so your saying i can toss the shift registors and rewrite the code that starts with " 'slow down display" ?.. but the rest of the code still should be good still though eh ?

    thanks Matt M
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-17 11:44
    You do need to keep the op-amp and the decade counter. I believe this counts the zero crossings of the waveform wrapping around the count every 3 cycles (6 half cycles). There's a pulse put out on half cycles 1 and 2 (counting from 0) and the Stamp measures the width of this pulse to get the wavelength of the signal. So yes, you can toss the shift registers (and the LEDs) and substitute a serial LCD. Do keep in mind that the LCD will be slower than the LEDs because the Stamp will have to send a lot more information to the LCD than the two bytes of information it has to send to the shift registers for the LEDs.
  • mattm_nsccmattm_nscc Posts: 13
    edited 2011-11-18 08:37
    Perfect, thanks for the help , right now we are trying to get the different notes to show up on the lcd as "E,A,D,G,B,E" i know the top portion of the code takes the incomming signal converts it to a timing and then compares it to the list of numbers and saves it a the variable " result". do u haver any suggestion on how i might get the letters to show up depending on what string i pluck ? would i have to make all the numbers in the list equal a letter ? for example the 1st line in the "lookup" 4416=E for example ?
    My teacher said i may have to creat an look up table or something so each letter will be assigned a #

    this is what we have now
    "serout 15,84 [22,12, " Note = ", result ], it gives use the best looking results so far...

    Thanks Matt M
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-18 16:59
    The LOOKUP statement in the original program translates a note number into a set of bits that light different LED segments to produce the letters for the notes. With an LCD that has its own font, you just need to translate the note number into a character that will get sent to the display. The LOOKUP statement effectively provides the lookup table and does the lookup. Read the description of the LOOKUP statement and see what you'd have to put to lookup a note number from 0-5 and produce a character from "E", "A", "D", "G", "B", "E".
  • mattm_nsccmattm_nscc Posts: 13
    edited 2011-11-19 10:45
    thanks for the advice , i've gotten the note to show up by using the LOOKUP, which i have a list of DEC # and then i use ASC? on the SEROUT to change it back to a letter on the LCD. ( dec 65= ASC A). Now i want to build the tune up/down portion on the second row. I would like to just use a "0" in the center on the screen which would be in tune and the "0's" would shift left(up)/right(down). to show which way to tune( taking the place of the LED bar in the orginal circuit ) . Any suggestions on how i might go about this ?

    Thanks Matt M
  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-19 12:58
    You haven't provided any documentation on your display, but most of them have a way to specify which row and column to use for the next character. You can always rewrite the whole "tuning bar" section of the display, but it may be faster to keep track of the current location of the "0" (you could use a "+" instead ... might look better), write a blank there, then supply the location for the new mark / cursor and write a "0" or "+" there.
  • mattm_nsccmattm_nscc Posts: 13
    edited 2011-11-19 15:45
    ok I am using a Matrix orbital serial 16 x 2 MOS series LCD, they have all the same commands as their parallax counterparts.... so what kind of commands would you suggest i try ?
Sign In or Register to comment.