Kris
Hi. I am very very new to all of this. I have successfully installed both the Open PLC server and the PLC Open Editor on my Ubuntu 14.04 machine. Both run, I have the server running on the default 8080 port. I have generated the Hello World st file from the HelloWorld.xml file using the PLC Open Editor and uploaded it into th PLC Server. It compiles successfully

e.g.

compiling new program...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c

Program compiled successfully
moving files...
compiling OpenPLC...
Generating object files...
Generating glueVars.cpp
varName: __IX0_0 varType: BOOL
varName: __QX0_0 varType: BOOL
Compiling main program


compiled without errors




Now my question is this - what next? how can I see the helloworld plc program executing with a Linux PC blank driver version of Open PLC? do i need modbus?

As a complete novice I have no idea how to actually run the helloworld.st program to view the outputs. I am sure up to now you are expecting and assuming a basic understanding of PLC workflows and programming, I may be your first person to come here first while attempting to simultaneously learn about PLC operation and programming. 
Quote 0 0
thiagoralves
Basically, the blank driver does nothing with the I/O, so you won't see anything happening. The best way to explore OpenPLC is to have a physical device connected to the computer (an Arduino board for example) or run OpenPLC on an embedded platform that has I/O, like the RaspberryPi.

However, if you don't want to move to hardware, you can use a Modbus software to talk to the running OpenPLC on your computer and read the state of its I/Os. Radzio Modbus is a very good one: http://en.radzio.dxp.pl/modbus-master-simulator/. You can refer to the table at http://www.openplcproject.com/scada to know which modbus address refers to each PLC I/O. One thing to note is that, if you look at the table, you will see that you can't write to inputs, which mean you can't change the value of the inputs. This is a definition of the Modbus protocol. Therefore, in the hello world example, you won't be able to change the state of the button because it is located in an input area (%IX0.0).

To actually control the button, you will have to move it to an output address (can be %QX0.1 for example). This will not have any practical effect in your software besides the fact that you will be able to actually write, or force, the state of the button using Modbus. Then you open Radzio Modbus, click on Connection -> Settings, select Modbus TCP and type the IP address of your OpenPLC machine. If you're running Radzio on the same machine that is running OpenPLC, just type localhost at the IP address box. After that, click on Connection -> Connect and then File -> New. You will see a spreadsheet-like window where you can manipulate the status of all OpenPLC's outputs.

In the future, I plan to replace the blank driver with a virtual I/O driver. This virtual I/O driver will have a GUI window that will display all I/O points for the OpenPLC and will allow the user to manipulate freely those points in order to simulate the execution of the program.
Quote 3 0
eclipse
I just want to note that this walk through was very useful, and I encourage you to add it in some fashion to your web site page that discusses the Windows and Linux "getting started".  Or, perhaps link from there to this forum topic.  The additional informatin about needing to change the Hello World project to use a writeable address isn't intuitive to us raw beginners.  Thanks.
Ed Reed, Aesec
Quote 0 0
jeskudero
Hello,

I'm also a begginer in this, thanks for the walk through. I changed the example and i have put the button on the %QX0.1. But then, when i try to wrtie in that position it does nothing.
I mean, shall i see something changed after that? i read the coils again and anything happens. (I use qModbus Master to connect to a VM (ubuntu 16) that is running OpenPLC.)
Quote 0 0
thiagoralves
For the hello world example, when you write to the button (%QX0.1 = Modbus address coil 1), you should see the coil %QX0.0 (Modbus address coil 0) changing. If it is not changing, either your program is wrong or you are looking at the wrong Modbus addresses.
Quote 0 0
jeskudero
Ok, today it works, maybe i was doing something wrong,
I changed to ligth 10 seconds so i can esaly view if it changes or not.
Thanks for this example.
Quote 0 0
mrjrbaker
Hi all, Noob alert.

I have followed Thiago's steps for a non hardware setup using Radzio's modbus (thank you). I have done everything the same to the best of my ability. I can compile and start the plc however i keep getting this error message:

"Device Modbus Slave Emulator is disconnected. Attempting to reconnect...Connection failed on MB device Modbus Slave Emulator: Connection refused"

Ive got 'localhost' as the IP address in both the slave device settings and the Radzio simulator.

