News:

SMF for DIYStompboxes.com!

Main Menu

Multi Effects Pedal

Started by MstrKurt, November 20, 2013, 11:35:51 PM

Previous topic - Next topic

MstrKurt

Hey guys,

I found this forum while researching dsPIC's and Audio Processing and found that it could benefit me greatly both for my final year major project (Computer Systems & Electronics) in uni and later in life.

My project is to create a Multi Effects Guitar Pedal that is controlled by a dsPIC33F32GP302; The initial effects I plan to create are Distortion, Delay, Chorus, Phaser, Wah.

I was wondering where you guys would recommend I begin learning to create/program these effects to the dsPIC. I have a basic knowledge of PIC programming thus far, how difficult do you guys think this project will be?.

Thanks for having me.

potul

dsPIC audio will not be hi-fi.... you know. Unless you use an external DAC.

But I programmed some dsPIC effects and they sounded great. You can see it in action here:

https://www.youtube.com/watch?v=Yj0t6TNvrgM

The most complicated thing to learn is how to manage the dspic itself. Memory mapping, registers, and get the ADC DAC working properly. Once you get there and you are able to input / output sound of your dspic, things get easier.

One of the beiggest limitations of dsPIC is the amount of available memory. If you want to implement delays... you might need some kind of external memory.

Regards



MstrKurt

Thanks a lot for your input Potul!.

MstrKurt

What dsPIC did you use for that btw?.

slacker


cloudscapes

I wouldn't use the dsPIC's internal DAC and ADC for audio. They're fine for tests, but not really that great for more. Last I heard, the DAC's 4 or 5 LSB's were so noisy that they might as well not exist, and that it's more like a 10bit DAC. Even using an external 12bit MCP3201 and equivalent DAC would be better. Proper audio ADCs and DACs have to be properly decoupled and seperated from a microcontroller, which is a huge source of digital noise. With its own star grounding and ground plane for best results. At least if you're aiming for 16 usable bits or better.

One thing the dsPIC has going for it is an I2S controller. I don't have any details or experience, but I've read that interfacing the dsPIC to a codec works pretty well, and that's it's possible to achieve a high samplerate and bit depth! I'd say go for it!

Lately I've been trying to get a PIC32 to work with a WM8731 codec. Hasn't been very easy so far.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

g_u_e_s_t

ive havent used PICs much, but have done a lot with the wm8731, so i can give pointers if needed.

MstrKurt

Ok, so the general consensus is to use external ADC's and DAC's?

Are there any other PICs you'd recommend that I can program with a PICkit 3?

If my best shot is the dsPIC could you recommend a specific model that would allow the highest quality of audio and is programmable using Assembly?.

Thanks a lot for your input so far guys, I appreciate it.

cloudscapes

Quote from: MstrKurt on November 23, 2013, 09:53:31 AM
Ok, so the general consensus is to use external ADC's and DAC's?

Are there any other PICs you'd recommend that I can program with a PICkit 3?

If my best shot is the dsPIC could you recommend a specific model that would allow the highest quality of audio and is programmable using Assembly?.

Thanks a lot for your input so far guys, I appreciate it.

I don't know about general consensus, but basically if you're fine with lofi (or at the most midfi) audio, then you can use the dsPIC's internal converters. Just don't expect lots of precision or a low noise floor. It might be fine when you're starting out and trying to get a handly on the microcontroller, then later you can upgrade your effect with some good external converters.

Based on my extremely limited experience in dsPICs, go for the dsPIC33 line of chips, not dsPIC30. The 33's are much more powerful. As for actual "audio quality" that will depend more on your program, and how well you use internal or external ADC/DAC converters than the actual type of dsPIC.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

cloudscapes

Quote from: g_u_e_s_t on November 22, 2013, 08:02:45 PM
ive havent used PICs much, but have done a lot with the wm8731, so i can give pointers if needed.

I think my problems are more with the PIC32 and how it does frame mode SPI and interrupts. The wm8731 was tricky at first, but I think I got it to sort of work on its own, setting it as the master with its own clock. I can throw words at the codec and have it work like a DAC, and based on what I'm seeing on my scope it seems to be at least attempting to give me ADC sample data. The trouble is more with the PIC and its SPI buffer, sitting there and pretending it isn't receiving anything when through the scope I can see it obviously is. Probably configuration bits or the order I'm doing things. Discouraging because I've been at it for weeks.

And because datasheets aren't my strength, and configuration bits that look nothing like actual words are really really confusing.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

g_u_e_s_t

if you let me know which pic32 youre using, i can have a look at the datasheet at some point, and see if i see anything.  the wm8731 doesnt really do SPI, it does something really close, so i wouldnt be suprised if the pic32 was getting a bit confused.  are you using the wm8731 in I2S mode or microcontroller mode?

cloudscapes

Running the codec in master DSP mode. Using a PIC32MX575F256L so there's no I2S mode, I'm told only DSP will work because the pic won't handle left-right frame shifting in I2S. MSB and LSB modes don't seem to work either. At least with my configuration.

