dazed and confused
Member
Ok here is the issue. I have a machine I am developing a MMI for. Using Wonderware V.10. I am interfaced with a VME processor that talks to AutoMax. AutoMax link is on OPC and VME to MMI is DDE. Get discrete from AutoMax via OPC to VME processor. Then VME does the whole bit swap thing (AutoMax is Motorola and VME and MMI is Intel). Anyway to make a long story short I am using packed 16 bit words to pass discrete values back and forth on the DDE network. I can unpack the word just fine in wonderware using (Reflective Memory Location) . (bit number) format. Now here is where it gets interesting. I have built an excel spread sheet with all my packed words and I want to display the bit values for trouble shooting purposes. I wrote a VB script in excel to unpack the word. I can get bits 0-14 but bit 15 gets a #value error in the cell.
VB code:
Function ExamineBit (ByVal tag, ByVal MyBit) as Boolean
Dim BitMask as Integer
BitMask = 2 ^ MyBit
ExamineBit = tag and BitMask
End Function
I am thinking excel is expecting the MSB of the 16 bit word to be a sign bit. Anybody done this before?
Ok figured it out:
BitMask needs to be a Long not Integer
VB code:
Function ExamineBit (ByVal tag, ByVal MyBit) as Boolean
Dim BitMask as Integer
BitMask = 2 ^ MyBit
ExamineBit = tag and BitMask
End Function
I am thinking excel is expecting the MSB of the 16 bit word to be a sign bit. Anybody done this before?
Ok figured it out:
BitMask needs to be a Long not Integer
Last edited: