Autor Tema: Servo ir acelerando  (Leído 1358 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Skualo

  • PIC10
  • *
  • Mensajes: 42
Servo ir acelerando
« en: 04 de Julio de 2008, 15:32:19 »
Código: [Seleccionar]
#include <16f877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP,PUT,BROWNOUT
#use delay(clock=4000000)
#use standard_io(b)


#define PIN_SERVO1 PIN_d5

const int AJUSTE_FINO_DE_RTCC = 30;

const int ticks_PULSO_MEDIO = 93;


int1 flagRTCC = 0;
int contRTCC = 0;
int1 flagSERVO1 = 0;
int tSERVO1 = ticks_PULSO_MEDIO;


void eco_servos(void);
void ajusta_servo(void);

#int_RTCC
RTCC_isr(){
  ++contRTCC;
  if(contRTCC==4){
    set_TIMER0(AJUSTE_FINO_DE_RTCC);
  }
  if(contRTCC==5){
    flagRTCC=1;
    contRTCC=0x00;
  }
}

void main() {
int ValTIMER0;
delay_ms(500);
tservo1=tservo1+1;

  setup_counters(RTCC_INTERNAL,RTCC_DIV_16);
  enable_interrupts(int_rda);
  enable_interrupts(global);
  set_TIMER0(0);
  enable_interrupts(INT_RTCC);
  do {



    // DISPARO DEL PULSO PWM
    if(flagRTCC==1){
      flagRTCC=0;
      output_high(PIN_SERVO1);
      flagSERVO1=1;
    }
    // CONTROL DE ANCHO DEL PULSO PWM
    if(flagSERVO1==1){
      valTIMER0 = get_TIMER0();
      if(valTIMER0>tSERVO1){
        flagSERVO1=0;
        output_low(PIN_SERVO1);
      }
    }
} while(TRUE);
}
kiero k m vaya acelerando acia un lado yo e intentado ir sumando un tick y acer una espera pero me hace cosas raras.


 

anything