I appreciate the offer, you don't have to though. I'll work on it a bit longer, but I think I might switch to ARM soon. There are a bunch of other things I like less about the PIC32, so that decision might've been overdue. Already ordered the STM32F4 Discovery board and will have a go as soon as I pick an IDE. I seem to have an easier time finding ARM documentation in audio projects, such as this one: http://ebrombaugh.studionebula.com/synth/stm32f4_codec/
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

g_u_e_s_t

ive had some luck getting the wm8731 to work with the stm32's, via the maple platform.  i used the codec in slave mode, as the SS pin is only briefly toggled in DSP mode, which doesnt match what the microcontroller is expecting.  most microcontrollers want the SS line held high for the duration of the transfer, and then interrupt on the falling edge.

cloudscapes

Yeah the maple platform looks pretty interesting. I've never used arduino but I admit the library and community support makes it appealing. And in the case of maple, I saw there's a wm8731 board that's compatible with it (with sources)

the 3 maple boards
http://leaflabs.com/devices/
seem to only be STM32F1's. How easy is it to use the maple IDE with your own JTAG programmer and boards, if you don't mind my asking?

I don't really have a clue, because usually everything arduino sort of advertises itself as board+bootloader, not IDE+chip.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

g_u_e_s_t

i am pretty sure there is a JTAG header on the maple boards.  i program them with their IDE, so i cant say for sure, though.  if you feel comfortable using your own tools, its probably better to just get started with the stm32f4 series, as they have more dsp support.  they also have native I2S, if i recall correctly.  i guess the nice thing about the maple native, is that it has built in SRAM, so you could just get up and running with it.

cloudscapes

Hmm.. I meant more in the sense of using the maple IDE with chips that are not of those three/four boards. STM32 chips of my own choosing.

I did do some more research since I last posted, though, think I got my answer. The IDE apparently supports one STM32F4 chip, and they tried that with the maple II board, but it's discontinued. There is semi-support for new chips, best I can gather. Not sure if that's good enough for me. Might go with the coocox IDE instead, since it's more "general" and doesn't appear to be tied with specific boards.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

potul

Hi again everybody.

For some reason I dropped my initial answer and forgot about this thread... and I realize now that some interesting discussion has been going on.

I agree with Cloudscapes, ADC/DAC in dsPIC are not hifi... so it will not fit all needs.
It highly depends on what you want to achieve. In my case, I was looking for the possibility of creating crazy effects, so I didn't care much about quality, 10bits looked good enough.

Regarding the model, I agree too on using dsPIC33 models. These are by far the best ones, very powerful, they do have FFT, autocorrelation and similar functions out of the box. BTW, these are optimized for C, so better forget about Assembly.
In my test project I used a dsPIC33FJ128GP802 because it was the one that was matching my needs in terms of I/O and memory. And I got if for free as a sample from Microchip  :icon_cool:

Nowadays I have this project unfinished in a carton box, waiting... I'm playing with my new Raspberry PI   ;D

MstrKurt

Can any moderators delete my other topics since I seem to be taking up the front of this forum haha. I will keep this thread as the one to continue with.

Can anyone explain to me why external memory is needed for delay?, and why a for loop cannot be used to delay the time until the next delay hits the output.

output = currentsignal;
for(x=1;x<100;x++);
{
}
output = lastsignal;

cloudscapes

#18
Quote from: MstrKurt on December 23, 2013, 01:01:45 PM
Can anyone explain to me why external memory is needed for delay?, and why a for loop cannot be used to delay the time until the next delay hits the output.

output = currentsignal;
for(x=1;x<100;x++);
{
}
output = lastsignal;


I wouldn't use for while loops to actually define your sample delay. it's not terribly accurate, and your processor can't do a whole lot while it "waits" for the next loop. it's probably better to use a timer interrupt instead. I've made several samplers/loopers/delays on pic and avr using timers. it frees up the processor to do important stuff like math, sampling pots, etc.

you can use any kind of memory for delay, internal or external. internal delay will be easier to use (just a sample word array as long as you need your delay time to be) and will be faster, but you'll have less of it. which dspic are you using? I can't find the one you mention in your original post.

external delay is a bit trickier to use, but you'll have a lot more of it
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

MstrKurt

Quote from: cloudscapes on December 23, 2013, 04:24:09 PM
Quote from: MstrKurt on December 23, 2013, 01:01:45 PM
Can anyone explain to me why external memory is needed for delay?, and why a for loop cannot be used to delay the time until the next delay hits the output.

output = currentsignal;
for(x=1;x<100;x++);
{
}
output = lastsignal;


I wouldn't use for while loops to actually define your sample delay. it's not terribly accurate, and your processor can't do a whole lot while it "waits" for the next loop. it's probably better to use a timer interrupt instead. I've made several samplers/loopers/delays on pic and avr using timers. it frees up the processor to do important stuff like math, sampling pots, etc.

you can use any kind of memory for delay, internal or external. internal delay will be easier to use (just a sample word array as long as you need your delay time to be) and will be faster, but you'll have less of it. which dspic are you using? I can't find the one you mention in your original post.

external delay is a bit trickier to use, but you'll have a lot more of it

I'm currently using the dsPIC33FJ32GP202: http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en530332
But I have a dsPIC33FJ128GP802 coming on the 27th: http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532298

I don't know much about interrupts in PIC's but what about using __delay32_(x) ?