Menu

encoder

Help
2024-01-21
2024-01-21
  • luisgoenaga

    luisgoenaga - 2024-01-21

    he buscado un fichero donde me me dice que source es el pin para contar y porb es la salida
    no me funciona

    Chip Settings

    chip 16F84A,4

    config OSC=XT, PWRTE=ON

    ;DEFINICIONES

    define GATE PORTA.0

    define SOURCE PORTA.1

    define out0 PORTA.2

    define led PORTA.3

    ;Variables
    Dim COUNTREG As byte
    Dim SAMPLE As byte
    Dim LATCH As byte

    Dir PORTA.0 In
    Dir PORTA.1 in
    Dir PORTA.2 Out
    Dir PORTA.3 Out
    dir PORTB out
    COUNTREG = 0
    out0 = 0
    SAMPLE = 0
    LATCH = 0
    Set PORTA.3 On
    wait 1 s
    Set PORTA.3 Off
    wait 1 s
    main:
    PORTB = COUNTREG
    if COUNTREG=10 then
    out0 = 1
    wait 1 ms
    COUNTREG = 0
    out0 = 0
    end if
    if GATE=1 then
    SAMPLE = SOURCE
    if LATCH=SAMPLE then
    goto main
    end if
    if LATCH=0 then
    LATCH = 1
    COUNTREG = COUNTREG+1
    goto main
    end if
    if LATCH=1 then
    LATCH = 0
    goto main
    end if
    end if
    goto main

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.