Problem mit PID-Regler Code example dsPIC

Gast #635464
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.
Gast
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 :)
Angehängte Dateien:
Gast
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.
Gast
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
Angehängte Dateien:
Gast
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?
Gast
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
Gast
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!

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 19 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.