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
ADC, QEI and PWM on dsPIC30f4012 problem
-
- Posts: 17
- Joined: Mon Dec 01, 2008 9:01 pm
ADC, QEI and PWM on dsPIC30f4012 problem
- Attachments
-
- myQEI.c
- (2.23 KiB) Downloaded 520 times
-
- QEI_ADC3.mdl
- (38 KiB) Downloaded 529 times
-
- 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
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
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
-
- Posts: 17
- Joined: Mon Dec 01, 2008 9:01 pm
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
Thanks a lot!
Jose Luis
Re: ADC, QEI and PWM on dsPIC30f4012 problem
Thanks Lubin,
Yes, that is correct. Glad it worked
Cheers
Mariano
Yes, that is correct. Glad it worked
Cheers
Mariano
Who is online
Users browsing this forum: No registered users and 4 guests