Continue to Site

# dsPIC - ADC and PWM

Status
Not open for further replies.

#### Maverickmax

##### New Member
Hi

I am thinking of using dsPIC30F for dsp application very soon but I want to be absolutely sure that I fully understand on 3 processes in regards to sampling frequency and reproducing signal on PWM channel.

1) Let say I am interested to take signal such as sine wave up to 500Hz so that means I have to set the adc at 2000Hz in comply to shannon nyquist theory.

2) At the moment, I am not going to DSP filter algorithm.

3) To reconstruct the original signal, should I use 2000Hz for PWM frequency? If higher frequency would be better, then please tell me why? To observe the signal on PWM, I would need to put 2nd pole Low pass filter RC circuit.

Once I fully grasp this concept, I will test it. If there is anything that i miss something importnat, please share your knowledge with us.

MM

1) Nyquist theory states sample rate must be at least twice the highest input frequency.
2)
3) With a 2000Hz PWM frequency, you'll have a very strong 2000Hz present in your output signal, even with your 2nd order RC filter (if you want to output the 500Hz). Increasing the PWM frequency means that it is easier to filter out the PWM frequency and harmonics.

Last edited:
Hi

Thank you for clearning this up. Do you have any tutorials for me to learn about these stuff within dspic?

Regards

MM

This stuff is not specific to dsPIC micros.

There's some info re PWM DAC at: **broken link removed**

Yes but I am slightly confused with implementation. Does the software simply take ADC sample at specified time and transfer to the PWM register straight away then PWM interrupt produce output at specified time?

Is it correct?

MM

No interrupts required, just read the sample and move it to the PWM register, as simple as that. The output frequency of the PWM has no effect, as long as it's high enough - and the higher the better, as it's easier to filter out.

Cool, thank you for information. I am going to confess that I am not entirely sure which should I go for AVR or dspic chip. I am practically torn away with this problem. Please advise me asap. I have been working on AVR for a while but I have not touched PIC or dsPIC since I was student. I am inclinded to do dspic because everyone and companies use them more than AVR chip. Do you agree with me?

I simply want to use microcontroller that allows me to sample and reproduce signal. Of course later on I would like to use dsp such as notch filter, high pass filter and low pass filter, etc.

Regards

MM

Which AVR chip?

I use ATMEGA32 at the moment

MM

I use ATMEGA32 at the moment

Do Atmel do a DSP AVR chip?, if they do you may as well stick to AVR's as you have more experience with them. If they don't, then switch to the dsPIC, PIC's are pretty simple to learn.

Unfortunately ATMEGA32 does not has the DSP functionality like dsPIC. I will order dsPIC chip very soon and build the software from scratch.

MM

Status
Not open for further replies.

Replies
5
Views
4K
Replies
0
Views
3K
Replies
3
Views
8K
Replies
4
Views
3K
Replies
1
Views
1K