PID ve PIC

Katılım
7 Şub 2010
Mesajlar
120
Puanları
1
PIC mikroişlemcilerini PID( PD, PI ,P) kontrolü ile programlayabilir miyiz? Bu programlama işlemi mikro c, proton gibi dillerle yapılabilir mi?
 
tabiki programlarsın.neticede pid bir kontrol birimi.bunu yazdığın programla oluşturuyorsun girdilerini çıktılarını belirlersin.buna göre kontrol eder.istediğin dildede istediğin işlemcidede programlarsın sorun olmaz.
 
Acaba elinde PIC ile yapılmış PID kontrol örneği olan var mı ? Paylaşıp, anlatıp yardımcı olur musunuz?
 
pic ile yapılmış PID algorimalı uygulama aranıyor kaynak gösterebilecek varmı?
 
http://www.shawnlankton.com/2005/03/pic-pid-controller/
http://www.ccsinfo.com/forum/viewtopic.php?p=9051

Kod:
PID.c
#include <18F452.h>

#device *=16 ADC=10

#use delay(clock=20000000)

#use rs232(baud=38400,xmit=PIN_C6,rcv=PIN_C7)

#include "PID.h"

#INT_TIMER0

TIMER0_isr(){

   drive = UpdatePID(&plantPID,(plantCommand - position), position );

}


void main(){

  setup_adc_ports ( NO_ANALOGS );
  setup_adc ( ADC_OFF );
  setup_psp ( PSP_DISABLED );
  setup_spi ( FALSE );
  setup_wdt ( WDT_OFF );
  setup_timer_0 ( RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit );
  enable_INTerrupts ( INT_TIMER0 );
  enable_INTerrupts ( GLOBAL );

  setup_oscillator ( False );

  while( 1 ) {

  }
}

PID.h
typedef struct {

  signed int16 dState,     // Last position input
               iState;     // Integrator state

  signed int16 iMax,
               iMin;       // Maximum and minimum allowable integrator state

  signed int16 iGain,      // integral gain
               pGain,      // proportional gain
               dGain;      // derivative gain
} SPid;

SPid plantPID;

signed int16 plantCommand, position, drive;

//PID controller code
signed int16 UpdatePID(SPid *pid, signed int16 error, signed int16 position)
{
   signed int16 pTerm,
                dTerm,
                iTerm;

   // calculate the proportional term
   pTerm =  pid->pGain * error;   // calculate the proportional term

   // calculate the integral state with appropriate limiting
   pid->iState += error;

   if ( pid->iState > pid->iMax){
       pid->iState = pid->iMax;
   }

   else if ( pid->iState <  pid->iMin){
      pid->iState = pid->iMin;
   }

   iTerm = pid->iGain * pid->iState;  // calculate the integral term

   dTerm = pid->dGain * ( pid->dState - position);

   pid->dState = position;

   return (pTerm + dTerm + iTerm);
}


Listing 1: PID controller code

Kod:
typedef struct
{
double dState; // Last position input
double iState; // Integrator state
double iMax, iMin;
// Maximum and minimum allowable integrator state
double iGain, // integral gain
pGain, // proportional gain
dGain; // derivative gain
} SPid;
double UpdatePID(SPid * pid, double error, double position)
{
double pTerm,
dTerm, iTerm;
pTerm = pid->pGain * error;
// calculate the proportional term
// calculate the integral state with appropriate limiting
pid->iState += error;
if (pid->iState > pid->iMax) pid->iState = pid->iMax;
else if (pid->iState
<
pid->iMin) pid->iState = pid->iMin;
iTerm = pid->iGain * iState; // calculate the integral term
dTerm = pid->dGain * (position - pid->dState);
pid->dState = position;
return pTerm + iTerm - dTerm;
}
 
Arkadaşlar kolay gelsin aşağıdaki asm dosyasını hex dosyasına çevirmem gerekiyor fakat bir türlü yapamıyorum. Yardımcı olurmusunuz.
Saygılar.
 

Ekli dosyalar

  • EARTHRES411.rar
    10.5 KB · Görüntüleme: 28
Arkadaşlar PBP ile yapılmış, PID algoritmasına bir örnek, bulamadım. Yardım...
 
proton 3.5.5.2 de hazır PID komutu vardır. p,i,d oranlarını önceden tanımlıyorsunuz.
 
http://www.shawnlankton.com/2005/03/pic-pid-controller/
http://www.ccsinfo.com/forum/viewtopic.php?p=9051

Kod:
PID.c
#include <18F452.h>

#device *=16 ADC=10

#use delay(clock=20000000)

#use rs232(baud=38400,xmit=PIN_C6,rcv=PIN_C7)

#include "PID.h"

#INT_TIMER0

TIMER0_isr(){

   drive = UpdatePID(&plantPID,(plantCommand - position), position );

}


void main(){

  setup_adc_ports ( NO_ANALOGS );
  setup_adc ( ADC_OFF );
  setup_psp ( PSP_DISABLED );
  setup_spi ( FALSE );
  setup_wdt ( WDT_OFF );
  setup_timer_0 ( RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit );
  enable_INTerrupts ( INT_TIMER0 );
  enable_INTerrupts ( GLOBAL );

  setup_oscillator ( False );

  while( 1 ) {

  }
}

PID.h
typedef struct {

  signed int16 dState,     // Last position input
               iState;     // Integrator state

  signed int16 iMax,
               iMin;       // Maximum and minimum allowable integrator state

  signed int16 iGain,      // integral gain
               pGain,      // proportional gain
               dGain;      // derivative gain
} SPid;

SPid plantPID;

signed int16 plantCommand, position, drive;

//PID controller code
signed int16 UpdatePID(SPid *pid, signed int16 error, signed int16 position)
{
   signed int16 pTerm,
                dTerm,
                iTerm;

   // calculate the proportional term
   pTerm =  pid->pGain * error;   // calculate the proportional term

   // calculate the integral state with appropriate limiting
   pid->iState += error;

   if ( pid->iState > pid->iMax){
       pid->iState = pid->iMax;
   }

   else if ( pid->iState <  pid->iMin){
      pid->iState = pid->iMin;
   }

   iTerm = pid->iGain * pid->iState;  // calculate the integral term

   dTerm = pid->dGain * ( pid->dState - position);

   pid->dState = position;

   return (pTerm + dTerm + iTerm);
}


Listing 1: PID controller code

Kod:
typedef struct
{
double dState; // Last position input
double iState; // Integrator state
double iMax, iMin;
// Maximum and minimum allowable integrator state
double iGain, // integral gain
pGain, // proportional gain
dGain; // derivative gain
} SPid;
double UpdatePID(SPid * pid, double error, double position)
{
double pTerm,
dTerm, iTerm;
pTerm = pid->pGain * error;
// calculate the proportional term
// calculate the integral state with appropriate limiting
pid->iState += error;
if (pid->iState > pid->iMax) pid->iState = pid->iMax;
else if (pid->iState
<
pid->iMin) pid->iState = pid->iMin;
iTerm = pid->iGain * iState; // calculate the integral term
dTerm = pid->dGain * (position - pid->dState);
pid->dState = position;
return pTerm + iTerm - dTerm;
}


Hex dosyası mevcut mu sizde ?
 
PIC ile PID, bulanık mantık gibi kontrol uygulamalarının verildiği bir kitap var. Sanırım Nobel yayınevinden çıkmış olmalı.
 

Yeni mesajlar

Forum istatistikleri

Konular
128,180
Mesajlar
915,674
Kullanıcılar
449,946
Son üye
kerim2756

Yeni konular

Geri
Üst