TODOPIC

Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: CarloS_32 en 06 de Febrero de 2011, 17:27:46

Título: Programa para motor PAP q se pasa un par de pasos
Publicado por: CarloS_32 en 06 de Febrero de 2011, 17:27:46
Hola..tengo un problema..uso el sig. programa para probar motores de pasos unipolares de 12V o mas sin L297 ni nada..tengo pulsadores q me permiten cambiar el sentido de giro,la velocidad y la cantidad de pasos a dar en cada caso..asi pude probar q el motor es de 48 pasos..pues le hacia dar 1 o 2 vueltas a diferentes velocidades y nunca perdia un paso asi lo probe una noche y bien, (la velocidad máxima es 500 pps maso menos) el problema surge cuando intento hacerlo girar mas vueltas cada vez de 5 hasta 20 (hace el ciclo de vueltas se para 1 seg. y arranca de vuelta) en el caso de 5 pierde 4 pasos en el caso de 20 pierde 16 pasos, no creo q sea un problema de error q se vaya acumulando a medida q da más pasos me parece q es por la variable PUNTERO q pasa el problema..me parece q cuando acepta otro nº de vueltas no apunta donde debiera apuntar y se pierden pasos,probe incrementar PUNTERO en int_ext pero no sirvio

Código: CSS
  1. #include <16f877a.h>
  2. #fuses HS,NOPROTECT,NOWDT,PUT,NOLVP,BROWNOUT
  3. #use delay(clock=20M)
  4. #include <flex_lcd.c>
  5. #byte portb=6
  6. #byte portc=7
  7. #byte portd=8
  8. #use standard_io(b)
  9. #use fast_io(c)
  10. #use fast_io(d)
  11. #define VEL_CRYSTAL 0.000000200
  12. #define PASOS_VUELTA_PAP 48
  13.  
  14. boolean flagOK=FALSE,flagDistancia=FALSE,flagVelocidad=FALSE,flagSentido=FALSE;
  15. int punteroDistancia=0,punteroVelocidad=0,punteroSentido=0,interrupciones=0,last_b,lastb=0b11110001,PUNTERO=0;
  16. unsigned long PASOS=300,CARGAT1=45000,NEW_PASOS=0,VUELTAS=0;
  17. float TIEMPO=0,PPS=0;
  18.  
  19. void secuencia_PCHorario(void);
  20. void secuencia_PCAntihorario(void);
  21. void resetLCD(void);
  22. void calculo_Velocidad(void);
  23.  
  24. #INT_TIMER1
  25. RSI_tmr1()
  26. {
  27. set_timer1(CARGAT1);
  28. PASOS--;
  29. }
  30.  
  31. #INT_EXT
  32. RSI_intext()
  33. {
  34. while(!input(PIN_B0))
  35.    {
  36.    if(interrupciones==TRUE)
  37.       {
  38.       resetLCD();
  39.       lcd_putc("Ok!");
  40.       delay_ms(100);
  41.       }
  42.    }
  43.       if(interrupciones==TRUE)
  44.       {
  45.       //PUNTERO=0;
  46.       flagOK=TRUE;
  47.       interrupciones=FALSE;
  48.       resetLCD();
  49.       PASOS=NEW_PASOS;
  50.       printf(lcd_putc,"PASOS=\n%lu",PASOS);
  51.       }
  52.       else if(interrupciones==FALSE)
  53.       {
  54.       flagOK=FALSE;
  55.       flagVelocidad=FALSE;
  56.       flagDistancia=FALSE;
  57.       flagSentido=FALSE;
  58.       }
  59. //portc=0;      
  60. set_timer1(CARGAT1);      
  61. enable_interrupts(INT_TIMER1);        
  62. }
  63.  
  64. #INT_RB
  65. RSI_rb()
  66. {
  67. byte changes;
  68. changes=last_b ^ portb;
  69.  
  70. if(lastb == portb)
  71. interrupciones=TRUE;
  72. else
  73. {
  74. interrupciones=FALSE;
  75. }
  76. last_b=portb;
  77. lastb=portb;
  78.    if ( bit_test(changes,4) && !bit_test(last_b,4) )
  79.    {
  80.    while(!input(PIN_B4))
  81.       {
  82.       }
  83.       delay_ms(50);
  84.       if(interrupciones==FALSE)
  85.       {
  86.       resetLCD();
  87.       lcd_putc("Sentido\nGiro");
  88.       }
  89.       flagOK=FALSE;
  90.       flagVelocidad=FALSE;
  91.       flagDistancia=FALSE;
  92.       flagSentido=TRUE;
  93.       if((++punteroSentido) == 3)
  94.       punteroSentido=1;
  95.    }
  96.    
  97.    else if( bit_test(changes,5) && !bit_test(last_b,5) )
  98.    {
  99.    while(!input(PIN_B5))
  100.       {
  101.       }
  102.       delay_ms(50);
  103.    }
  104.    
  105.    else if ( bit_test(changes,6) && !bit_test(last_b,6) )
  106.    {
  107.    while(!input(PIN_B6))
  108.       {
  109.       }
  110.       delay_ms(50);
  111.       if(interrupciones==FALSE)
  112.       {
  113.       resetLCD();
  114.       lcd_putc("Ingrese\nPasos");
  115.       }
  116.       flagOK=FALSE;
  117.       flagVelocidad=FALSE;
  118.       flagDistancia=TRUE;
  119.       flagSentido=FALSE;
  120.       if((punteroDistancia++) == 5)
  121.       punteroDistancia=1;
  122.    }
  123.    
  124.    else if ( bit_test(changes,7) && !bit_test(last_b,7) )
  125.    {
  126.    while(!input(PIN_B7))
  127.       {
  128.       }
  129.       delay_ms(50);
  130.       if(interrupciones==FALSE)
  131.       {
  132.       resetLCD();
  133.       lcd_putc("Ingrese\nVel");
  134.       }
  135.       flagOK=FALSE;
  136.       flagVelocidad=TRUE;
  137.       flagDistancia=FALSE;
  138.       flagSentido=FALSE;
  139.       if((punteroVelocidad++) == 13)
  140.       punteroVelocidad=1;
  141.    }
  142. set_timer1(CARGAT1);  
  143. disable_interrupts(INT_TIMER1);  
  144. portb=0b11110001;
  145. }
  146.  
  147. void main(void)
  148. {
  149.    set_tris_b(0b11110001);
  150.    port_b_pullups(TRUE);
  151.    portb=0b11110001;
  152.    ext_int_edge( 0,H_TO_L );
  153.    setup_timer_1 (T1_INTERNAL|T1_DIV_BY_8);
  154.    set_tris_c(0);
  155.    set_tris_d(0);
  156.    lcd_init();
  157.    portd=0;
  158.    lcd_gotoxy(1,1);
  159.    printf(lcd_putc,"Ingrese\nParametr");
  160.    delay_ms(1000);
  161.    enable_interrupts(INT_EXT);
  162.    input(PIN_B1);
  163.    enable_interrupts(INT_RB);
  164.    enable_interrupts(GLOBAL);
  165.    last_b=0b11110001;
  166.  
  167.       while(1)
  168.       {
  169.       last_b=portb;
  170.          
  171.          if ((interrupciones==TRUE) && (flagDistancia==TRUE))
  172.          {
  173.          flagDistancia=0;
  174.             switch (punteroDistancia)
  175.             {
  176.                case 1:
  177.                {
  178.                VUELTAS=1;
  179.                }
  180.                break;
  181.                case 2:
  182.                {
  183.                VUELTAS=2;
  184.                }
  185.                break;
  186.                case 3:
  187.                {
  188.                VUELTAS=5;
  189.                }
  190.                break;
  191.                case 4:
  192.                {
  193.                VUELTAS=10;
  194.                }
  195.                break;
  196.                case 5:
  197.                {
  198.                VUELTAS=20;
  199.                }
  200.                break;  
  201.             }
  202.             resetLCD();
  203.             printf(lcd_putc,"Dis/Mot\nVuel=%lu",VUELTAS);
  204.             NEW_PASOS=(PASOS_VUELTA_PAP*VUELTAS);
  205.          }
  206.          if ((interrupciones==TRUE) && flagVelocidad==TRUE)
  207.          {
  208.          flagVelocidad=0;
  209.             switch (punteroVelocidad)
  210.             {
  211.                case 1:
  212.                {
  213.                CARGAT1=35000;
  214.                }
  215.                break;
  216.                case 2:
  217.                {
  218.                CARGAT1=37500;
  219.                }
  220.                break;
  221.                case 3:
  222.                {
  223.                CARGAT1=40000;
  224.                }
  225.                break;
  226.                case 4:
  227.                {
  228.                CARGAT1=42500;
  229.                }
  230.                break;
  231.                case 5:
  232.                {
  233.                CARGAT1=45000;
  234.                }
  235.                break;
  236.                case 6:
  237.                {
  238.                CARGAT1=47500;
  239.                }
  240.                break;
  241.                case 7:
  242.                {
  243.                CARGAT1=50000;
  244.                }
  245.                break;
  246.                case 8:
  247.                {
  248.                CARGAT1=52500;
  249.                }
  250.                break;
  251.                case 9:
  252.                {
  253.                CARGAT1=55000;
  254.                }
  255.                break;
  256.                case 10:
  257.                {
  258.                CARGAT1=57500;
  259.                }
  260.                break;  
  261.                case 11:
  262.                {
  263.                CARGAT1=60000;
  264.                }
  265.                break;
  266.                case 12:
  267.                {
  268.                CARGAT1=62500;
  269.                }
  270.                break;  
  271.                case 13:
  272.                {
  273.                CARGAT1=62800;
  274.                }
  275.                break;  
  276.             }
  277.             resetLCD();
  278.             calculo_Velocidad();
  279.          }
  280.          if ((interrupciones==TRUE) && (flagSentido==TRUE))
  281.          {
  282.          flagSentido=0;
  283.          resetLCD();
  284.             switch (punteroSentido)
  285.             {
  286.                case 1:
  287.                {
  288.                lcd_putc("Giro    \nHorario ");
  289.                }
  290.                break;
  291.                case 2:
  292.                {
  293.                lcd_putc("Giro    \nAntiHor.");
  294.                }
  295.                break;
  296.             }  
  297.          }
  298.          
  299.             while (flagOK)
  300.             {
  301.             if((punteroSentido==1) && PASOS !=0)
  302.             secuencia_PCHorario();
  303.             else if((punteroSentido==2) && PASOS !=0)
  304.             secuencia_PCAntihorario();
  305.             else
  306.             secuencia_PCHorario();
  307.             if(PASOS == 0)                        
  308.             {
  309.             disable_interrupts(INT_TIMER1);
  310.             PASOS=NEW_PASOS;
  311.             //portc=0;
  312.             delay_ms(1000);                     //Original 200.
  313.             lcd_putc("\f");
  314.             printf(lcd_putc,"PASOS=\n%lu",PASOS);
  315.             set_timer1(CARGAT1);
  316.             enable_interrupts(INT_TIMER1);
  317.             }
  318.             }    
  319.       }
  320. }
  321.  
  322. void secuencia_PCHorario(void)
  323.    {
  324.    if(PUNTERO == 4)
  325.    PUNTERO=0;
  326.    if(PASOS)
  327.    {
  328.       switch(PUNTERO)
  329.       {
  330.       case 0:
  331.       {
  332.       portc=0b11000000;
  333.       }
  334.       break;
  335.       case 1:
  336.       {
  337.       portc=0b01100000;
  338.       }
  339.       break;
  340.       case 2:
  341.       {
  342.       portc=0b00110000;
  343.       }
  344.       break;
  345.       case 3:
  346.       {
  347.       portc=0b10010000;
  348.       }
  349.       break;
  350.       }
  351.    }  
  352.    }
  353.    
  354. void secuencia_PCAntihorario(void)
  355.    {
  356.    if(PUNTERO == 4)
  357.    PUNTERO=0;
  358.       switch(PUNTERO)
  359.       {
  360.       case 0:
  361.       {
  362.       portc=0b00110000;
  363.       }
  364.       break;
  365.       case 1:
  366.       {
  367.       portc=0b01100000;
  368.       }
  369.       break;
  370.       case 2:
  371.       {
  372.       portc=0b11000000;
  373.       }
  374.       break;
  375.       case 3:
  376.       {
  377.       portc=0b10010000;
  378.       }
  379.       break;
  380.       }  
  381.    }
  382.    
  383. void resetLCD(void)
  384.    {
  385.    lcd_putc("\f");
  386.    lcd_gotoxy(1,1);
  387.    delay_ms(50);
  388.    }
  389.    
  390. void calculo_Velocidad(void)
  391.    {
  392.    TIEMPO =(65535 - CARGAT1)/2;
  393.    TIEMPO =(TIEMPO * 8)* VEL_CRYSTAL;
  394.    PPS = 1/TIEMPO;
  395.    printf(lcd_putc,"Vel/Mot\npps=%lu ",(unsigned long)PPS);
  396.    }
