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.


Topics - kallileo

Pages: [1]
1
Support Questions / Modbus RTU questions
« on: February 28, 2021, 06:35:36 AM »
I use Modbus RTU driver to connect to a Modbus slave.
The addressing scheme of the slave is 0 based so in order to read HR 400050 I have to put the address 400051 in basic label.
Is it possible to setup the AHMI driver to be 0 based as well?

The method modbusRTUCom1.CloseConnection() can be used to close the connection.
How can I reopen it?

2
Open Discussion / AdvancedHMI as Soft-PLC
« on: January 03, 2019, 06:39:53 AM »
I was wondering how it's possible to use AdvancedHMI as Soft PLC.
I understand all the real-time restrictions of the OS and the whole setup but for test purposes and non critical applications it could work.

Lets assume that it's acceptable so I guess that a separate thread should be created in order to run the control code.
Has anyone done it before?




3
Hi,

I want to read 3 Modbus registers from a level measuring device.
What I do now is to list all the available com ports and then after selecting the correct one I start reading and displaying the 3 registers by using BasicLabel controls.

It works but this is not how I want it to work.
Is it possible to establish Modbus communication and then start reading Modbus data?

So I use the following code:

Code: [Select]
private void MainForm_Load(object sender, EventArgs e)
        {
            //show list of valid com ports
            foreach (string s in System.IO.Ports.SerialPort.GetPortNames())
            {
                comboBox1.Items.Add(s);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            modbusRTUCom1.PortName = comboBox1.SelectedItem.ToString();
        }

        private void modbusRTUCom1_ConnectionEstablished(object sender, EventArgs e)
        {
            button1.Text = "Connected";
            Timer timerReadPLC = new Timer();
            timerReadPLC.Interval = 500;
            timerReadPLC.Tick += new EventHandler(timerReadPLC_Tick);
            timerReadPLC.Start();
        }

        void timerReadPLC_Tick(object sender, EventArgs e)
        {
                litersMod.Text = modbusRTUCom1.Read("30001").ToString();
                kilosMod.Text = modbusRTUCom1.Read("30003").ToString();
                int x = Int32.Parse(modbusRTUCom1.Read("30002")) / 10;
                levelMod.Text = x.ToString();
        }

Is it a proper way to make a program?

Also I don't really undestand what modbusRTUCom1.Subscribe and modbusRTUCom1.BeginRead methods do.


4
Support Questions / Manually select serial for port for Modbus RTU
« on: March 25, 2015, 12:35:23 PM »
In my application I don't to hardcode the serial port number into my code but I want to be able to select the port from a combobox and the start the connection.
So I have created a combobox and populate it with the available com ports. Then I added a button and as soon as I selected the appropriate com port I use it to read from the address I need and write the value to DigitalPanelMeter.
I need to press the button every time I want to read. Is it possible to poll the slave every 500ms as it's done the ModbusRTUCom driver is added in the designer?
Do I need to create an event to achieve this?
I'm not an expert in VB.NET (yet) so any help will be appreciated. Below is my code.

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim ports As String() = SerialPort.GetPortNames()
        Dim port As String
        For Each port In ports
            ComboBox1.Items.Add(port)
        Next port
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ModbusDriverXR80CX As New ModbusRTUCom
        ModbusDriverXR80CX.PortName = ComboBox1.SelectedItem
        ModbusDriverXR80CX.BaudRate = 9600
        ModbusDriverXR80CX.StationAddress = 5
        DigitalPanelMeter1.Value = ModbusDriverXR80CX.Read("40257")
End Sub

Pages: [1]