lunes, 13 de octubre de 2014

Zero Crossing con microcontrolador PIC, SCR control de compuerta con PIC12F675

Control de disparo en la compuerta de un SCR usando un PIC
Programacion en ASM


Este proyecto esta basado en la caracteristica que tiene el microcontrolador de generar una interrupcion en el pin 2 al recibir una señal que hace un cruze por cero (zero crossing).

Esquematico:


Montaje fisico realizado en 2008






Codigo fuente en ensamblador.


LIST   P=12f675

RADIX HEX

include "P12f675.inc"    ;Definiciones de registros internos

;Palabra de configuracion

__config _CPD_OFF & _BODEN_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC & _CP_OFF & _CPD_OFF


CBLOCK  0x20
duty, ContTemp, RegDelayAng1, RegDelayAng2, RegDelayPulso
ENDC
        ORG 0
goto INICIO

ORG 4  ;inicio de la subrutina de interrupcion
        btfss   INTCON,INTF            ; Si La interrupcion corresponde al RBif sigue si no regresa
        retfie
        bcf     INTCON,GIE             ; Desabilitamos el permiso global de interrupciones
        call    pulso
        Bcf     INTCON,INTF
        bsf     INTCON,GIE
        retfie
        

;include "subrutina.lib"   ; para incluir subrutinas y librerias

INICIO
    BANKSEL  OSCCAL
    call 3FFh ;Get the cal value
    movwf    OSCCAL ;Calibrate
    movlw    b'11111110'
    movwf    TRISIO
    movlw    b'01100010'
    movwf    ANSEL 
    BANKSEL  option_reg
    bsf      option_reg,6
    BANKSEL  0
    bsf      gpio,0

    movlw   b'00000101'
    movwf   ADCON0
    movlw   .10
    movwf   duty

    movlw    b'00000111'
    movwf    CMCON
    bsf      INTCON,INTE
    bsf      INTCON,intf
    bsf      INTCON,GIE
;*******************************************************************************************
; Aqui comiensa el programa
KErneL
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    call   GetAdc
    movwf  duty
    movlw  .100
    movwf  ContTemp
    decfsz ContTemp,f
    goto   $-1
    bsf      gpio,0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;*******************************************************************************************
    goto      KErneL
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; Subrutinas de retardo independientes
;*********************************************************************
; DelayAng: retardo variable para producir un angulo de disparo variable
DelayAng
        movwf      RegDelayAng1
DelayAng1
        movlw      .8
        movwf      RegDelayAng2

        decfsz     RegDelayAng2,f
        goto       $-1

        decfsz     RegDelayAng1,f
        goto       DelayAng1
        return
;*********************************************************************
; Este retardo es para el ancho del pulso de disparo
DelayPulso
        movlw     .80
        movwf     RegDelayPulso
        decfsz    RegDelayPulso,f
        goto      $-1
        return
;*********************************************************************
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GetAdc
   bsf     ADCON0,GO
   btfsc   ADCON0,GO
   goto    $-1
   movf    adresh,w
   return
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
pulso
        incf    duty,w
        movlw   .200
        call    DelayAng
        Bcf     gpio,0
        call    DelayPulso
        Bsf     gpio,0
        return



    goto      $


org 0x3ff
retlw 0x34

end


 




No hay comentarios:

Publicar un comentario