Author Topic: AdvancedHMI on a Raspberry Pi  (Read 131178 times)

Zip

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #30 on: August 17, 2015, 10:46:46 PM »
Thanks Godra. Re-read Vitors post and you are correct. I must have skimmed over that before. I probably saw the IP address and immediately associated it with TCP connection. Was sifting through so much material. On the plus side learnt alot of cool stuff along the way!

Vitor. Yes i am looking at connecting my pi directly to plc via usb - serial adaptor. Am confident your method will work (prpviding i can get ser2ser etc to run ok. Will let you know of i get stuck/how i go.

Thanks again guys.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #31 on: August 17, 2015, 10:51:10 PM »
Here is one more link for you which shows how to create a symbolic link in Debian Linux:

http://forums.debian.net/viewtopic.php?f=16&t=61943

If your Pi has a linux and it is any similar to Debian then these commands might just work for you (you would have to follow them exactly and see if you will be getting similar responses).

Zip

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #32 on: August 17, 2015, 11:27:29 PM »
Sorry, also to clarify, not nessessarily concerned about working with mono. Only that is what is running AHMI on Pi.
So i figured was relevant. I have a touch screen attached to pi to display AHMI comminicating with PLC via RTU. Looking forward to trying out these new suggestions tonight. As frustrating as this can be is a hell of a lot of fun!

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #33 on: August 17, 2015, 11:52:18 PM »
Here is a new thing to try.

I have attached a GetSerial.exe file which you should copy to your Pi and run under mono, the same way you run AHMI which should be:

Code: [Select]
mono GetSerial.exe
I can only suggest you copy it to the same folder where AHMI is (or if it is on a device like USB Flash Drive or some other).

It works on MONO installed in Windows (check the attached picture) but I am not sure if it will work on Pi.

Zip

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #34 on: August 17, 2015, 11:57:57 PM »
Thanks Godra will try that soon.
Just read a few of Vitors projects again and there is bits and pieces in there that i think i cann use to point me in the right direction. The difference being i am trying to elominate the use of a PC. I only want to use my PC to design the AHMI interface then load that interface onto the pi so i have a standalone unit consisting of pi (with touchscreen) and PLC.


Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #35 on: August 18, 2015, 10:07:48 AM »
Please let us know how that goes. Serial port on Pi is something a lot of us would be interested in.

I wonder if DF1 communication could be possible this way? This would lead to ultra cheap HMIs for really low budget projects or hobbist projects.

Zip

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #36 on: August 18, 2015, 08:46:59 PM »
That's exactly what im aiming for. Cheap full colour stand alone HMI.
Will let you knkw how i get on.

Vitor

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #37 on: August 19, 2015, 03:23:52 AM »
Until now i tried not only with Pi but with PC´s running Debian 7 and 8 with no success. But code writen in C seems to work where in V.Basic not.
For those who want to know if the serial adapter is working here is one usefull command that list all the serial ports:
dmesg | grep -i tty

Zip

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #38 on: August 19, 2015, 09:19:09 PM »
Still no luck.
I have a feeling modbusRTU driver would work in wine with a link between COM1 and /dev/ttyUSB0 in DOSDevices folder as Godra suggested earlier. Unfortunately i cant test that as wine wont run on pi and i have no other linux machine. Might build a virtual on windows one of these days.
Last night tried Vitors experiment connecting to plc through pi via pc using Modbus TCP driver and Ser2net on pi to link IP to ttyUSB0. Connection works (although garbled as my plc is not compatable with TCP). RxTx flashing away nicely on plc port though as soon as AHMI opened on PC.
Considering a workaround using modbustcp-rtu software on the pi. Thoughts?

Godra i tried the linux distro instructions you suggested but ourputs were significantly different. Also could not get GetSerial exe. To run. It would open briefly then close. Both GUI and Command line files did the same. May i ask the intended pupose of the GetSeriak exe? Could find a whole lot on google except for getserial errors.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #39 on: August 20, 2015, 12:29:13 AM »
Zip, here are a few things I need to mention/explain:

1) In linux terminal you should always start with "sudo su", provide the password and then run "mono AdvancedHMI.exe" or "mono GetSerial.exe" or "mono SerialToIPGUI.exe" or any other program

2) GetSerial.exe is a program I created to fetch all available serial ports by their friendly names (currently it works in MONO for Windows and Ubuntu linux). It is equivalent to "ls -l /dev/tty*" command mentioned on Debian page posted previously. Vitor's command "dmesg | grep -i tty" should show currently active serial ports.