Título: Re: Programa para motor PAP q se pasa un par de pasos
Publicado por: korpaztk en 07 de Febrero de 2011, 11:30:44
con motores paso a paso no tengo demasiada experiencia, el unico proyecto a mediana escala fue una pequeña cocina solar con seguidor solar en 2 ejes comandados por paso a paso, hay algunos motores de ese estilo que cuando uno quiere hacerlos girar mas rapido se ´´frenan´´ porque es muy rapido la frecuencia de exitacion en las bobinas y no alcanzan a dar los pasos que unos los coloca, tambien tiene mucho que ver de la manera que exites sus bobinas, ya que puedes alimentar con positivo un solo terminal de una bobina para darle giro nomas, como puedes darle a 2 bobinas para que tenga mas fuerza..
no creo q mi comentario t ayude pero bueno es solo una opinion personal
Título: Re: Programa para motor PAP q se pasa un par de pasos
Publicado por: CarloS_32 en 07 de Febrero de 2011, 15:54:55
Hola gracias por tu interés..no creo q es un problema de tiempo (igual no tengo su hoja de datos) pero entre los 100pps y los 500 o 600 pps tiene que andar sin problemas como la mayoria de los pap, tengo un par de if que dependiendo de la carga del timer puede estarse ejecutando justo antes de dispararse su interrupción y retornar a el despues de ella antes de ejecutar el sig.paso lo cual me haria perder un par de instrucciones deben ser 5 o 6 en asm..no llegaria a 1 µ por paso, en el peor caso y a la mayor velocidad (doy digamos 500 pasos y retardo de 4 ms por paso o sea 250 pps) estaria perdiendo 0.25 ms = los pasos se darian,afectaria a la velocidad nomas..creo q el problema pasa por la variable PUNTERO,probé dejar libre el estator o sea desenergizarlo y arrancar de 0 para q no quede en retención esperando el sig.paso correcto ahora lo voy a armar lo voy a probar y te cuento..
Título: Re: Programa para motor PAP q se pasa un par de pasos
Publicado por: CarloS_32 en 09 de Febrero de 2011, 19:30:47
Lo he conseguido..el 1º programa no funciona no sumaba la variable PUNTERO en int_tmr1 ya he conseguido al menos la repetitibilidad o sea q se termine en el mismo lugar de donde arranca..parece que a nadie le interesa pero POR LAS DUDAS LO COMPARTO por si alguien esta haciendo algo parecido y le sirve o si me quiere aconsejar mejoras pongo el programa modificado q funciona..gracias y saludos  :)

