[elektro] PIC 10 bit szorzás kérdés
Huszti Andras
kyrk at villamvadasz.hu
Fri Feb 6 18:15:24 CET 2009
Hali!
C-ben nem egyszerubb?
float integrate(float in, float dt) {
static float result = 0;
if (dt != 0) {
result += in * dt;
} else {
//t.b.d. error condition
}
return result;
}
esetleg kulturaltabb lehet:
typedef struct _Integrator {
float in;
float out;
float dt;
} Integrator;
unsigned int intergrate (Integrator *integrator) {
unsigned int result = RET_ERROR;
if (integrator->dt != 0) {
integrator->out += integrator->in * integrator->dt;
integrator->out = RET_OK;
//t.b.d. overflow and underflow detection
} else {
//error condition
result = RET_ERROR;
}
return result;
}
En csinaltam regebben szabalyozastechnikai alaptagokat modulban. PID
szabalyzotol egeszen a PT1-eg minden volt benne. PIT1D1 is meg PIT0D0
is :) Kinek mi tetszik jobban.
More information about the Elektro
mailing list