playinmyblues - 2015-02-20

On p188 of the GCB Programming Manual it provides the following section of code:

<a href="#">
'Produce the tone
'440 Hz = 880 changes = tone on for 1.14 ms
Repeat 440
    PulseOut SPEAKER, 1140 us
    Wait 114 10us 'Wait for 114 x 10 us (1.14 ms)
End Repeat
</a>

The part that is missing is a * between the numbers. It should look like:
Wait 110 * 10 us

Most people will figure it out but it could stump somebody new to programming, at least for a while.

By the way, in the manual it says that the tone command is not great for making sounds - it that ever true! I am making a looper based on the Luna Mod Looper (see Make magazine) and I tried everything I could think of the get a loop to play with the correct frequencies and timing and it would not work properly. I had an LCD connected as per the Sample Project and that part worked. Good thing, as I am using a PICKit 1 which, to my knowledge, does not allow for a serial terminal so the LCD was doing double duty as a frequency and tempo display as well as a debugger.

I disconnected the LCD to see if that would change anything. I moved the frequency pot off the ICSPData pin to see if that would work. I even put in a crystal with caps, granted based on the Arduino - 16 MHz crystal with 22 pF caps but, that did not straighten out the timing. So this is why I posted the code above. It will take a little more figuring out to get the numbers right to produce musical notes close to the standard frequencies but it should provide more control over the sound as it looks like the duty cycle can be changed by altering the Wait time.

I wonder if two or more frequencies can be played at one time by using PulseOut on more that one pin and the same Wait command?

Other relevant information: the PIC used is a 16F684 - 14 pin IC.

 

Last edit: playinmyblues 2015-02-20