hi, i tried to implement the code Example for PID-control (CE019_PID) into my Project. I wrote the following code: (the most is copy pasted from the example code) #include "dsp.h" #include "p30f5015.h" tPID dc150PID; fractional abcCoefficient[3] _attribute_ ((section (".xbss, bss, xmemory"))); fractional controlHistory[3] _attribute_ ((section (".ybss, bss, ymemory"))); fractional kCoeffs[] = {0,0,0}; //definition {kp,ki,kd} void setupPID (void) { dc150PID.abcCoefficients = &abcCoefficient[0]; /*Set up pointer to derived coefficients */ dc150PID.controlHistory = &controlHistory[0]; /*Set up pointer to controller history samples */ PIDInit(&dc150PID); /*Clear the controler history and the controller output */ kCoeffs[0] = Q15(0.7); //kp kCoeffs[1] = Q15(0.2); //ki kCoeffs[2] = Q15(0.07); //kd PIDCoeffCalc(&kCoeffs[0], &dc150PID); /*Derive the a,b, & c coefficients from the Kp, Ki & Kd */ } int calcPID (int act_value,int des_value) { dc150PID.controlReference = des_value ; /*Set the Reference Input for your controller */ dc150PID.measuredOutput = act_value ; /*Typically the measuredOutput variable is a plant response*/ PID(&dc150PID); return dc150PID.controlOutput; } after building the project i got following error messages: ...\PID.o(.text+0xc): In function `setupPID': ...\PID.c:16: undefined reference to `PIDInit' ...\PID.o(.text+0x1e):...\PID.c:20: undefined reference to `PIDCoeffCalc' ...\PID.o(.text+0x34): In function `calcPID': ...\PID.c:31: undefined reference to `PID' Link step failed. after that i tried to add the pid.s to my source files and got the following errors: pid.s: Assembler messages: pid.s:29: Error: can't open dspcommon.inc for reading pid.s:116: Error: Invalid mnemonic: 'fractsetup' pid.s:240: Error: Invalid mnemonic: 'fractsetup' so i copied the dspcommon.inc into my project folder and get this error messages: ...\pid.o(.libdsp+0x0):.../pid.s: multiple definition of `PID' ...\PID.o(.libdsp+0x0):.../pid.s: first defined here ...\pid.o(.libdsp+0x38):.../pid.s: multiple definition of `PIDInit' ...\PID.o(.libdsp+0x38):.../pid.s: first defined here ...\pid.o(.libdsp+0x4e):.../pid.s: multiple definition of `PIDCoeffCalc' ...\PID.o(.libdsp+0x4e):.../pid.s: first defined here c:\pic30_tools\bin\pic30-coff-ld.exe: Link terminated due to previous error(s). what am i doing wrong? i also tried to add the linkerscript.gld from the code example same success.
It would be helpful if you pack your project folder and post it here.
Hier ist das komplette Projekt. vielleicht kannst du mir ja helfen. P.S. hab vorhin auf denglish gepostet weil ich das gleiche auch bei microchip ins forum gestellt hab aber da antwortet niemand :)
Ups, da ist noch was falsch in dem .zip file du musst PID.c aus dem Project entfernen und das PID.c neu adden weil der pfad sonst nicht stimmt. ansonsten müsste es gehen.
OK, Es liegt daran dass zwei Objektdateien gleich heissen. schmeiss pid.s raus, benenns um in pid2.s und schaffs wieder ins projekt. dann gehts. zumindest nässt es sich Fehlerfrei übersetzen.
Danke das hat funktioniert . Trozdem noch ne Frage ich hab ein bisschen rumprobiert und habe das Beispiel so wie in meinem projekt umprogrammiert, bei dem codeexample muss ich allerdings gar keine pid.s einbinden und es funktioniert trozdem obwohl mein funktionen in PID.c sind also wieder ein gleiches objektfile entsteht? Das hätte ich auch gerne so in meinem Projekt(ist aber nicht zwingend notwendig). Im Zipfile ist die geänderte CE019_PID
Ich hab absolut keine Ahnung was du damit sagen willst. es geht doch jetzt oder?
Ja es geht pid.s in pid2.s umbenannt und funzt, danke dafür. ABER in dem Beispiel von Microchip haben die gar nicht erst die pid.s ins projekt eingebunden und es geht trozdem ? Warum?
ok kapiert. Scheinbar linken die mit ihrem linkerskript Bibliotheken dazu, in denen diese Funktionen schon enthalten sind. Ist aber nur ne Vermutung.
Hi, To run this PID on a p33FJ256GP710 you need to change: fractional controlHistory[3] _attribute_ ((section(".ybss, bss, ymemory"))); to fractional controlHistory[3] _attribute_ ((far, section(".ybss, bss, ymemory"))); My topic is a little bit out of the contex, but I am sur it will help somebody. regards, PL
Darf ich aus reinem interesse fragen, für was der Regler zum Einsatz kommt? Hast du Einstellempfehlungen benutzt? Wenn ja Welche? Wie gesagt, nur aus Interesse. Danke im Voraus!
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.