Código: CSS
  1. #include <16f877a.h>
  2. #fuses HS,NOPROTECT,NOWDT,PUT,NOLVP,BROWNOUT
  3. #use delay(clock=20M)
  4. #include <flex_lcd.c>
  5. #byte portb=6
  6. #byte portc=7
  7. #byte portd=8
  8. #use standard_io(b)
  9. #use fast_io(c)
  10. #use fast_io(d)
  11. #define VEL_CRYSTAL 0.000000200
  12. #define PASOS_VUELTA_PAP 48
  13.  
  14. boolean flagOK=FALSE,flagDistancia=FALSE,flagVelocidad=FALSE,flagSentido=FALSE,ciclo=FALSE;
  15. int punteroDistancia=0,punteroVelocidad=0,punteroSentido=0,interrupciones=0,last_b,lastb=0b11110001,PUNTERO=0;
  16. unsigned long PASOS=300,CARGAT1=45000,NEW_PASOS=0,VUELTAS=0;
  17. float TIEMPO=0,PPS=0;
  18.  
  19. void secuencia_PCHorario(void);
  20. void secuencia_PCAntihorario(void);
  21. void resetLCD(void);
  22. void calculo_Velocidad(void);
  23.  
  24. #INT_TIMER1
  25. RSI_tmr1()
  26. {
  27. if (ciclo)
  28. ciclo=0;
  29. else
  30. ciclo=1;
  31. set_timer1(CARGAT1);
  32.    if(PASOS!=0 && ciclo)
  33.    {
  34.       if(--PASOS == 0)
  35.       {
  36.       PASOS=NEW_PASOS;
  37.       delay_ms(1000);
  38.       }
  39.    }
  40. if(PUNTERO++ == 3)
  41. PUNTERO=0;
  42. }
  43.  
  44. #INT_EXT
  45. RSI_intext()
  46. {
  47. disable_interrupts(INT_TIMER1);
  48. while(!input(PIN_B0))
  49.    {
  50.    }
  51.    if(interrupciones==TRUE)
  52.       {
  53.       resetLCD();
  54.       lcd_putc("Ok!");
  55.       delay_ms(100);
  56.       }
  57.       if(interrupciones==TRUE)
  58.       {
  59.       flagOK=TRUE;
  60.       interrupciones=FALSE;
  61.       PASOS=NEW_PASOS;
  62.       resetLCD();      
  63.       printf(lcd_putc,"PASOS=\n%lu",PASOS*2);
  64.       }
  65.       else if(interrupciones==FALSE)
  66.       {
  67.       flagOK=FALSE;
  68.       flagVelocidad=FALSE;
  69.       flagDistancia=FALSE;
  70.       flagSentido=FALSE;
  71.       }      
  72. set_timer1(CARGAT1);      
  73. enable_interrupts(INT_TIMER1);        
  74. }
  75.  
  76. #INT_RB
  77. RSI_rb()
  78. {
  79. byte changes;
  80. changes=last_b ^ portb;
  81.  
  82. if(lastb == portb)
  83. interrupciones=TRUE;
  84. else
  85. {
  86. interrupciones=FALSE;
  87. }
  88. last_b=portb;
  89. lastb=portb;
  90.    if ( bit_test(changes,4) && !bit_test(last_b,4) )
  91.    {
  92.    while(!input(PIN_B4))
  93.       {
  94.       }
  95.       if(interrupciones==FALSE)
  96.       {
  97.       resetLCD();
  98.       lcd_putc("Sentido\nGiro");
  99.       }
  100.       flagOK=FALSE;
  101.       flagVelocidad=FALSE;
  102.       flagDistancia=FALSE;
  103.       flagSentido=TRUE;
  104.       if((++punteroSentido) == 3)
  105.       punteroSentido=1;
  106.    }
  107.    
  108.    else if( bit_test(changes,5) && !bit_test(last_b,5) )
  109.    {
  110.    while(!input(PIN_B5))
  111.       {
  112.       }
  113.    }
  114.    
  115.    else if ( bit_test(changes,6) && !bit_test(last_b,6) )
  116.    {
  117.    while(!input(PIN_B6))
  118.       {
  119.       }
  120.       if(interrupciones==FALSE)
  121.       {
  122.       resetLCD();
  123.       lcd_putc("Ingrese\nPasos");
  124.       }
  125.       flagOK=FALSE;
  126.       flagVelocidad=FALSE;
  127.       flagDistancia=TRUE;
  128.       flagSentido=FALSE;
  129.       if((punteroDistancia++) == 5)
  130.       punteroDistancia=1;
  131.    }
  132.    
  133.    else if ( bit_test(changes,7) && !bit_test(last_b,7) )
  134.    {
  135.    while(!input(PIN_B7))
  136.       {
  137.       }
  138.       if(interrupciones==FALSE)
  139.       {
  140.       resetLCD();
  141.       lcd_putc("Ingrese\nVel");
  142.       }
  143.       flagOK=FALSE;
  144.       flagVelocidad=TRUE;
  145.       flagDistancia=FALSE;
  146.       flagSentido=FALSE;
  147.       if((punteroVelocidad++) == 13)
  148.       punteroVelocidad=1;
  149.    }
  150. delay_ms(5);  
  151. disable_interrupts(INT_TIMER1);  
  152. portb=0b11110001;
  153. }
  154.  
  155. void main(void)
  156. {
  157.    set_tris_b(0b11110001);
  158.    port_b_pullups(TRUE);
  159.    portb=0b11110001;
  160.    ext_int_edge( 0,H_TO_L );
  161.    setup_timer_1 (T1_INTERNAL|T1_DIV_BY_8);
  162.    set_tris_c(0);
  163.    set_tris_d(0);
  164.    lcd_init();
  165.    portd=0;
  166.    lcd_gotoxy(1,1);
  167.    printf(lcd_putc,"Ingrese\nParametr");
  168.    delay_ms(1000);
  169.    enable_interrupts(INT_EXT);
  170.    input(PIN_B1);
  171.    enable_interrupts(INT_RB);
  172.    enable_interrupts(GLOBAL);
  173.    last_b=0b11110001;
  174.  
  175.       while(1)
  176.       {
  177.       last_b=portb;
  178.          
  179.          if ((interrupciones==TRUE) && (flagDistancia==TRUE))
  180.          {
  181.          flagDistancia=0;
  182.             switch (punteroDistancia)
  183.             {
  184.                case 1:
  185.                {
  186.                VUELTAS=1;
  187.                }
  188.                break;
  189.                case 2:
  190.                {
  191.                VUELTAS=2;
  192.                }
  193.                break;
  194.                case 3:
  195.                {
  196.                VUELTAS=5;
  197.                }
  198.                break;
  199.                case 4:
  200.                {
  201.                VUELTAS=10;
  202.                }
  203.                break;
  204.                case 5:
  205.                {
  206.                VUELTAS=20;
  207.                }
  208.                break;  
  209.             }
  210.             resetLCD();
  211.             printf(lcd_putc,"Dis/Mot\nVuel=%lu",VUELTAS*4);
  212.             NEW_PASOS=(PASOS_VUELTA_PAP*VUELTAS)*2;
  213.          }
  214.          else if ((interrupciones==TRUE) && flagVelocidad==TRUE)
  215.          {
  216.          flagVelocidad=0;
  217.             switch (punteroVelocidad)
  218.             {
  219.                case 1:
  220.                {
  221.                CARGAT1=35000;
  222.                }
  223.                break;
  224.                case 2:
  225.                {
  226.                CARGAT1=37500;
  227.                }
  228.                break;
  229.                case 3:
  230.                {
  231.                CARGAT1=40000;
  232.                }
  233.                break;
  234.                case 4:
  235.                {
  236.                CARGAT1=42500;
  237.                }
  238.                break;
  239.                case 5:
  240.                {
  241.                CARGAT1=45000;
  242.                }
  243.                break;
  244.                case 6:
  245.                {
  246.                CARGAT1=47500;
  247.                }
  248.                break;
  249.                case 7:
  250.                {
  251.                CARGAT1=50000;
  252.                }
  253.                break;
  254.                case 8:
  255.                {
  256.                CARGAT1=52500;
  257.                }
  258.                break;
  259.                case 9:
  260.                {
  261.                CARGAT1=55000;
  262.                }
  263.                break;
  264.                case 10:
  265.                {
  266.                CARGAT1=57500;
  267.                }
  268.                break;  
  269.                case 11:
  270.                {
  271.                CARGAT1=60000;
  272.                }
  273.                break;
  274.                case 12:
  275.                {
  276.                CARGAT1=62500;
  277.                }
  278.                break;  
  279.                case 13:
  280.                {
  281.                CARGAT1=63300;
  282.                }
  283.                break;  
  284.             }
  285.             resetLCD();
  286.             calculo_Velocidad();
  287.          }
  288.          else if ((interrupciones==TRUE) && (flagSentido==TRUE))
  289.          {
  290.          flagSentido=0;
  291.          resetLCD();
  292.             switch (punteroSentido)
  293.             {
  294.                case 1:
  295.                {
  296.                lcd_putc("Giro    \nHorario ");
  297.                }
  298.                break;
  299.                case 2:
  300.                {
  301.                lcd_putc("Giro    \nAntiHor.");
  302.                }
  303.                break;
  304.             }  
  305.          }
  306.             while (flagOK)
  307.             {
  308.                if(punteroSentido==1)
  309.                secuencia_PCHorario();
  310.                else if(punteroSentido==2)
  311.                secuencia_PCAntihorario();
  312.                else
  313.                secuencia_PCHorario();
  314.             }
  315.                  
  316.       }
  317. }
  318.  
  319. void secuencia_PCHorario(void)
  320.    {
  321.       switch(PUNTERO)
  322.       {
  323.       case 0:
  324.       {
  325.       portc=0b11000000;
  326.       }
  327.       break;
  328.       case 1:
  329.       {
  330.       portc=0b01100000;
  331.       }
  332.       break;
  333.       case 2:
  334.       {
  335.       portc=0b00110000;
  336.       }
  337.       break;
  338.       case 3:
  339.       {
  340.       portc=0b10010000;
  341.       }
  342.       break;
  343.       }  
  344.    }
  345.    
  346. void secuencia_PCAntihorario(void)
  347.    {
  348.       switch(PUNTERO)
  349.       {
  350.       case 0:
  351.       {
  352.       portc=0b00110000;
  353.       }
  354.       break;
  355.       case 1:
  356.       {
  357.       portc=0b01100000;
  358.       }
  359.       break;
  360.       case 2:
  361.       {
  362.       portc=0b11000000;
  363.       }
  364.       break;
  365.       case 3:
  366.       {
  367.       portc=0b10010000;
  368.       }
  369.       break;
  370.       }  
  371.    }
  372.    
  373. void resetLCD(void)
  374.    {
  375.    lcd_putc("\f");
  376.    lcd_gotoxy(1,1);
  377.    delay_ms(50);
  378.    }
  379.    
  380. void calculo_Velocidad(void)
  381.    {
  382.    TIEMPO =(65535 - CARGAT1)/2;
  383.    TIEMPO =(TIEMPO * 8)* VEL_CRYSTAL;
  384.    PPS = 1/TIEMPO;
  385.    printf(lcd_putc,"Vel/Mot\npps=%lu ",(unsigned long)PPS);
  386.    }