Problem about QEI and DisPIC33fj256mc710

Create new topics, add your comment, remark, bugs...
Post Reply
Magic
Posts: 7
Joined: Thu Jan 15, 2009 10:06 am
Location: Taiwan

Problem about QEI and DisPIC33fj256mc710

Post by Magic » Wed Feb 11, 2009 4:36 pm

Hello Lubin,

I downloaded Ender's modelon forum for testing the QEI on Explorer 16.

Compiling were succesful and I confirmed the Phase A & B of encoder is correct.(My PIC is same as Ender's : DisPIC33fj256mc710 and also without Index of QEI)

But I read nothing(zero) from rs232 when I run it
zero.JPG
zero.JPG (32.99 KiB) Viewed 3882 times

Could you help me? I could not find errors for many days.

Is the QEA & QEB pins the RB4 & RB5,right?

or do I miss something?

Regards
Magic
Attachments
QEI_workfun.c
C fonction for QEI on DsPic33FJ256MC710, 500 ligth by roll 2x mode without Index
(1.65 KiB) Downloaded 223 times
QEI_work.mdl
QEI to UART 115200 baud with a 8Mhz quartz
(31.33 KiB) Downloaded 201 times

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Problem about QEI and DisPIC33fj256mc710

Post by Ender » Wed Feb 11, 2009 6:59 pm

I Magic, I saw your email.

How many Mhz do you use for the quartz ? I used a 8Mhz for this code I think.

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

Re: Problem about QEI and DisPIC33fj256mc710

Post by LubinKerhuel » Wed Feb 11, 2009 8:41 pm

Hi Magic,

I don't go into the QEI code, I leave this part to Marianoand Ender...

I did not see errors in the model somewhere else.
- QEI Init code is called after the configuration of others peripheral (That's OK).
- Sampling time is Ok
- double in C function GetQEI is a 32 bit real in Simulink (would be 64 if you add the configuration block that add this option)

Note that the int16 conversion block will remove all decimal of the value. Thus you may have to turn a lot to get 1 ?

I would suggest to
- use only integer values, no floating point variable (replace double with long (32 bits integer) in the C function)
- test C function call by setting the C function output (inside the .C file) to a know value and check that you can see it on the matlab GUI through the TX Output Multiplexed block. If it works, the problem may come from the QEI peripheral
- Last (boring) test is to use the MPLAB debugger (you have to set-up a project, add all C files generated by simulink and dsPIC library and compile it inside MPLAB.

Not sure this help that much...

Lubin

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

Re: Problem about QEI and DisPIC33fj256mc710

Post by malife » Thu Feb 12, 2009 8:45 pm

Hello Magic,
After reading the posts it is hard for me to see if the QEI is not working or if the serial is not sending the data. Can you confirm with a scope that when you are moving the motor you actually get a train of pulses from your encoder? Because since I had the code working and Ender modified it to the MC710 and also got it to work, it might be a either a hardware or serial issue rather than the software

You are right B4 and B5 are are the phases for the QEI module. Also, since you assigned a very low priority to your QEI interrupt make sure that your IPL<2:0> is not set in such a way that interrupts with lower priority than the CPU (typically 3) are not serviced.

I can not think of anything else that could make this not work.

Sorry :-S

Magic
Posts: 7
Joined: Thu Jan 15, 2009 10:06 am
Location: Taiwan

Re: Problem about QEI and DisPIC33fj256mc710

Post by Magic » Fri Feb 13, 2009 3:48 am

Hi,

Thank you very much for these advisee.

It is work after I changed two places as following. But I exactly didn't know why it is work...

1.
I read the peripheral library module of QEI of the C30 compiler and replaced the POSCNT register with theReadQEI()function in the GetQEI function of the QEI code.

2.
check off the Activate PLL in the Master block.



Regards
Magic

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest