Menu

Get bit from PLC

Help
zamsz
2012-02-26
2012-09-18
  • zamsz

    zamsz - 2012-02-26

    I have "I0_0" object. Connected to PLC and procedure I0_0ValueChange works
    fine, but haw to get bit status 0 or 1 from this object?

     
  • Fabio Luis Girardi

    First: What's your PascalSCADA version?

    You tried I0_0.Value?

    Your component connections are one of:

    TCPUDP_Port <- ISOTCPProtocol <- PLCTagNumber <- TagBit or

    TCPUDP_Port <- ISOTCPProtocol <- PLCBLock <- PLCBlockElement <- TagBit or

    TCPUDP_Port <- ISOTCPProtocol <- PLCStruct <- PLCStructElement <- TagBit

    Depending of your version and where you are trying get the tag bit value, by
    example, OnValueChangeFirst of the Tag PLCTagNumber, you will get the wrong
    value of I0_0 bit.

    The Best Regards,

    Fabio

     
  • zamsz

    zamsz - 2012-02-26

    I tested PascalSCADA 0.7.2 on Lazarus. My connect is TCPUDP_Port <-
    ISOTCPProtocol <- PLCTagNumber <- TagBit.

    I0_0 is a first digital input pin on my PLC (S7-1200).

    I tested libnodave and i get bit status with function
    "b:=NoDave1.GetBit(0,0);" wher b is boolean

    I suspect the same on b:=I0_0.value but get double variable.

    Haw get bit status on boolean type?

     
  • Fabio Luis Girardi

    Ah... Your problem is this...

    How any tag is a descendant of TPLCNumber (including TTagBit) you will get the
    value of TTagBit on Value property (a double)

    The reason of this, is because you can map a group of bits (TTagBit mapping
    bits from 0 to 3, mapping a nibble from a byte, word, ...). See properties
    StartBit and EndBit. Because of this, TTagBit.Value is a Double.

    To get it as Boolean do:

    booleanVar := I0_0.Value<>0;

     
  • zamsz

    zamsz - 2012-02-26

    I understand. Thanks for quick reply.

    Next question. My aplication activate connection i set properties
    "TCP_UDPPort1.Active:=True;" on FormCreate procedure. If necessary deactivate
    connection TCP_UDPPort1.Active:=False; when i close aplication? When i
    deactivate connection my aplication frozen.

     
  • Fabio Luis Girardi

    No, you don't need close the connection. TCPUDP_Port does it automatically
    when it's destroyed. And yes, depending of your system configuration, it will
    freeze (I fixed some of these freezes on the next version).

    Please tell-me, are you running the application on a single-core system (one
    processor with one core)? What's the OS?

     

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.