Any help would be greatly appreciated!
Quote 0 0
thiagoralves
Radzio is not supposed to be used as a slave device. It is the other way around. Radzio is the master and OpenPLC is its slave. You should use Radzio to query OpenPLC I/Os 
Quote 0 0
theozz

How do I configure the HMI to send a command to the Pi causing the physical light to come on when clicking the software button in the mySCADA HMI? 

I have everything working with mySCADA HMI and OpenPLC on my Raspberry Pi per the walk through. I can see the light and the button respond in my HMI when I push the physical button on my circuit attached to the Pi. I can not find documentation on sending commands from the HMI to the Raspberry Pi. 

Quote 0 0
eclipse
Theozz - it was less than obvious to me, too.  It depends on which HMI application you're using - there are several possible choices.  But generally, you (a) select a WRITE operation (instead of READ) - for example, WRITE COIL, and (b) then double-click on the display field of the coil whose value you want to change.  That brings up a dialog or allows you to enter your value (e.g., from '0' change it to '1'), and then (c) send the request to your PLC device.  If it all works, your light will change state from '0' to '1'.  And vice versa.  Hope this helps.
Ed Reed, Aesec
Quote 0 0
theozz
@eclipse Thanks for the response. I am still not able to figure it out. I am using the demo version of MyPro HMI from mySCADA and doing the HMI design/edit using mydesinger...also from mySCADA.org. 
Quote 0 0
eclipse
I've been using a couple of downloads I found mentioned at http://www.dalescott.net/modbus-development/, such as the Scheider Electric Modbus Tester at https://www.schneider-electric.us/en/faqs/FA180037/, and Modbus qModMaster at https://sourceforge.net/projects/qmodmaster/.  But, my needs are a bit peculiar - I'm working strictly with Modbus-RTU (over RS-232 serial) at the moment.
Ed Reed, Aesec
Quote 0 0
thiagoralves
You can’t write to a coil that is being controlled by the ladder logic. My tip is to add another coil (%QX0.2 or any other unused coil) in a contact in parallel with your button on the ladder logic. Then, whenever you press the button or write true to the %QX0.2 coil, the lamp will turn on.
Quote 0 0
eclipse
Thiagoralves - is that a change from the earlier version?  I thought that was the whole point of the two button, 1 LED demo.  I write to the coil with no problems, with the version of the Modbus routines I'm working with.  Where is the check preventing it supposed to go?

For my routine that processes the Modbus-RTU messages received, I call the same processModbusMessage() routine provided by core/modbus.cpp.  Taken from the master-180519 source tree.

So, yes, I reference coil 1 in the ladder logic, its value controls the signal to the LED (I'm doing this with the Arduino Uno controller), and a Modbus-RTU write coil, calling WriteCoil (which protects the Modbus DB via Mutexes from contention with the Arduino hardware_layer provided updateInputBuffer and updateOutputBuffer routines called by main(), which provides the PLC process loop and invokes the config_run__() function to invoke the ladder logic processing).

Or, do you attempt to control access to the coil used in the client side, some how?  If so, is that spec'd in the standard somewhere?

Just wanting to track your work as closely as I can (given my use of cross-platform development environment in lieu of running compilers on the SoftPLC platform).

Thanks,
Ed
Ed Reed, Aesec
Quote 0 0
thiagoralves
Hi Ed,

In fact this has been in OpenPLC since the first Modbus implementation. Ladder logic always has priority over Modbus requests. If you try to write to a coil that is being controlled by ladder logic (note here that I'm saying controlled by ladder logic, not present on the ladder logic) it won't give you any Modbus errors, but the request will be immediately superseded by the ladder logic. Take this simple scenario for example:
     %IX0.0                         %QX0.0
|----|    |------------------------(      😉--------|

%QX0.0 is controlled by the state of %IX0.0 on the ladder logic. If %IX0.0 is false and you try to write true to %QX0.0, this request will be lost immediately after the ladder logic is processed again. Now if you do something like this:
     %IX0.0                         %QX0.0
|----|    |--------+---------------(      😉--------|
                   |
     %QX0.0        |
|----|    |--------|

Then %QX0.0 will be true by a small instant that will be enough to latch the circuit and keep %QX0.0 on forever. This situation is different than the first one because on this, the output %QX0.0 is being controlled by %IX0.0 and %QX0.0.
Quote 0 0