Hey Archie,
Yes i have enabled "TreatDataAsHex = TRUE".
The HostLinkBaseCom.vb of AdvanceHMI3.99s has a function:
Public Overrides Function BeginWrite(ByVal address As MfgControl.AdvancedHMI.Drivers.Omron.OmronPlcAddress, ByVal dataToWrite() As String) As Integer
where you will fnd the below code:
If address.BitsPerElement = 16 Then
Dim x(1) As Byte
For i As Integer = 0 To dataToWrite.Length - 1
If m_TreatDataAsHex Then
Dim data As Integer
Try
data = Convert.ToUInt16(dataToWrite(i), 16)
Catch ex As Exception
Throw New MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException("Invalid hexadecimal value " & dataToWrite(i)) End Try
x(0) = CByte(data And 255)
x(1) = CByte(data >>
Else
x = BitConverter.GetBytes(CUShort(dataToWrite(i)))
If address.IsBCD Then
'* Convert to BCD
x(1) = CByte(CUShort(Math.Floor(CDbl(dataToWrite(i)) / 100)))
x(0) = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.HexToByte(Convert.ToString(CUShort(dataToWrite(i)) - (x(1) * 100)))
x(1) = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.HexToByte(Convert.ToString(x(1)))
End If
End If
'* Bitconverter uses LittleEndian
'* Omron uses BigEndian, so reverse
dataPacket.Add(x(1))
dataPacket.Add(x(0))
Next
Else
The line in red colour is the error thrown whenever i try to write the
String Values to CP1-E PLC
Apart from that i'm even unable to convert the String values read from PLC from hex to string readable format. I've written the code as below:
Public Sub convertToString()
Label4.Text = "" '
Label4.Text shows converted value read from PLC Try
Dim st As String = Label1.Text '
Label1.Text has the hexa value read from PLC Dim com As String = ""
For x = 0 To st.Length - 1 Step 2
Dim k As String = st.Substring(x, 2)
com &= System.Convert.ToChar(System.Convert.ToInt32(k, 16)).ToString
Next
'Label4.Text = Trim(com)
Dim s(12) As Char
s = com.ToCharArray()
For i = 0 To s.Length - 1
TextBox2.Text += com
Next
Catch ex As Exception
'MsgBox(ex.Message)
'Label4.Text = ex.Message
End Try
End Sub
The values comes to s but then i'm unable to show them in Textbox or label.
Apart from that I've buttons whose register values are W25.01, W25.02 and etc. I've tried them with buttons control of AHMI, I've tried writing them in code on button click event. But it always pops a error msg of some Header mismatch should be 2 char or something like that. I've tried using WP also instead of W but with no result.
Please Help me resolve these Problems..