Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gfoster@sdsma.com

Pages: [1]
1
Archie,
I just this minute discovered, once again, that I R A Idiot.

I'm sending a variety of data to the PLC in the same loop.
For each item: I declare the var type as object then load var with the converted value (Integer, Decimal).
I failed to include these new tags in the test to determine how to convert the value to var. They default to type Decimal. var holds the correct value. But when treated as decimal by the downstream logic it is converted to decimal.
Once I let the code now these values were integer, all is well.


:-P
regards
GF

2
Archie,
The problem is not in the conversion.

Here's how I'm testing:
All PLC comms live in a list: PLC_Pair.Key, PLC_Pair.Value

I set a breakpoint at the line with: Ethernet.Write(PLC_Pair.Key, var)
.Key and var each contain their correct value.

I let the code continue. It breaks at the same place for the next PLC_Pair.
The incorrect value appears at the PLC.

There's no logic in between the the send and the PLC. There's no logic in the PLC> Just data tables.

Help Mr. Wizard.

regards
GF

3
Here's the code to generate ASCII stuffed integers:

    Public Sub Convert_KeySeries()
        'PanelView wants a DINT array
        Dim K_Series(12) As Integer

        'initialize values = 0
        For i = 0 To Key_Series.Length
            K_Series(i) = 0
        Next

        ' pack Key Series digits into DINT as ASCII characters
        For i = 0 To Key_Series.Length - 1
            K_Series(i) = Asc(Key_Series.Substring(i, 1))
            K_Series(i) = K_Series(i) << ((3 - i Mod 4) * 8)
        Next

        Print_Code(1) = K_Series(0) Or K_Series(1) Or K_Series(2) Or K_Series(3)
        Print_Code(2) = K_Series(4) Or K_Series(5) Or K_Series(6) Or K_Series(7)
        Print_Code(3) = K_Series(8) Or K_Series(9) Or K_Series(10) Or K_Series(11)

        ConvertPrintCodeToHex()
    End Sub

    Public Sub ConvertPrintCodeToHex()
        Try
            Dim hi As String
            Dim lo As String

            hi = Hex(Print_Code(1) Mod 2 ^ 16)
            lo = Hex(Print_Code(1) / (2 ^ 16))
            Print_Code_Hex(1) = hi & lo

            hi = Hex(Print_Code(2) Mod 2 ^ 16)
            lo = Hex(Print_Code(2) / (2 ^ 16))
            Print_Code_Hex(2) = hi & lo

            hi = Hex(Print_Code(3) Mod 2 ^ 16)
            lo = Hex(Print_Code(3) / (2 ^ 16))
            Print_Code_Hex(3) = hi & lo

        Catch ex As Exception
            Print_Code_Hex(1) = "FFFFFFFF"
            Print_Code_Hex(2) = "FFFFFFFF"
            Print_Code_Hex(3) = "FFFFFFFF"

            'MsgBox("Convert Print Code to hex: " & vbCrLf & ex.Message)
        End Try
    End Sub

4
in debug mode, I can confirm that the number in the ethernet.write statement uses the desired number.

Fr'instance
825373492 goes our via ethernet.write. 825373500 shows up in PLC.
889192448 goes out.889192400 shows up.

There no PLC logic in my test setup. Just tag table.

Yeah. I'm gonna do a workaround for time being. I am concerned that the problem may show up elsewhere, but not so obviously.

I noticed that large numbers with trailing zeroes (decimal format) do not exhibit the problem. and not all large numbers result in the problem. it seems to want to 'round off' decimal numbers to the nearest 100.

thank you
GF

5
Cannot find anything that addresses this problem.

Using CompactLogix PLC ...
Application requires writing 12 ASCII characters into a DINT array. (4 characters per DINT) Why ask why?

When HMI (VB / AdvancedHMI) writes a number > 10,000,000 to PLC, then 1 or 2 right most digits are incorrect. and sometimes, left digits change in what appears to be a round-up. I have not discovered any pattern it goes through as the number becomes larger. Tho, If the right 2 digits of the incoming number are '00' then there is no error.

FYI: I discovered the 10,000,000 limit by repetitive testing.

This error does not happen when writing from PanelView.

Any clues?

At this point, I'll code a work around in the PLC. I sure would like to know why or whats happening with the AdvHMI PLC driver.

Thank you
GF

Pages: [1]