Guitar Pedal Modification / Digital Potentiometers /Wave Tables / Hexadecimal

Hello,

I am new to Arduino. I was inspired to dive in by this video and post on the Make Magazine website:

http://blog.makezine.com/archive/2009/08/collins-lab-guitar-pedal-modding-wi.html . Please watch the video. I think it will give a nice background to interpret my questions below.

The sketch can be found here: http://code.google.com/p/makezine/downloads/detail?name=WavePot-090819a.zip&can=2&q= .

I have successfully executed a bunch of the Arduino tutorials, and now I am ready to jump into hacking guitar pedals. I have some questions about the sketch that Colin Cunningham made for the above application.

In reviewing the sketch, it seems like there arrays of hexadecimal values (the so-called "wave tables") that can be sent to the potentiometer in sequence, thus creating a "low frequency oscillator". It seems that on each pass of the loop the next hexadecimal value is arrived at by adding 1 to the value of the index for the array that holds the hexadecimal numbers (in the sketch that incrementing of the index seems to be represented by "i++").

My question is how and when does the index of the array loop back to index 0?

Also, the variable 'rate' is defined as an integer, but it is being assigned hexadecimal values. I am guessing that the Arduino software automatically translates the hexadecimal values into integers. Is that right? (CORRECTION: I was completely off base. It is the variable "resistance" which is a byte that is being assigned hexadecimal numbers.)

I am also wondering what modifications would need to be made to controll multiple digital potentiometers simultaneously (using for example a AD5206 which has 6 digital potentiometers built in).

Any thoughts, help, or direction will be much appreciated.

Thanks, MalikilaM

My question is how and when does the index of the array loop back to index 0?

It's a byte, it only goes 0...255, so incrementing a byte variable from 255 sets it back to zero.

PS "hexadecimal"

Also, the variable 'rate' is defined as an integer, but it is being assigned hexi-decimal values. I am guessing that the Arduino software automatically translates the hexi-decimal values into integers. Is that right?

Hex is just a convenient representation of numbers, all of which, ultimately, are binary. (where do you think "rate" is assigned hex values?)

Ignore the "byte i;" in "setup - it isn't used for anything.

Thanks for your quick reply.

I see that the resistor value only goes up to 255. (CORRECTION: I now see that I was confused. It is the variable "resistance" which is a byte that is being assigned hexadecimal numbers.)

I am more curious about the incrementing of the array index, how does the index get back to 0 by using the ++ command?

Thanks for the spelling correction on "hexadecimal" (I am a terrible speller).

I now see that "rate" is not being assigned hexadecimal numbers. It is "resistance" that gets the hex numbers. From what you are saying it seems that the Arduino software has no problem translating hexadecimal numbers into byte (0-255).

Thanks a lot.

when a byte gets up to 255, adding one more gets you 256. But only 8 bits are maintained, so the 9th bit disappears:

1111 1111 + 1 = 1 0000 0000, but only the eight 0s get to hang around

Ah, that makes sense. So, if the actual index of the array is also a 'byte', then the index of the array will go back to 0 after 255.

So, are indexes of arrays bytes?

So, are indexes of arrays bytes?

No, indices are any integer datatype.

Ah, now I understand:

AWOL mentions this: "Ignore the "byte i;" in "setup - it isn't used for anything."

That isn't correct. The variable 'i' is specifically declared as a byte so that it can be used as the index for the array, i.e., if a byte variable type is inserted in the index slot for the array incrementing it by 1 will always send it back to 0 one it exceeds 255. (I must say that that is pretty damned smart and economical programming on Collin Cunningham's part. I probably would have tried to create some crazy loopback function.)

All right! Now to make some crazy sounds! I will post a video once I get this going.

Anybody have any advice on getting changes to more than one digital potentiometer going simultaneously (or at least simultaneously-seeming to the human ear)?

Thanks for the great input!

AWOL mentions this: "Ignore the "byte i;" in "setup - it isn't used for anything."

That isn't correct

Oh yes it is.

I see now that I was ambiguous when I said that "That isn't correct." What I meant to say is that the variable 'i' actually is used. It is used as the placeholder for the number of the index being called from the array.

See this code from the sketch:

void loop()
{ 
  resistance = sineTable[i];    // CHANGE "sineTable" TO "squareTable", "sawTable", OR "sawrevTable"
  rate = (analogRead(1) + 1);
  write_pot(resistance);
  delayMicroseconds(rate);
  i++;
  //Serial.println(rate, DEC);
}

Am I correct in interpreting your statement "Yes, it is." to mean that you agree that the variable 'i' actually is used?

No, I do not agree. The variable "i" declared, as I said, in "setup" is not used and not needed. The variable "i" declared in "setup" is not used, and because it goes out of scope at the end of "setup", it cannot be used in "loop". If you doubt me, remove it, and see if your sketch still works.

Interesting. I didn't even notice that there is a variable 'i' defined in setup.

There is also a global variable 'i' defined above that as a byte with an initial value of 0. I think that is the byte variable 'i' that is used in the loop. Does that make sense?

See the sketch here:

#define DATAOUT 11//MOSI
#define DATAIN 12//MISO - not used, but part of builtin SPI
#define SPICLOCK  13//sck
#define SLAVESELECT 10//ss

int rate=0;
byte resistance=0;
byte i = 0;

I wonder why a new variable 'i' was defined in setup. As you say, that one doesn't seem to be used at all.

All right, I got the thing working. Check it out: http://www.youtube.com/watch?v=uCCRDhzniiE.

In the video I am modulating the "Delay" time control on the pedal using the digital potentiometer controlled by the Boarduino. Modulating the delay time actually changes the pitches of the repeats that are already in the delay line, so the the effect is pitch modulation.

Now to find a way to make it sound musical again! Vary it over a smaller range, maybe get a tremolo type effect, or phase shifter or something …