News:

SMF for DIYStompboxes.com!

Main Menu

Thoughts on dsPIC test bench

Started by JKowalski, February 18, 2011, 06:20:51 PM

Previous topic - Next topic

JKowalski

So on my last order I picked up a few dsPIC33FJ128GP802's too fool around with - as an introduction to dsPIC's. I was going to make a little "development pedal" for myself to give me an easy to use platform for audio experimentation.

Before anyone starts spouting off reasons why I shouldn't use dsPIC's for this kind of thing, golden quality & extremely complex audio processing is not my end goal. I just want to experiment with dsPICs (specifically) a little and have a quick way to test out algorithms easily.

I just started putting the project together in my mind and felt like bouncing ideas off of you guys.


Alright, so the I/O will be:

- 2x8 Character LCD
- Two potentiometers (So I can do two parameter effects, or have one pot as parameter select and the other as parameter adjust - LCD makes this nicer to work with.)
- Footswitch - may be true bypass - but maybe I should have it momentary so that it can be multi-function?
- 1/8" input - I use a 0-5V signal through 1/8" for tap tempo on my board. Maybe tie this to an analog-enabled pin so that it can be used as either tap in or an expression pedal input depending on the code....
- Of course, mono in/out... internal 12-bit ADC / 16-bit DAC  - with a bit of analog circuitry for buffering/filtering
- 6-pin header for programming with PICKit3

Dunno about external memory... Havent decided whether I want to implement any delay/reverb kind of effects yet... I have a couple of 23k256's...


This all goes into a little 3.5*4.5 folded enclosure.

Suggestions? I'll have to delve more deeply then I have so far to check that my ideas correspond to the capabilities of the chip before I make a prototype board, of course...


mhelin

#1
Save the on board A/D's for potentiometer reading and connect a proper audio A/D (in master mode generating all of the clocks) to SPI input (running as slave, if possible both SPI and DAC using DMA) instead. Use an ADC like CS5361 (or CS5351) available in SOIC24 (http://www.cirrus.com/en/products/cs5361.html) . Check the dsPIC datasheet for SPI, I guess you have to choose between I2S or left justified mode in ADC, and the dsPIC supports only 16 bit. Anyway, you should be able to use the LRCK out as /SS signal for SPI. That way you could sample the other channel (when LRCK=0) from the ADC SDATA output easily. You have to supply the MCLK to the ADC of course - the clock should be 256x or 512x the FS in master mode (so using for an example 8 MHz clock you should get around 31 kHz sample rate).

Now there is also this "dsPIC Functions"  design by Eric Brombaugh you could for your project:

http://members.cox.net/ebrombaugh1/synth/dsPICfun/index.html

I've checked that the gerbers are BatchBCP compatible (after you rename the files).

The IC is more difficult to solder but I guess if you take the PCB and chip to a radio/ electronics repair shop they can solder the chip in for you easily.

Eric's also designed a proper signal processing board with onboard WM8731 CODEC and a 32k SRAM:

http://members.cox.net/ebrombaugh1/synth/dsPIC_sp/index.html

Because of the 32k SRAM that could be used also for delay based effects.

potul

Quote from: JKowalski on February 18, 2011, 06:20:51 PM
So on my last order I picked up a few dsPIC33FJ128GP802's too fool around with - as an introduction to dsPIC's. I was going to make a little "development pedal" for myself to give me an easy to use platform for audio experimentation.

I have now one of those in my breadboard and I'm starting to play with it. Fun stuff. I like the fact that it has almost everything I need in a chip, (ADC, DAC; PWM, DSP, etc...) and in a DIP format. So with a  minimal part count circuit you can have a digital development platform. (and, you can even get free samples from Microchip).
I've programmed some basic things like a tremolo, a delay  and a flanger, and so far I find it really useful as a tool to get introduced to the digital world.
The only thing I miss is more memory, with the internal 16k I could only get delay of around 300ms at 22khz sampling rate.
I plan sooner or later to add and SCCARD and try to see if I can create a looper with it.

If you find a good solution to add additional memory, let us know.



Mat

JKowalski

#3
Quote from: mhelin on February 19, 2011, 04:58:16 AM
Save the on board A/D's for potentiometer reading and connect a proper audio A/D (in master mode generating all of the clocks) to SPI input (running as slave, if possible both SPI and DAC using DMA) instead. Use an ADC like CS5361 (or CS5351) available in SOIC24 (http://www.cirrus.com/en/products/cs5361.html) . Check the dsPIC datasheet for SPI, I guess you have to choose between I2S or left justified mode in ADC, and the dsPIC supports only 16 bit. Anyway, you should be able to use the LRCK out as /SS signal for SPI. That way you could sample the other channel (when LRCK=0) from the ADC SDATA output easily. You have to supply the MCLK to the ADC of course - the clock should be 256x or 512x the FS in master mode (so using for an example 8 MHz clock you should get around 31 kHz sample rate).

