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 - halosome

Pages: [1] 2 3
1
I was thinking I might save a reading, but your way is more straight forward.

2
It seems working! I will test it tomorrow.

Thank you!

3
Hello Godra and Archie, please help.

It seems most of the problems are solved except this one, I really need help in solving this issue because I would like to create one page for several same devices (their Modbus addresses are the only difference). Once I select a device, the device base address plus offsets will be applied to all the display components. But currently they all stick to the address at the form designer.


4
Thanks a lot Godra,

I have got a pretty easy solution. For example I would manipulate the bit 15 of integer PLC:40001.

1) Add a sub to existing odmeter control as the end of the post:
2) Create a hidden odometer1 -> PLC:40001
3) Create a button, in button_click, just call odometer1.setbit(15)

    Public Sub SetBit(ByVal b_Num As Integer)
        Try
            m_ComComponent.Write(m_PLCAddressKeypad, Value Or 2 ^ (b_Num - 1))
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show("Failed to write value. " & ex.Message)
        End Try
    End Sub

5
You got it. I left form10's driver to 0.0.0.0.

Thanks Archie!

6
I try to make it simple so I directly drag the controls in the form, but when I change the controls' PLCaddress, the value not changed, it sticks to the one from the address in the form designer.

Dim addr1 as integer = 40001
Dim addr2 as integer = 40011
If DeviceID=1 then
Odometer1.PLCAddressValue.PLCAddress = addr1.ToString
Odometer2.PLCAddressValue.PLCAddress = (addr1+1).ToString
Else
Odometer1.PLCAddressValue.PLCAddress = addr2.ToString
Odometer2.PLCAddressValue.PLCAddress = (addr2+1.ToString
End If

7
Thank you both.

Its right, I tried the code, it works.  But there is another problem now, the modbustcp.beginread which i call every 100mS pops up an exception:

MFgControls.advancedHMI.driver.comm.PLCDriverException: 'ModbusTCP SendData DLL Instance not Created.

The BeginRead is calling from the MainForm, the add controls code is in Form10. If I don't show form10, everything is OK, if I show Form10, the exception pops up right away.

8
Thanks Godra,

I try to click a button and change one bit of the plc:40001, lets say bit 2.

so I create an odometer and the PLCaddress =40001, also PLCaddressKeyboard = 40001; (I can click on it and modify the values but I want to use a button, not with the keypad)

when I click on a button, I will use odometer.value OR 0000010 (bit 2) and somehow send to odometer,  and directly trigger the odometer.write.

In this way I can change a bit of PLC:40001, instead of using ModbusTCP function 22, bit mask write. However, I don't know how to write this program.

9
Open Discussion / Bit set in integer walk arround - button write to odometer
« on: September 29, 2019, 05:41:10 PM »
Lets say that we have a odometer, reads/writes to PLC: 40001

is it possible to program a button, the button_click triggers a sub, bit and odometer's value with 00000000001 and send this value to PLC by triggering the odometer write?

10
        SS10 = New AdvancedHMIControls.SevenSegment2
        SS11 = New AdvancedHMIControls.SevenSegment2
        SS12 = New AdvancedHMIControls.SevenSegment2

        SS10.Location = New Point(400, 160)
        SS11.Location = New Point(400, 220)
        SS12.Location = New Point(400, 280)

        SS10.ForeColorInLimits = SystemColors.Info
        SS11.ForeColorInLimits = SystemColors.Info
        SS12.ForeColorInLimits = SystemColors.Info

        SS10.BackColor = SystemColors.Window

        SS10.PLCAddressValue = New Drivers.PLCAddressItem("43006,1,,,0.1,0")
        SS11.PLCAddressValue = New Drivers.PLCAddressItem("43008,1,,,0.1,0")
        SS12.PLCAddressValue = New Drivers.PLCAddressItem("43010,1,,,0.1,0")

        Me.Controls.Add(SS10)
        Me.Controls.Add(SS11)
        Me.Controls.Add(SS12)

        Me.Refresh()

11
Is it possible to assign the PLCAddress on those displayers in programming? I tried use to integers or strings ("41001") and they all failed.

I am trying to use a group of displayers to show several groups of devices by selecting different ModbusTCP Addresses.

12
It's Productivity P2000 PLC. I am not sure if it support bit mask write. But if it supports, how can AHMI run code 22? I checked but don't see any method under ModbusTCPCom related to code numbers.

13
Thanks it works!

There is another question, is it possible if i click the MomentaryButton, and it change a bit in an integer of a PLC address? Some thing like a PLC address to be 40001:10?


14
Open Discussion / Decimal on number displayer, SevenSegment2 and Odometer
« on: September 27, 2019, 08:00:30 PM »
My PLC use integer for float (x10), for example 123 means 12.3

I tried to manipulate SevenSegment2 and Odometer and they seem to be unable to display 12.3; The digitalPanelMeter can show 12.3 by setting decimalPosition to 1.

Anything I have missed? Or is there any around way?

Thanks

15
Support Questions / Re: Need help on ModbusTCPCom
« on: September 26, 2019, 06:52:05 PM »
I only wrote the select case but when I ran the program I realized the timeout and comm broken problems. Since you mentioned it, i just write a sample code for people who wants to have a look:


    Private Sub PLC_Read_Timer_Tick(sender As Object, e As EventArgs) Handles PLC_Read_Timer.Tick
         '100mS Timer

        PLC_Scan = IIf(PLC_Scan >= 9, 0, PLC_Scan + 1)

        Try

            Select Case PLC_IO_Scan
            Case 0
                 '
            Case 1
                ModbusTCPCom1.BeginRead("40001", 32)
            Case 2
                ModbusTCPCom1.BeginRead("43001", 32)
            Case 3
                ModbusTCPCom1.BeginRead("43101", 32)
            Case 4
                ModbusTCPCom1.BeginRead("40001", 32)
            Case 5
                ModbusTCPCom1.BeginRead("43001", 32)
            Case 6
                ModbusTCPCom1.BeginRead("43101", 32)
            Case 7
                ModbusTCPCom1.BeginRead("40001", 32)
            Case 8
                ModbusTCPCom1.BeginRead("43001", 32)
            Case 9
                ModbusTCPCom1.BeginRead("43101", 32)
            Case Else
                '
        End Select
        Catch ex As Exception
            ‘MessageBox.Show("Alarm: PLC Cannot be read!!")
        End Try

    End Sub

    Private Sub ModbusTCPCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles ModbusTCPCom1.DataReceived
        Dim ind As Integer = 0


Comm_WatchDog_Timer.Enabled = False

        Select Case e.PlcAddress
            Case "40001"
                ‘MessageBox.Show("PLC_Address = 40001”)
            Case "43101"
                For ind = 0 To 31
                    PC_Array(ind) = CInt(e.Values(ind))
                Next
            Case "43133"
                ‘MessageBox.Show("PLC_Address = 40001”)

            Case Else
                ‘MessageBox.Show("PLC_Error”)
        End Select

Comm_WatchDog_Timer.Enabled = True

    End Sub


    Private Sub Comm_WatchDog_Timer_Tick(sender As Object, e As EventArgs) Handles Comm_WatchDog_Timer.Tick
                      '5000mS Timer
                      ‘MessageBox.Show("Comm Timeout”)
    End Sub

Pages: [1] 2 3