ADC, QEI and PWM on dsPIC30f4012 problem

Create new topics, add your comment, remark, bugs...
Post Reply
Simon_says
Posts: 17
Joined: Mon Dec 01, 2008 9:01 pm

ADC, QEI and PWM on dsPIC30f4012 problem

Post by Simon_says » Tue Jan 13, 2009 2:49 am

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
Attachments
myQEI.c
(2.23 KiB) Downloaded 268 times
QEI_ADC3.mdl
(38 KiB) Downloaded 261 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Post by LubinKerhuel » Tue Jan 13, 2009 10:52 pm

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
Posts: 17
Joined: Mon Dec 01, 2008 9:01 pm

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Post by Simon_says » Wed Jan 14, 2009 1:11 am

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

Jose Luis

malife
Expert
Posts: 56
Joined: Tue Apr 17, 2007 7:24 am
Location: Santa Cruz, CA
Contact:

Re: ADC, QEI and PWM on dsPIC30f4012 problem

Post by malife » Thu Jan 15, 2009 12:48 am

Thanks Lubin,
Yes, that is correct. Glad it worked

Cheers
Mariano

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests