Page 1 of 1

ADC, QEI and PWM on dsPIC30f4012 problem

Posted: Tue Jan 13, 2009 2:49 am
by 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

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Posted: Tue Jan 13, 2009 10:52 pm
by LubinKerhuel
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

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Posted: Wed Jan 14, 2009 1:11 am
by Simon_says
That was the solution!!! Great! Thanks a lot. I will continue experimenting and learning...
Thanks a lot!

Jose Luis

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Posted: Thu Jan 15, 2009 12:48 am
by malife
Thanks Lubin,
Yes, that is correct. Glad it worked

Cheers
Mariano