abdul
I would like to turn Raspberry Pi into a Modbus Master and would like to communicate using USB to Serial Converter with my PC and simulate the result using a Modbus Slave simulator. Waiting for your response.
 
Reply 0 0
thiagoralves
Just follow the instructions here to install the OpenPLC with the Modbus Master driver.
Reply 0 0
abdul
I followed the steps and in config file when I select RTU I'm unable to give my device address as /dev/ttyS3. Please help me out.
Reply 0 0
abdul
I have attached the print screen of the above problem
Reply 0 0
thiagoralves
It seems that there is a problem with ctag's modbus conf page. I'll report it to him. Meanwhile, you can simply fix it by downloading the cfg file after filling out all the other information, and then opening it on notepad (or your favorite text editor) to fix the address line. Just change the line after device0.address = "" to device0.address = "/dev/ttyS3".

By the way, are you sure the address of your USB to Serial adapter is showing on your Raspberry Pi as /dev/ttyS3? Usually, USB adapters show up as /dev/ttyACM0...
Reply 1 0
abdul
Thank you for your guidance.
I didn't understand how to upload file to openPLC. I'm remotely logging into my Raspberry Pi so I used openplc-ip:8080 but I get a reply that site can't be reached. And also I would like to know how can I upload config file without a web interface.

I used the following commands to find the address of USB to Serial adapter
cd /dev and then ls
or
dmesg | grep tty

I got /dev/ttyUSB0

Reply 0 0
thiagoralves
You must substitute "openplc-ip" with whatever IP address your RaspberryPi have. Uploading an ST file or CFG file to the OpenPLC without the web interface is far too complicated. If you really want to do it, you can take a look at the server.js file that handles the webserver requests. There you will find all the steps required after you upload a file to the OpenPLC.

About the usb-serial adapter, it seems that it is attached to /dev/ttyUSB0. You should use this address instead.
Reply 0 0
abdul
After typing sudo nodejs server.js I got an error whose print screen is attached
Reply 0 0
thiagoralves
You must run that command inside the OpenPLC_v2 folder, where the server.js is located. If you cloned it in your home directory, just type
cd ~/OpenPLC_v2
sudo nodejs server.js
Reply 0 0
abdul
After executing the above commands also I got an error. Please find the attachment.
Reply 0 0
thiagoralves
This error occurs when the server can't find the OpenPLC application. Did you follow the instructions on the getting started guide? It seems that OpenPLC is not installed on your Raspberry Pi. Before starting it, you need to install it. You do by typing
./build.sh
on the console inside the OpenPLC_v2 folder. During the installation process, it will ask you which driver to use, then you need to choose Modbus. It will then generate the OpenPLC application on your RaspberryPi, and you will be able to start it with the nodejs server.js command.

Alternatively, you may have an old version of nodejs or Raspbian. Please make sure you're running Raspbian Jessie and have the latest version of nodejs installed. You can check the version of your Operating System by typing: 
uname -a

Also, you can check the version of nodejs with
nodejs -v


On my RaspberryPi, I got the following:
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.9+ #884 Fri May 6 17:25:37 BST 2016 armv6l GNU/Linux
pi@raspberrypi:~ $ nodejs -v
v0.10.29


If you have anything different than that, try updating your system with 
sudo apt-get update
sudo apt-get upgrade
Reply 0 0
abdul
When I typed the command ./build.sh it gives No such file or Directory
So I started my Installation process from beginning
When I installed wiringPi everything is OK
When I entered 

sudo apt-get install build-essential bison flex autoconf automake libtool make nodejs git

 It gives the following error messages which I attached to this post.
Reply 0 0
thiagoralves
You need to learn more about Linux/Unix Terminal to better deal with your RaspberryPi. A very nice and introductory tutorial can be found here: http://www.ee.surrey.ac.uk/Teaching/Unix/
I strongly suggest you to take a look at these exercises. It will help you to find your way with the commands.
Now, about your issues, you can only run ./build.sh inside the OpenPLC _v2 directory, because there is where the file is located. A simple ls command can help you see which files are available on the current directory (again, the Linux tutorial will help you with this).
About the apt-get error, it can mean two things: either your RaspberryPi is offline (this command requires internet connection) or your sources list is outdated. The second problem can be easily fixed with
sudo apt-get update
Reply 0 0
abdul
I have done ./build.sh inside OpenPLC _v2 directory and ended with error which I have sent you in pics4.

So I started to the OpenPLC installation from beginning and ended with error in  

sudo apt-get install build-essential bison flex autoconf automake libtool make nodejs git

which I have sent you as an attachment in pics5.

I will review the linux commands as you suggested thanks for your support.
Reply 0 0
thiagoralves
As soon as you log into your Raspberry Pi using PuTTY, type these commands in sequence. This should be enough to install OpenPLC from scratch
cd ~

rm -Rf OpenPLC_v2

sudo apt-get update

sudo apt-get install build-essential bison flex autoconf automake libtool make nodejs git

git clone https://github.com/thiagoralves/OpenPLC_v2.git

cd OpenPLC_v2

./build.sh


At the end of the installation process, you will be asked to choose a driver for the OpenPLC. Select Modbus. The installation will continue (might take a while) and then finally you will be ready to type
sudo nodejs server.js


Please paste here the output of your installation to make sure that the process went through fine. You don't need to send pictures of the PuTTY screen, just copy and paste the contents. To copy the text from the PuTTY screen, just select it with your mouse. Just by doing that the text will be available in your clipboard. Then just paste it here.
Reply 0 0
Reply