martes, 10 de mayo de 2011

Subrutina "PWM"

;subrutinas
DELAY11:                      CLR TMR1 ;PRIMER DELAY POR TEMPORIZACION PARA PWM
DELAY1:                         MOV #1953,W0
                                        CP TMR1
                                        BRA NZ,DELAY1
                                        RETURN

DELAYTOFF:                 CLR TMR2 ;DELAY POR TEMPORIZACION PULSO EN BAJO
DELAY2:                         MOV #78,W0
                                        CP TMR2
                                        BRA NZ,DELAY2
                                        RETURN

DELAYTON:                 CLR TMR3 ;DELAY POR TEMPORIZACION PULSO EN ALTOR
DELAY3:                         MOV W9,W0 ;EN W9 SE DEBE GUARDAR TODA LA INFORMACION
                                        CP TMR3
                                        BRA NZ,DELAY3
                                        RETURN


PWM:                              CLR TMR1 ;RUTINA PARA CONTROL PWM
                                        CLR W2
PWM1:                            NOP
                                        BSET PORTC,#14 ;puerto pwm, motor
                                        CALL DELAYTON
                                        BCLR PORTC,#14
                                        CALL DELAYTOFF
                                        MOV #1953,W0
                                        CP TMR1
                                        BRA LTU,PWM1
                                        CLR TMR1
                                        INC W2,W2
                                       MOV #3,W0;CANTIDAD DE ESPERAR DE A ACA 0.5SEGUNDOS
                                        CP W2,W0
                                        BRA NZ,PWM1
                                        BCLR PORTC,#14
                                       RETURN

A la hora de utilizar la subrutina se debe hacer asi:


                                         MOV #12,W9 ;VALOR DEL PULSO
                                         CALL PWM ;LLAMADO DE LA SUBRUTINA PWM

NOTA:

  • Se debe configurar el TIMER 1, TIMER 2 y TIMER 3 con Preescaler de 256.
  • Cuando se hace referencia a Valor del pulso es hacer una temporización por TIMER que dure el mismo tiempo de Ton para posicionar el servo en los grados deseados.

1 comentario:

  1. Cidade Gaming Online Gaming Casinos in Canada
    The most popular type of Cidade カジノ シークレット games is Pragmatic Play's excellent slots with the potential for 온라인카지노 a 우리카지노 쿠폰 big jackpot, with progressive jackpots ranging from

    ResponderBorrar