Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I should move from PIC18 to dsPIC33 for 3 channelAudio recorder

Status
Not open for further replies.

electroman2000

Member level 2
Joined
Feb 3, 2015
Messages
44
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
496
Hi everyone, I'm new on this forum. For first, I'm sorry for my poor english; second, I signed here because I was redirect in this forum many time in my search and every time I have read useful answer.

Well, my problem is simple. I have to implement a 3 channel Audio recorder with a PIC18F4525, and I have only a (limited) experience with a PIC18 (8 bit). I would store the record in a MMC, in WAV format. I use mikroC and proteus for simulation.
My strategy for now is to use 3 external 8-bit ADC, due to slow internal ADC of PIC. Also I use a swap file to save faster the sample, and then, at the end of record, move to FAT16, in WAV file format.
For doing this I implement an interrupt (TMR0) every 22us (44.1 khz sample rate), and two 512 bytes array; when the first is full, it is written into MMC and the sample is stored in the second one, and vice versa. Due to a poor RAM, I'm not able to implement this for every 3 channel, with 6 array of 512 bytes. So I used to store in only two array every sample of 3 channel, so every 512 bytes of a sector have a 171 sample from 1° channel, 171 sample from 2° channel and 170 sample from 3° channel.
This system works well but increment the speed of record. Also every record is too much noisy, no matter the number of channel, also 1 channel have this problem. For simulation I linked an Audio file (WAV) in Proteus directly to analog input of a LTC1099 ADC, and the parralel 8-bit output to a PORTB of microcontroller.

Now my question is: is possibile that the problem is simulation in Proteus, or PIC18F is really too poor for this type of application?
Is the noise caused b PIC18, 8-bit instead of 16, simulation in proteus or what?

In this case I have to move to dsPIC, and so I have a question: is my C-code portable? Can I use my code , with few modification on the registry, or the logic is completely different?

Thank you!
 

unless I was building 1000's of units I would not consider anything less than a PIC24 for new applications

If you moved to a dsPIC33 you could use onboard ADC's with DMA, i.e. moving sampled data directly in memory using double buffering

have a look at Microchip's product selector
https://www.microchip.com/maps/microcontroller.aspx

and the code examples
**broken link removed**
 

Thank you for reply and for useful links. Of course 16 bit PIC is better, more power at the same cost. But in my case I haven't much time and I have already written the code, so I want to know it can be done with PIC18 and, if not, it is possibile to port the code without rewrite it.
Also I'm interested to know if the learn curve of 16 bit is high or not. In this balance powerfull and cost aren't the only variable, there is also time and complexity.

Another question: what is the difference between PIC24 and dsPIC33? What I should choose?

Thanks again.
 

Something that might help but may not be relevant to your project is; what type of sound are you expecting to record? If it's voice or some other relatively low bandwidth source, you can lower your sampling frequency which should help with the throughput. It it's music, then you should probably stick with 44KHz but since you are using 8-bit ADCs, that might not be the case.
 

Something that might help but may not be relevant to your project is; what type of sound are you expecting to record? If it's voice or some other relatively low bandwidth source, you can lower your sampling frequency which should help with the throughput. It it's music, then you should probably stick with 44KHz but since you are using 8-bit ADCs, that might not be the case.
I want to record voice.
Now I made some other try with 64 Mhz PIC18F46K20, with 44 Khz and the sound is recorder properly, but it is also much noisy. I think the problem is the source, that is music, instead of only voice that I want to record.
What your are saying is correct, I can lower the sample rate, because I only want to record voice. But finally I obtain the 44.1 Khz sample rating, and I use this for oversampling, to reach a trade-off with small number of bit. What do you think of this?

Also, I watch on youtube a video that this record is made by a PIC16! I would know if the problem is simulation, and maybe a real system with filter improve the audio quality of speech, or it is a intrisec problem of the system.
 

There is Any advantage to move toward PIC32 instead to dsPIC, form my application?
Consider that I'm new in both dsPIC and PIC32. PIC32 is really too complex, and eventually too expensive, for choose it?
Thanks
 