Now there is also this "dsPIC Functions"  design by Eric Brombaugh you could for your project:

http://members.cox.net/ebrombaugh1/synth/dsPICfun/index.html

I've checked that the gerbers are BatchBCP compatible (after you rename the files).

The IC is more difficult to solder but I guess if you take the PCB and chip to a radio/ electronics repair shop they can solder the chip in for you easily.

Eric's also designed a proper signal processing board with onboard WM8731 CODEC and a 32k SRAM:

http://members.cox.net/ebrombaugh1/synth/dsPIC_sp/index.html

Because of the 32k SRAM that could be used also for delay based effects.



Thanks for all the info. I'll consider the external ADC. Was hoping to piece this together from parts I have stocked (no ADC's only DACs  :icon_neutral:) so that alone might sway me.

I have 5 SOIC versions of the chip and one SPDIP, so I might try more then one board if I find I want to revise it.

Quote from: potul on February 20, 2011, 06:00:46 AM
Quote from: JKowalski on February 18, 2011, 06:20:51 PM
So on my last order I picked up a few dsPIC33FJ128GP802's too fool around with - as an introduction to dsPIC's. I was going to make a little "development pedal" for myself to give me an easy to use platform for audio experimentation.

I have now one of those in my breadboard and I'm starting to play with it. Fun stuff. I like the fact that it has almost everything I need in a chip, (ADC, DAC; PWM, DSP, etc...) and in a DIP format. So with a  minimal part count circuit you can have a digital development platform. (and, you can even get free samples from Microchip).
I've programmed some basic things like a tremolo, a delay  and a flanger, and so far I find it really useful as a tool to get introduced to the digital world.
The only thing I miss is more memory, with the internal 16k I could only get delay of around 300ms at 22khz sampling rate.
I plan sooner or later to add and SCCARD and try to see if I can create a looper with it.

If you find a good solution to add additional memory, let us know.

Mat

How did you set your chip up for the mentioned effects? Are you using the internal ADC/DAC and if so what is your opinion of them?

potul

So far I've used both internal ADC and DAC. They sound good to me... :). I know it's not Hi-Fi (12bits ADC only, but 16 bits DAC), but sounds decent to me. My intention is not to build a pro thing, just to play around with digital processing, so it's good enough for me.

I've basically setup the ADC and DAC to work at 22k sample rate, and programmed a delay line using the maximum available memory, and an LFO. With these 2 elements you can easily achieve most of the modulation based effects. Delay is somehow limited because of the available memory.

Let me see if I can post a video or audio so that you can hear it...

Regards.

Mat


potul

Going back to your question though, what I would have in mind would be (this would be my whishlist, or at least, this is what I'm aiming to):

-LCD display (could be 2x8 or 2x16, it's just a question of space)
-3 pots
-MIDI IN/OUT
-Some buttons to interface with the configuration. At a minimum one "enter button".
-One momentary stompswitch or two. (these could replace the previous ones), in addition to a bypass hardwired switch for the truebypass lovers.
-Maybe an expression pedal IN?
-SDCARD interface using SPI. (well..... not really needed, but could be great for a looper or similar)
-One programmable LED or two if possible (nothing beats an LED, not even an LCD... )

wow,..... I think my list is getting too big... it will not fit any box. :), and will run out of i/o pins...


JKowalski

Quote from: potul on February 21, 2011, 12:30:13 PM
Going back to your question though, what I would have in mind would be (this would be my whishlist, or at least, this is what I'm aiming to):

-LCD display (could be 2x8 or 2x16, it's just a question of space)
-3 pots
-MIDI IN/OUT
-Some buttons to interface with the configuration. At a minimum one "enter button".
-One momentary stompswitch or two. (these could replace the previous ones), in addition to a bypass hardwired switch for the truebypass lovers.
-Maybe an expression pedal IN?
-SDCARD interface using SPI. (well..... not really needed, but could be great for a looper or similar)
-One programmable LED or two if possible (nothing beats an LED, not even an LCD... )

wow,..... I think my list is getting too big... it will not fit any box. :), and will run out of i/o pins...



Thanks, definitely helps.

I think I'll go with the internal ADC/DAC for now then... 2x8 LCD, 1/8" exp pedal / tap in, moment footswitch, 2 pots, two buttons, 23k256 for memory?, status LED.


Depending on how that goes, maybe I'll make another medium sized box with upgrades in the future (16-bit ADC / CODEC, more I/O...).

JKowalski

#7
Alright, I did some more planning:

Preliminary schematic (sans analog I/O section)



If you spot any bad pin assignments or w/e please let me know.

Ran out of IO pins to do EVERYTHING I wanted. All that is missing is a spot for a second 23k256, which I guess is not that important.


Soooo, new IO

-LCD is controlled by 4-bit, RS, RW, EN
-DAC differential output
-ADC 12-bit input

-Two analog CV's (pots)
-One analog input (expression pedal) & associated digital input (1 is CV ON 0 is CV OFF, generated by switched input jack)

    Basically the controls work like this. One pot is the parameter select, with it you choose the parameter to alter and the parameter shows up on the LCD. The other pot is the value adjust, with it you adjust the value of      
    whatever parameter is selected. That way I can emulate a ton of controls. If the CV digital input is 1, then the value adjust pot is replaced by the CV... Whatever parameter is selected can be controlled by the expression    
    pedal instead.

-23k256 SRAM SPI interface
-One footswitch digital input
-True bypass footswitch




potul

Oooh.... too bad you ran out of pins....

Quick tip if you want to save some pins, at the cost of adding one IC:

-I've used with success a 2-wire interface to an LCD, based on a shift register. You can see the concept here (this is where I got it):
http://www.rentron.com/Myke1.htm

It will save you 5 I/O pins!

Another way to get 2 extra pins is to not use the external Xtal, and use internal oscillator. This PIC allows to go up to 40 MIPS with the internal oscillator, but it will be less accurate. I've used it in my workbench without noticing any timing issues.

On the other hand, a question regarding power. I see everywhere 5v (from the LM2937), but this dspic should be powered with 3.3v. this will add some complexity when connecting to other devices like the ADC in or the SPI memory. I think you should review it.

Regards,

Mat


potul

#9
Oh, one more remark.

If you have only one SPI device (the memory), Maybe you can skip the CS (although I don't have a clue if it can be used for something else). If you need to add another SPI memory, you can share the SDI, SDO, SCK pins, and you just need to add 1 CS per memory IC. (if you need only 2, maybe you could use just one CS and a NAND gate?).

Mat


Forget it, you will probably need the CS pin to initialize the memory.... (at least it is true with an SDCARD)

potul

And..... another thought that can save 2 pins:

-If you plan to use the expression input always as a replacement of the on-box pot, you could do it via hardware, reusing the same ADC pin, and with a switch to connect/disconnect the pot/expression. This way you save 2 pins (the CV in and the expression pedal).

Just brainstorming....

JKowalski

#11
Quote from: potul on February 25, 2011, 10:47:53 AM
And..... another thought that can save 2 pins:

-If you plan to use the expression input always as a replacement of the on-box pot, you could do it via hardware, reusing the same ADC pin, and with a switch to connect/disconnect the pot/expression. This way you save 2 pins (the CV in and the expression pedal).

Just brainstorming....

Thanks a ton for the ideas.

I actually got rid of the LCD display R/W control to save a CS pin for the second SPI device. I also set it up so it is a little open for change - fits SRAMs, EEPROMs... I think with that the second SPI everything is okay.

I know it runs off of 3.3v, the reg used comes in 3.3V versions and was just there as a placeholder anyways - since I don't have any 3.3v regs with me I think I will end up using an LM317.

I also realized that the LCD I am using has the backlight permanently attached to the power inputs (no separate backlight pins, dam) and must run off of 5V to get any light. I dont think this will be a problem though, since it looks like the LCD threshold levels are 2.4V and since the RW pin is not used (permanent write) there won't be any 5V outputs to deal with from the LCD module. The SRAM is made to run off of 3.3V, so no problems there.

So the power supply is 9V for analog I/O, into two regs - LM7805 for LCD and LM317 at 3.3V for digital.

The CV replacement through hardware is a good idea but I was also thinking about maybe having that available as a digital I/O as well, for tap sync/external FS or whatever.


Ill post some pics when I get home, I started building the enclosure. It's a tiny little thing.

Right now I am drawing up a preliminary PCB and writing some psuedocode (trying to optimize timing, thats whats nice about ASM  :icon_biggrin:)

Looks like I can sample all the control ADC's in one go (nice)...

So I am totally new to the dsp concept. I assume that I set the sample rate of the ADC, and when it periodically samples the audio input it triggers an interrupt, where the dsp algorithm is carried out and the output is written to a buffer for the DAC. The DAC maybe does the conversion at the same time as the ADC from the buffer...

And then the program main loop carries out the I/O functions in the background...

I'll start writing & researching some code for a while to make sure I understand the concept before etching a board for it.

JKowalski


potul

wow, the box looks great!

regarding the ADC - DAC... There are multiple ways to set them up. You can setup the ADC for a sampling rate or configure it to sample "on demand". The DAC can only we set to a sampling rate based on the clock and some post scalers.

Both ADC and DAC can we setup to use DMA.

This is how I have it configured in my bench right now in order to have both in sync: The DAC is setup for the desired sampling rate (22k in my case). I have an infinite loop that checks for the DAC buffer to be "not full" (needing more data), and when this happens I read the ADC and trigger a new sampling+conversion, do all the calculations and send the output value to the ADC. (this should be done probably using an interrupt instead)

But there's multiple ways to skin a cat... DMA looks interesting if you want to process a large amount of samples in batch (like FFT or similar), because it allows the system to be collecting all data without CPU intervention, and when the full sample is ready, do your calculations.

As I'm working now on algorithms that need to be computed on each sample, I don't use DMA.

Mat


JKowalski

Quote from: potul on February 26, 2011, 05:38:38 AM
wow, the box looks great!

regarding the ADC - DAC... There are multiple ways to set them up. You can setup the ADC for a sampling rate or configure it to sample "on demand". The DAC can only we set to a sampling rate based on the clock and some post scalers.

Both ADC and DAC can we setup to use DMA.

This is how I have it configured in my bench right now in order to have both in sync: The DAC is setup for the desired sampling rate (22k in my case). I have an infinite loop that checks for the DAC buffer to be "not full" (needing more data), and when this happens I read the ADC and trigger a new sampling+conversion, do all the calculations and send the output value to the ADC. (this should be done probably using an interrupt instead)

But there's multiple ways to skin a cat... DMA looks interesting if you want to process a large amount of samples in batch (like FFT or similar), because it allows the system to be collecting all data without CPU intervention, and when the full sample is ready, do your calculations.

As I'm working now on algorithms that need to be computed on each sample, I don't use DMA.

Mat



Do you know of some good code examples for simple DSP programs in ASM? All microchip's examples seem to be in C.


My plan is to write this code to be as "modular" as possible, I.E. a basic skeleton interface to the I/O with the core dsp program stuck in the middle and very extensive comment documentation. The main loop getting all the I/O done in the background, storing control info to standard memory locations that the dsp program accesses. Hopefully I can get it to a point where I can easily introduce new effects with minimal GPIO worries. Will also necessitate a nice library of subroutines. I'll post the schematics/layout/code here once I am done.

potul

All the code examples are in C...., and I'm also using C. These 16 bits PICs are supposed to be optimized to work in C. But most of the basic steps to get the ADC working should be the same as it is just a matter of configuring the ADC registers and read data from memory. Same for the DAC.
Coding the DSP algorithms is something more complex, and I haven't found any good example... I can't really help here. In fact, I'm not using the DSP yet, all my calculations are done by the MCU.

Mat

JKowalski

Quote from: potul on February 27, 2011, 06:47:12 PM
All the code examples are in C...., and I'm also using C. These 16 bits PICs are supposed to be optimized to work in C. But most of the basic steps to get the ADC working should be the same as it is just a matter of configuring the ADC registers and read data from memory. Same for the DAC.
Coding the DSP algorithms is something more complex, and I haven't found any good example... I can't really help here. In fact, I'm not using the DSP yet, all my calculations are done by the MCU.

Mat

I should start looking into C for uC's. I know how to write in C, I just never applied it to uC's yet. I'm much more comfortable writing in ASM.

The main reason I wanted to take a peek at sample code is to get a global view of how to use dsPIC's (methods to configure the analog data path) and get more comfortable with the host of new ASM commands the dsPIC's give you. I tend to learn really well by parsing other people's code more then anything.

JKowalski

Here's an updated schematic. The power lines are correctly labeled, tentative analog I/O (is it worth it to put analog limiting before the ADC?), second SPI in, parts labeled



JMCTech

I've just found this link:

http://spinlab.wpi.edu/projects/dspboard/dspboard.html

There's a realy good project report with schematic and source code inluding 6 detailed DSP based LAB assignments

They use a dsPIC33FJ128GP802 with a TI TLV320AIC23 stereo audio codec.

JC

mhelin

Quote from: JMCTech on February 28, 2011, 12:57:17 PM
I've just found this link:

http://spinlab.wpi.edu/projects/dspboard/dspboard.html

There's a realy good project report with schematic and source code inluding 6 detailed DSP based LAB assignments

They use a dsPIC33FJ128GP802 with a TI TLV320AIC23 stereo audio codec.

JC

Interesting, I didn't know that the dsPIC33FJ128GP802 has DCI port because the dsPIC33 selection table column for the codec interface (I2S, AC97) says "NO". I though read on MC forums that the selection table is wrong / has errors and that the part does really have the DCI interface. Which means also the DIP (though hole) part has so you could for an example use the Mikroelektronica CODEC board with these parts easily.