Recent Posts

Pages: 1 ... 7 8 [9] 10
81
Open Discussion / ON/OFF Button for bit in a register Modbus TCP
« Last post by Nikola Tesla on February 05, 2024, 01:18:02 PM »
Hi, I'm new with VB and I was looking for some forum posts to create a couple of buttons for an application. The first button is to set to 1 independent bits of a modbus tcp register and for that I have used Godra's code in another post:

Private Sub BasicButton1_Click(sender As Object, e As EventArgs) Handles BasicButton1.Click
    Try
        Dim b_Num As Integer = 1 'or if dynamically changing then call it from a TextBox, like: Dim b_Num As Integer = TextBox1.Text
        Dim Value = Me.ModbusTCPCom1.Read("40001")
        Me.ModbusTCPCom1.Write("40001", Value Or 2 ^ (b_Num - 1))
    Catch ex As Exception
        System.Windows.Forms.MessageBox.Show("Failed to write value. " & ex.Message)
    End Try

 The second button I created to disable the bit of the word I enabled earlier and for this I used the same Godra code and changed the following command:

Me.ModbusTCPCom1.Write("40001", Value - 2 ^ (b_Num - 1)).

The off button is only connected and appears on screen if the bit it disables is set to 1, but if you quickly hit the button before the associated bit is disabled, it is able to subtract more than once the same bit, how could I avoid it to subtract more than once and not modify the register in a wrong way? Can you think of another way to create an off/on button for independent bits of a register?

82
Feature Request / Re: Multiple StationAddress from one ModbusRTUCom in one Form
« Last post by fayeq on February 05, 2024, 01:47:59 AM »
up
83
Open Discussion / 1756-L81E 5580 Controller f/s
« Last post by kingparmer on February 02, 2024, 09:44:57 AM »
Have an extra controller still in factory sealed box, It was ordered for a project and ended up not needing.

$2500 obo

LMK if anyone is interested.
84
Support Questions / Re: System.StackOverflowException while trying to closed form
« Last post by thunting on February 01, 2024, 08:08:58 AM »
Sorry, I found my answer. Thanks for the help

Here is the link for the answer to my question.
https://www.advancedhmi.com/forum/index.php?topic=303.msg1069#msg1069
85
Support Questions / Re: System.StackOverflowException while trying to closed form
« Last post by thunting on February 01, 2024, 08:07:20 AM »
I noticed after removing the above listed code from the forms, other than the Main, the application does not close. I realize this is what Archie mentions in his post, but I'm unsure how to fix the application not closing from other forms than the Main. Or is the expected method to remove the "close" button from the title bar of the other forms and force users to return to the Main form to close the application? Any suggestions?
86
Support Questions / Re: System.StackOverflowException while trying to closed form
« Last post by thunting on January 31, 2024, 05:30:42 PM »
Thanks Archie, that fixed it.
87
Support Questions / Re: System.StackOverflowException while trying to closed form
« Last post by Archie on January 30, 2024, 05:17:48 PM »
That piece of code should only be in the MainForm or the Mainmenu form, which would be the only form being closed to exit the application.
88
Support Questions / System.StackOverflowException while trying to closed form
« Last post by thunting on January 30, 2024, 04:47:22 PM »
Hello,
I keep getting an exception when I close any form in my application. Here are the details:

System.StackOverflowException
  HResult=0x800703E9
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

The call stack trace shows a loop of 521 times while running the stock code listed below. The exception is thrown at My.Application.OpenForms(index).Close().

Thanks for any help

Code: [Select]
    '***************************************************************
    '* .NET does not close hidden forms, so do it here
    '* to make sure forms are disposed and drivers close
    '***************************************************************
    Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing

        Dim index As Integer
        While index < My.Application.OpenForms.Count
            If My.Application.OpenForms(index) IsNot Me Then
                My.Application.OpenForms(index).Close()
            End If
            index += 1
        End While

    End Sub
89
Support Questions / Re: EthernetIPforSLCMicroCom Conect to Micrologix 1400
« Last post by Archie on January 30, 2024, 04:44:38 PM »
can you ping the IP address?
90
Support Questions / EthernetIPforSLCMicroCom Conect to Micrologix 1400
« Last post by Fer-Vargas on January 30, 2024, 04:38:16 PM »
I Have been reading the question and post, and I know this may be an old question for all.

Could you please help me understand how to use EthernetIPforSLCMicroCom or send me a manual to read?

I am trying to connect to a Micro 1400 and it shows me that I have an error, with the connection regarding either the IP of plc Issue or the Port number on the driver.

Also If you help me understand if on the reader I can ask for the address ("N19:0")? or if I need to use a specific address for those registers?

Pages: 1 ... 7 8 [9] 10