Some comments:
- If you are recording voice then 8KHz sampling is sufficient. This gives you frequencies up to 4KHz. A number of communication systems use this sampling frequency as it provides intelligible speech, lower bandwidth requirements and is much easier on the processor.
- If you are using an internal ADC, then many in the PIC devices only go to 10 or 12 bits. As the bottom few bits are generally noise, you can use 8-bit sampling.
- The main difference between the PIC24 and dsPIC33 families is that the dsPIC devices contain additional capabilities around signal processing, in particular the multiply-and-accumulate instructions and some fancy addressing hardware that makes things such as FFT calculations more straight forward. Unless you need to use FFT, FIR or IIR filters etc, then there is not much to choose between them.
You don't say which compiler you are using (at least I couldn't see it). However, there a re a few differences in moving from the PIC18 to the PIC24 families of devices; mainly in the register names, the config bits and how some peripherals are implemented (e.g. the PIC18 MSSP becomes 2 devices in the PIC24 world: SPI and I2C). The basic concepts are the same (i.e. analog vs digital pins, the config bits, getting the oscillator to work correctly...).
- I have not used the PIC32 families of devices but form what I can see, it is less of a step from PIC24/dsPIC33 to PIC32 than from PIC18 to PIC24. Much of the additional 'complexity' of the PIC32 architecture is hidden by the compiler (i.e. the use of separate registers to perform bit manipulations on the registers in PIC32 vs the use of the main accumulator in the PIC24) but, again, the basic concepts all flow through.
Susan
 
Some comments:
- If you are recording voice then 8KHz sampling is sufficient. This gives you frequencies up to 4KHz. A number of communication systems use this sampling frequency as it provides intelligible speech, lower bandwidth requirements and is much easier on the processor.
- If you are using an internal ADC, then many in the PIC devices only go to 10 or 12 bits. As the bottom few bits are generally noise, you can use 8-bit sampling.
- The main difference between the PIC24 and dsPIC33 families is that the dsPIC devices contain additional capabilities around signal processing, in particular the multiply-and-accumulate instructions and some fancy addressing hardware that makes things such as FFT calculations more straight forward. Unless you need to use FFT, FIR or IIR filters etc, then there is not much to choose between them.
You don't say which compiler you are using (at least I couldn't see it). However, there a re a few differences in moving from the PIC18 to the PIC24 families of devices; mainly in the register names, the config bits and how some peripherals are implemented (e.g. the PIC18 MSSP becomes 2 devices in the PIC24 world: SPI and I2C). The basic concepts are the same (i.e. analog vs digital pins, the config bits, getting the oscillator to work correctly...).
- I have not used the PIC32 families of devices but form what I can see, it is less of a step from PIC24/dsPIC33 to PIC32 than from PIC18 to PIC24. Much of the additional 'complexity' of the PIC32 architecture is hidden by the compiler (i.e. the use of separate registers to perform bit manipulations on the registers in PIC32 vs the use of the main accumulator in the PIC24) but, again, the basic concepts all flow through.
Susan

Thanks Susan for your reply. I wrote in the OP what compiler I use, it is mikroC.
-I agree with you, doe speech recording 8k sampling is sufficient. But my commiter, who is not a technician, thinks that a higher sampling frequency involve a better quality of speech, so I have to use 44.1 khz.
- Thanks for explaining the difference between dsPIC33 and PIC24. Now I have clear ideas.
-About PIC32, because my application is time critical (I need to store information in SD FAT32), I think PIC32 is a good choice. You said that the step from PIC24 to PIC32 is too much, but what about the direct step from PIC18 to PIC32? My idea is simple: instead use PIC24 and maybe find problem in future, I skip directly to PIC32 for avoid problem, because I haven't much time before the deadline.

I also say , for clarity, that mikroC have a wide number of library wich is the same for every mikroC (PIC18, PIC24 and PIC32), for example SD and SPI library. This might make the migration more simple.

I want to ask another question: knowing the max velocity of PIC32's SPI modules ( 25 Mbps), how fast I can write on FAT32 file on SD?
 

I'm not sure what problems you would have with the PIC24 range that going to a PIC32 would solve.If you are talking to an SD card, then it will probably be via SPI or a 4-bit interface - both of which will be just as easy with a PIC24. The key thing will be the speed the card can be written. However the FAT32 library software is available in the "Harmony" software library for the PIC32 families so there may be a bit of an advantage there.
The maximum SCK frequency for the PIC32s will depend on the device but 20MHz is a general 'guide'. THis is abotu the same for the PIC24 familes but you really need to look at the data sheets to be sure for any specific device.
However the other aspect to consider is the processing that will be required for each value exchanged. Using DMA will help push through values. If you need CPU intervention, then you need to keep an eye on the maximum CPU clock speed you can get and how this relates back to the MIPS you will need to process each value.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top