fuzzy logic

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

fuzzy logic

Postby salemimoh » Wed Jan 07, 2009 9:48 pm

Dear Lubin,
I have tried to simulate a controller of the speed of a motor using fuzzy logic. After developing the model in MATLAB and transfer it to MPLAB V8.15a and build it. All went ok. But when i fired the program into the DSPIC30F6014 and tried to run it using microchip ICD2, it starts to run but it hangs up. I then tried to run it in step by step mode using animate, it gave me the following error message. Is this due a shortage of program memory or what ? If this is the case, is it due to the number of rules implemented in the fuzzier where i am implementing 25 rules of the form (if rule1 and rule2 then decision) which makes the program too long so that it could not be accomodated into the programming memory?
But if this is the case, i suppose the program could not be downloaded into the DSPIC because an overflow will take place.
By the way, i tried to run the program in the MPLAB simulator and it did not work either.
So could you please advise.
Here are the error messages

Code: Select all

CORE-E0011: Trap due to unimplemented RAM or PSV memory access, occurred from instruction at 0x000688
CORE-E0001: Trap due to stack error, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-W0008: Software Reset Instruction called at PC=0x002f16

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

Re: fuzzy logic

Postby LubinKerhuel » Wed Jan 07, 2009 10:29 pm

Hello,

salemimoh wrote:After developing the model in MATLAB and transfer it to MPLAB V8.15a and build it

How did you transfer it to MPLAB ? are you using the dsPIC blockset for Simulink available on this website ?

The hang up and restart behaviour is typical from trap error. Theses one are hard to find and solve. Look in the doc about memory, there may be compilation options to avoid this error. I do not know much than that. Try the microchip forum for further help on this.

Lubin

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

Re: fuzzy logic

Postby salemimoh » Wed Jan 07, 2009 11:38 pm

Dear Lubbin,
What I did, is to build the model in the MATLAB using the your blocksets. Then I built the system successfully.
Then I loaded the resulting files into the MPLAB V8.15a in the way is explained in your tutorial. Then I tried to run it. I was faced with dilema the I mentioned to you.

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

Re: fuzzy logic

Postby malife » Sun Jan 11, 2009 7:09 am

If you are stepping through see in which instruction it fails. This might help us to help you. Also, try compiling the model with a "far" memory model. See the C30 Documentation. Also it might just be that the chip you are trying to use does not have enough RAM to perform whatever it is you are trying to do. Remember the fact that the hex fits in flash is no guarantee that you have enough RAM for the program to run. Try the exact same model on a dsPic with more RAM. Finally, stack overflow errors are typical of a huge amount of local variables. If you have a C function you wrote or you are using embedded matlab try declaring large local arrays as static (or persistent if in eml) and see if that solves it.

Hope this helps

Mariano

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

Re: fuzzy logic

Postby salemimoh » Mon Jan 12, 2009 1:03 pm

Dear Mario thanx for you help
In the next step by step and what happened in W14 and w15 and where it jumps, probably you figure out the bug


I executed the program in step by step mode. the instruction at address 686 is:

00686 FA1B48 lnk #0x1b48

Before execution the registers contents are:
W14 = 137C
W15 = 1380
SPLIM = 2790
PC = 686
W8 =0x0000


After instruction's execution:

W14 =1382
W15 = 2ECA
SPLIM = 2790
PC = 688
W8 =0x0000

as expected then the problem starts from next at address 688

00688 781F88 mov.w 0x0010,[0x001e++]
before as above

After here is the problem:

W14 = 1382
W15 = 2ECE
SPLIM = 2790

PC = 2A98 which is out of the range of the program (last instruction is at address (2A96)
W8= 0x0000
and the following error messages occur:

Code: Select all

CORE-E0011: Trap due to unimplemented RAM or PSV memory access, occurred from instruction at 0x000688
CORE-E0001: Trap due to stack error, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-E0003: Trap due to unimplemented RAM memory access, occurred from instruction at 0x000688
CORE-W0008: Software Reset Instruction called at PC=0x002a98


next step PC = 0x00000000000
The question is why when excuting instruction at address 688, it does not go to next instruction at address:
0068A 804000 mov.w 0x0800,0x0000
and it goes wild as i explained?

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

Re: fuzzy logic

Postby malife » Thu Jan 15, 2009 2:00 am

Can you post a bit more about what you are doing (application wise) and which dsPIC you are using? Not really sure what is wrong. Evidently PC is getting lost for some reason.

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

Re: fuzzy logic

Postby salemimoh » Fri Jan 16, 2009 6:17 pm

Dear Malife,
What I am basically doing is to use MATLAB fuzzy logic. The number of rules implemented is 25 rules.
As a guess, when the program is compiled in MATLAB then transfered to MPLAB, and built, those rules probably introduce too many loops which requires a larger stack. And that is probably the root of the error mentioned earlier.
to solve it,
I wrote a program in custom linker script as shown below.
.stack :
{
__SP_init = .;
. += 0x2000;
__SPLIM_init = .;
. += 8;
} >data

Then i tried to call it from MPLAB custom build but it did not work yet.
my question: What should i do to call when the program is built or Is there a better way how to increase the stack?

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

Re: fuzzy logic

Postby malife » Fri Jan 16, 2009 7:28 pm

Hello Salemimoh,
I am not familiar with the Fuzzy logic toolbox (blockset?) in Matlab so I can not help you there. But I have previously encountered similar stack overflow problems, and as I mentioned in previous post, making the arrays and variables static (or persistent in matlab) did solve the problem. If this is an issue of too many nested loops I think you need to rethink your approach, because I don't know (but I don't think) there is much to do about growing the stack. Also unless you are at the top of the dsPIC family tree, try using a more capable chip, specially one with more RAM.

Sorry I can not be of more help.

Mariano

salemimoh
Posts: 23
Joined: Tue Apr 08, 2008 1:01 pm

Re: fuzzy logic

Postby salemimoh » Sat Jan 17, 2009 1:07 pm

Dear malife
I am using the DSPIC30F5014. It has a considarble memory. If fact I checked the memory used: It using 5906 from the program memory which is: 49152
and using 2934 from 8192 available. so there is still a considerable memory.
I think the problem is how to relocate the stack and how to increase it. Thing which i could not solve up to now.
There is a suggestion by usind custom linker script, I tired it but it gives a syntax error. I have looked in the literature and i could not find anything yet.


Return to “Advanced Simulink & RTW Questions”

Who is online

Users browsing this forum: No registered users and 1 guest