Acquisizione di due tastiere Wiegand – Support Elsist https://support.elsist.biz/forums/topic/acquisizione-di-due-tastiere-wiegand/feed/ Fri, 30 Oct 2026 08:06:42 +0000 https://bbpress.org/?v=2.6.20 it-IT https://support.elsist.biz/forums/topic/acquisizione-di-due-tastiere-wiegand/#post-84189 Acquisizione di due tastiere Wiegand https://support.elsist.biz/forums/topic/acquisizione-di-due-tastiere-wiegand/#post-84189 Wed, 08 Oct 2025 10:06:20 +0000 Emilio Pantanali Buongiorno, ho scritto un programma per gestire due tastiere su un unico sistema SlimLine MPS056, una con ingressi su 0 ed 1, l’altra su ingressi 2 e 3. Anche dopo l’acquisto della chiave di protezione per lo sblocco dei 2 counters aggiuntivi mi da errore:

User program error:9981201

E non viene vista la seconda tastiera, questo è il programma che ho provato a scrivere

VAR
    TimeBf0 : UDINT; (* Time buffer (mS) *)
    Errors0 : UDINT; (* Error counter *)
    TAGID0 : UDINT; (* TAG ID *)
    Data0 : ARRAY[0..1] OF BOOL; (* Data status *)
    Value0 : ARRAY[0..1] OF UDINT; (* Counter value *)
    CInp0 : ARRAY[0..1] OF SysGetCounter; (* Counter acquisition *)
    CInp1 : ARRAY[0..1] OF SysGetCounter; (* Counter acquisition *)
    WDecoder0 : WiegandDcd; (* Wiegand decoder *)
END_VAR

    // *****************************************************************************
    // PROGRAM "ST_WiegandDcd_Double"
    // *****************************************************************************
    // Gestisce due lettori Wiegand separati:
    // - Lettore 1 su ingressi 0 e 1 (DATA0/DATA1)
    // - Lettore 2 su ingressi 2 e 3 (DATA0/DATA1)
    // *****************************************************************************

    IF (SysFirstLoop) THEN

        // Imposta frequenza di esecuzione del task
        eTO_JUNK(SysSetTaskLpTime(ID_TASK_FAST, 1000));

        // --- Config lettore 1 ---
        CInp0[0].Address := 255;
        CInp0[0].Channel := 0;
        CInp0[0].Mode := 16#00000000;

        CInp0[1].Address := 255;
        CInp0[1].Channel := 1;
        CInp0[1].Mode := 16#00000001;

        // --- Config lettore 2 ---
        CInp1[0].Address := 255;
        CInp1[1].Channel := 2;
        CInp1[0].Mode := 16#00000000;

        CInp1[1].Address := 255;
        CInp1[1].Channel := 3;
        CInp1[1].Mode := 16#00000001;
    END_IF;

    // ============================================================================
    // LETTORE 1
    // ============================================================================

    CInp0[0](); // Acquisizione contatore 0
    CInp0[1](); // Acquisizione contatore 1

    Data0[0] := TO_BOOL(CInp0[0].Value <> Value0[0]);
    Data0[1] := TO_BOOL(CInp0[1].Value <> Value0[1]);

    IF (Data0[0] OR Data0[1]) THEN
        Value0[0] := CInp0[0].Value;
        Value0[1] := CInp0[1].Value;
        TimeBf0 := SysTimeGetMs();

        IF (Data0[0] AND Data0[1]) THEN
            Errors0 := Errors0 + 1;
            RETURN;
        END_IF;

        WDecoder0.WBCount := WDecoder0.WBCount + 1;
        WDecoder0.WBData := WDecoder0.WBData * 2;
        IF (Data0[1]) THEN
            WDecoder0.WBData := WDecoder0.WBData OR 16#00000001;
        END_IF;
    END_IF;

    // Decodifica dopo 100 ms senza bit
    IF ((SysTimeGetMs() - TimeBf0) > TO_UDINT(T#100ms)) THEN
        WDecoder0(Enable := TO_BOOL(WDecoder0.WBCount = 26));

        IF (WDecoder0.CodeOk) THEN
            TAGID0 := TO_UDINT(WDecoder0.Facility) * 16#10000 + WDecoder0.IDNumber;
        END_IF;

        WDecoder0.WBCount := 0;
        WDecoder0.WBData := 0;
    END_IF;

    // ============================================================================
    // LETTORE 2
    // ============================================================================

    CInp1[0](); // Acquisizione contatore 0
    CInp1[1](); // Acquisizione contatore 1

    // Come lettore 1 utilizzando variabili con suffisso 1 (Es. CInp1).

// [End of file]
]]>
https://support.elsist.biz/forums/topic/acquisizione-di-due-tastiere-wiegand/#post-84194 Rispondi a: Acquisizione di due tastiere Wiegand https://support.elsist.biz/forums/topic/acquisizione-di-due-tastiere-wiegand/#post-84194 Thu, 09 Oct 2025 06:57:02 +0000 Sergio Bertana L’errore 9981201 come visibile dalla pagina elenco errori, indica “Errore impostazione modo counter” nel FB SysGetCounter.

Infatti tu hai definito Mode 16#00000000 sia per il CInp0[0] che per il CInp1[0], e 16#00000001 sia per il CInp0[1] che per il CInp1[1]. Come vedi dalla definizione di Mode nel FB SysGetCounter, la cifra meno significativa indica l’ingresso digitale da collegare al counter.

In questo modo tu hai asseegnato gli ingressi o e 1 ad entrambi i counters e questo genera l’errore. Devi modificare l’inizializzazionre dei counters in questo modo.

    IF (SysFirstLoop) THEN

        // Imposta frequenza di esecuzione del task
        eTO_JUNK(SysSetTaskLpTime(ID_TASK_FAST, 1000));

        // --- Config lettore 1 ---
        CInp0[0].Address := 255;
        CInp0[0].Channel := 0;
        CInp0[0].Mode := 16#00000000;

        CInp0[1].Address := 255;
        CInp0[1].Channel := 1;
        CInp0[1].Mode := 16#00000001;

        // --- Config lettore 2 ---
        CInp1[0].Address := 255;
        CInp1[1].Channel := 2;
        CInp1[0].Mode := 16#00000002;

        CInp1[1].Address := 255;
        CInp1[1].Channel := 3;
        CInp1[1].Mode := 16#00000003;
    END_IF;

Inoltre il Task Fast è di default già eseguito ogni 1mS quindi la definizione.

eTO_JUNK(SysSetTaskLpTime(ID_TASK_FAST, 1000));

E’ inutile, si utilizza la funzione SysSetTaskLpTime solo per modificare il tempo di esecuzione di una task.

]]>