FORUM TOPIC · READ ONLY

ADC, QEI and PWM on dsPIC30f4012 problem

ADC, QEI and PWM on dsPIC30f4012 problem

Forum : General Remark and Questions

4 message(s) · archive en lecture seule

Simon_says
Hello Lubin and Mariano!

I am still learning how to use the pheriperals of the dsPIC. I was implementing the following model in order to use the PWM, the ADC and the QEI at the same time. The PWM generates just a signal with a constant period and constant duty cycle. The QEI, reads the position of the motor shaft and turns on a led when the count of the PSTCNT is <1 or > 44000 counts, otherwise the led is off. Last, the ADC reads a voltage input and turns on /off a led when the input voltage is at a certain level. When I use only one peripheral, the model runs fine in the dsPIC; However, in the model attached there is no problem with the PWM and the QEI but the ADC won´t respond as it suppossed to. I noticed that when I configure the QEI something affects the ADC and it do not work properly... Can you help me? Could you please take a look at the model? Thanks a lot!

By the way, I am using the function and the model proposed by Mariano to run the QEI....

Regards.

Jose Luis

Pièce jointe : QEI_ADC3.mdl

Pièce jointe : myQEI.c

LubinKerhuel

Re: ADC, QEI and PWM on dsPIC30f4012 problem

The configuration of the QEI peripheral in the C function file should not interfere with others peripheral:



in myQEI.c , the line

ADPCFG = 0xFFFF; //ADPCFG | 0x0030; // Disable the A/D pins 4 and 5

Disable ADC from pin 0 to xx. Thus, ADC 0 will not be used properly!

It should be like the comment:

ADPCFG =ADPCFG | 0x0030; // Disable the A/D pins 4 and 5



if it still do not work, report it. There may be few tricks to remove completely the pin configuration done inside the QEI c file!



Lubin
Simon_says

Re: ADC, QEI and PWM on dsPIC30f4012 problem

That was the solution!!! Great! Thanks a lot. I will continue experimenting and learning...

Thanks a lot!



Jose Luis
malife

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Thanks Lubin,

Yes, that is correct. Glad it worked



Cheers

Mariano