3) I just tried running SerialToIPGUI program in MONO on Ubuntu linux and this program runs as well and lists all available serial ports. Its advantage is that it has graphical user interface and runs as either a Server or a Client connecting serial port to ethernet.

If Archie could provide an option within any driver to tunnel its packets through 127.0.0.1 then, by using the SerialToIP program, the Pi could be used as standalone option for HMI (if there is no other solution of course).


@Sprungmonkey

When I use DF1 driver alone in AHMI project and start it in MONO on Ubuntu, the attached exceptions occur and the AHMI screen closes.

Don't get any of that if using ModbusRTU or EthernetIPforPLCSLCMicro drivers.

Didn't get it with older version of AHMI either (v3.84) with DF1 driver.
« Last Edit: August 21, 2015, 12:09:05 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #40 on: August 20, 2015, 12:48:51 AM »
Quote
Last night tried Vitors experiment connecting to plc through pi via pc using Modbus TCP driver and Ser2net on pi to link IP to ttyUSB0. Connection works (although garbled as my plc is not compatable with TCP). RxTx flashing away nicely on plc port though as soon as AHMI opened on PC.
Considering a workaround using modbustcp-rtu software on the pi. Thoughts?

In the same topic for Vitor's experiment I posted the experiment with 2 PCs. That setup enabled usage of DF1 driver and should do the same for the ModbusRTU driver.

You would just have to use com0com and SerialToIP programs on the PC to be able to use ModbusRTU driver and leave the Pi configured as Vitor proposed.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #41 on: August 21, 2015, 12:52:40 AM »
Archie,

The SerialToIP software, when started with MONO on Ubuntu, doesn't have any issues with detecting and opening /dev/ttyUSB0 port. In the code, the author is not using anything special but SerialPort.GetPortNames() and SerialPort.Open() commands.

Is it possible that AHMI is specifically looking for string that starts with "COM" word?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvancedHMI on a Raspberry Pi
« Reply #42 on: August 21, 2015, 07:50:04 AM »
I checked through the code and there is nothing restricting the name of the serial port. It defaults to COM1, but after it changes the property name, it pushes it directly to the serial port component:

                            SerialPort.PortName = m_PortName

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AdvancedHMI on a Raspberry Pi
« Reply #43 on: August 21, 2015, 12:16:56 PM »
I forgot to mention that the SerialToIPGUI version that I am running with MONO was actually converted to VB Net and compiled as exe program.

So this issue doesn't seem to have anything to do with VB Net itself or the mono-vbnc.

Could it be a part of AHMI dll that is causing this issue?

Which class is specifically opening the COM port for DF1 driver to send packet (currently I am testing DF1driver until I figure some other approach/driver)?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvancedHMI on a Raspberry Pi
« Reply #44 on: August 21, 2015, 12:29:52 PM »
Here is the function that opens the COM port for the DF1 driver if you wanted to try to test it in a stand alone application:
Code: [Select]
   '*********************************
    '* Open Serial Port
    '*********************************
    Public Function OpenConnection() As Integer
        '*****************************************
        '* Open serial port if not already opened
        '*****************************************
        If Not SerialPort.IsOpen Then
            If m_BaudRate > 0 Then
                Try
                    SerialPort.PortName = m_ComPort

                    If m_BaudRate = 0 Then
                        DetectComSettings()
                    Else
                        SerialPort.BaudRate = m_BaudRate
                        SerialPort.Parity = m_Parity
                    End If


                    '* Calculate how long to wait based on baud rate
                    MaxWaitTicks = Convert.ToInt32(19200 * 100 / m_BaudRate)

                    SerialPort.ReceivedBytesThreshold = 1
                    SerialPort.Open()
                Catch ex As Exception
                    If SerialPort.IsOpen Then CloseConnection()
                    Return -9
                    'Throw New MfgControl.AdvancedHMI.Drivers.PLCDriverException("Failed To Open " & SerialPort.PortName & ". " & ex.Message)
                End Try
            Else
                Dim result As Integer = DetectComSettings()
                If result <> 0 Then
                    'Throw New MfgControl.AdvancedHMI.Drivers.PLCDriverException("Could Not Auto Connect")
                    If SerialPort.IsOpen Then CloseConnection()
                End If
                Return result
            End If
        End If

        Return 0
    End Function