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

Pages: [1] 2
1
First right click on AdvancedHMI in the Solution Explorer tab. Select Manage NuGet Packages. Click the Browse tab and search for "Plt.M2Mqtt" and install it.
At the very top of the coding page insert this:
Code: [Select]
Imports System
Imports System.Reflection.Emit
Imports System.Text
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports uPLibrary.Networking.M2Mqtt
Imports uPLibrary.Networking.M2Mqtt.Messages

At the beginning of the Public Class MainForm Declare the Client variable as follows:
Code: [Select]
Dim client As MqttClient

I also declared my variables that I moved subscribed topic messages to.
Code: [Select]
Dim client As MqttClient
 Dim t1_temp As String
 Dim t1_humidity As String

On the Private Sub MainForm_Load I inserted the following:
Code: [Select]
Try
     client = New MqttClient("<Broker IP>", 1883, False, Nothing, Nothing, MqttSslProtocols.None)

     Dim clientId As String = "HMI"

     AddHandler client.MqttMsgPublishReceived, AddressOf Client_MqttMsgPublishReceived
     AddHandler client.ConnectionClosed, AddressOf Client_Disconnect

     client.Connect(clientId, "<user name>", "<password>")

 Catch ex As Exception
     ToolStripStatusLabel1.Text = "Error mqtt connect."
     MsgBox(ex.Message(), MsgBoxStyle.Critical)
 End Try

 Try
     Dim topics() As String = {"t1_temp", "t1_humidity"}
     Dim qosLevels() As Byte = {MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE}
     client.Subscribe(topics, qosLevels)

 Catch ex As Exception
     ToolStripStatusLabel1.Text = "Error mqtt subcribe"
     MsgBox(ex.Message, MsgBoxStyle.Critical)
 End Try


I then added this sub:
Code: [Select]
Private Sub Client_MqttMsgPublishReceived(ByVal sender As Object, ByVal e As MqttMsgPublishEventArgs)
    If e.Topic = "t1_temp" Then
        t1_temp = System.Text.Encoding.UTF8.GetString(e.Message)
    ElseIf e.Topic = "t1_humidity" Then
        t1_humidity = System.Text.Encoding.UTF8.GetString(e.Message)

    End If
End Sub



For Publishing you can set it up in a clicked sub or a timer:

Code: [Select]
Try
     Dim Qos As Byte = 1
     client.Publish("<Topic>", Encoding.Default.GetBytes(<Variable that holds message> ), Qos, False)

 Catch ex As Exception
     ToolStripStatusLabel1.Text = "Error"
     MsgBox(ex.Message, MsgBoxStyle.Critical)
 End Try

2
 I got it to work! At least the subscribe end. If interested I will post how I did it.

3
I've been trying to get MQTT to work within AdvancedHMI with no luck as of yet. Has anyone been successful with this?

4
Additional Components / Re: Any interest in a driver for MQtt
« on: July 09, 2021, 08:07:42 PM »
I could really use it. It's such an easy way to pass data between devices. CLICK PLUS PLCs are even supporting it.

5
Feature Request / I would really like to see MQTT added.
« on: July 09, 2021, 07:51:14 PM »
I would really like to see MQTT added. It would make life so much easier.

6
Additional Components / Re: Any interest in a driver for MQtt
« on: December 12, 2020, 10:12:35 AM »
I am very interested in this. Where can I find it? Do you have instructions on how to integrate it? Been looking for something like this.

7
Support Questions / Re: Modbus TCP causing an error on main form.
« on: March 13, 2020, 02:58:23 AM »
I just saw the post about the bug in VS 19. That seems to be the issue. Just an FYI. You can get by this bug by deleting a Character from the line and then pressing undo. You can then click on the form design tab and go right in. I started closing the forms before exiting and it seems to work.

8
Support Questions / Modbus TCP causing an error on main form.
« on: March 13, 2020, 02:50:58 AM »
I am using the latest 399 release and Visual Studio 19. I open the form and build the project. Then size the form and choose the background. I then delete everything off of the form. I then go to the tools and drag the ModbusTCPCom to the form. I then click the ModbusTCPCom at the bottom of the form and set and IP address. I then Save All. I exit out of Visual Studio and try to reload the file and I get an Error screen that says:

The designer cannot process the code at line 28: Me.ModbusTCPCom1 = New AdvancedHMIDrivers.ModbusTCPCom(Me.components) The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.

I then click to it and it brings me here.


  Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.ForceItemsIntoToolBox1 = New MfgControl.AdvancedHMI.Drivers.ForceItemsIntoToolbox()
        Me.ModbusTCPCom1 = New AdvancedHMIDrivers.ModbusTCPCom(Me.components)                           <this is line 28
        CType(Me.ModbusTCPCom1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()


9
Open Discussion / Re: Linux and Com ports.
« on: May 09, 2018, 05:33:19 PM »
I think the problem is that the Plc uses USB to serial. it is showing up as ttyACM0. I am also using a USB to RS485 adapter that comes up as ttyUSB0. I currently have a test Screen where I can change com names and a label attached to the plc heartbeat bit. I have tried these names but no luck yet. I'm new to linux so I have a lot to learn.

10
Open Discussion / Linux and Com ports.
« on: May 08, 2018, 08:40:34 PM »
Hi. I'm trying to get my HMI to work on a Raspberry Pi 3. I got the HMI to run in MONO but I'm not sure how to address the com ports. Using the command lsusb it list my plc on bus 001 Device 7. On my Windows PC it was Com3. Is this something that needs to be set up in mono or do I need to address this as differently in AdvancedHMI to get it to work?

11
Tips & Tricks / Re: AdvancedHMI on a Raspberry Pi
« on: May 08, 2018, 11:53:26 AM »
I started over and reinstalled everything and it is running now so I must have missed something the first time. Thanks.


12
Tips & Tricks / Re: AdvancedHMI on a Raspberry Pi
« on: May 05, 2018, 04:58:03 AM »
Hi. I'm trying to get AvancedHmi to run on a Raspberry pi 3. I installed Raspbain and managed to get mono installed (I think) but it still is not working. This is what I get when I try to run it.

The entry point method could not be loaded due to Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:(null) signature:<none>

Do you have an updated procedure to get this to work? Debian Wheezy is not listed for download anymore on the Pi website.

13
Open Discussion / Re: Advance HMI and Android HMI
« on: April 15, 2018, 04:52:20 PM »
Using ModRSsim2 as a server is working out well. Thanks for the suggestion,  DougLyons.


14
Open Discussion / Re: Advance HMI and Android HMI
« on: April 14, 2018, 11:42:56 AM »
Thanks. I will research this a bit.

15
Open Discussion / Advance HMI and Android HMI
« on: April 13, 2018, 10:11:06 PM »
Is it possible to get AdvanvceHMI to share some Modbus registers to an Android HMI? The Android HMIs that I have tried are looking for a server and doesn't connect with the modbusTCP. I'm fairly new to this so it's very possible that I did it wrong. Wanting to interface with the Android via modbusTCP and read/write values on Modbus RTU RS485 bus that my AdvHMI is using. I may have to get additional hardware to get it to work. Has anyone done this? I normally VNC into my HMI but my wife had a stroke and I need to have a simple interface for her to adjust the room temperature. 

thanks

Pages: [1] 2