• 목록
  • 아래로
  • 위로
  • 0
  • 임꺽
  • 조회 수 3084

'****************************************************************************************************
'PLC의 워드를 읽어 BIT로 분해
'****************************************************************************************************
Sub do_Word2Bit()
 
Dim Bit(16)
 
'Bit value decare
Bit(0)  = &H1&:   Bit(1) = &H2&:   Bit(2) = &H4&:    Bit(3) = &H8&
Bit(4)  = &H10&:  Bit(5) = &H20&:  Bit(6) = &H40&:   Bit(7) = &H80&
Bit(8)  = &H100&: Bit(9) = &H200&: Bit(10)= &H400&: Bit(11) = &H800&
Bit(12) = &H1000&:Bit(13)= &H2000&:Bit(14)= &H4000&:Bit(15) = &H8000&
 
'Delay time
UDelay = 20
 
While 1
      '1.PLC에서 1개워드만를 CIMON으로읽음
      PLC_Dtag   = "WORD2BIT.PLC.ANALOG.입력01"
      PLC_DValue = GetTagVal (PLC_Dtag)
 
      '2.워드를 비트로 분해
     For i = 0 To 15
        'Bit And calculation
        CIMON_Bit = PLC_DValue And Bit(i)

        'tag name
        UTAG$ = "WORD2BIT.CIMON.DIGITAL_IN.B" + Format(I,"0#") 
       'writing to CiMON bit tag
        SetTagVal UTAG$, CIMON_Bit
     Next
 
   'Delay
    Sleep (UDelay)

WEnd

End Sub

공유

facebooktwitterpinterestbandkakao story
퍼머링크

댓글 0

권한이 없습니다.