Modbus to Hal

More
08 Nov 2013 21:41 - 08 Nov 2013 22:47 #40672 by simon n.
Modbus to Hal was created by simon n.
Hi Guys,

i already opened a thread in the general section where we solved problems with linuxcnc and resolvers with different type of construction. For rubberneck's (hope its the right word ^^,i am from Germany and my English is not that good) the original thread:

www.linuxcnc.org/index.php/english/forum...e-with-resolver-7i49

We want to embed a Safety-plc to our linuxcnc system. Right now we try to get it running with classicladder. We followed several guides to install the libmodbus3. It should be installed and compiled right now, we did it with the command:

git clone git://github.com/stephane/libmodbus
./configure && make && make install

That results in no errors and plenty stuff of installed packages. Before that we upgraded EMC from the stable 2.5 version to the master branch 2.6. After that we used this command:

loadrt classicladder_rt

addf classicladder.0.refresh servo-thread

loadusr -w classicladder --modmaster apesgonnaride.clp

After that we programed a simple program in classicladder with 1 input and 1 output. When we start linuxcnc the classicladder window opens first. We can do some settings now, alike the modbus settings but we didn't look into it until now. We now want to understand properly how it works in modbus to hal, we want to send a test signal from the plc to hal using modbus.

The connection between hal and plc should be modbus TCP./IP
Why does classicladder always starts before the actual program of the machine starts? Each time when we close the classicladder it says that modbus will be quit. Does that mean, that there can't be send any signals from the plc to hal when we close the classicladder? or does it run in the background?

We are quite confused now about how it works or how we should setup the settings for modbus to get it communicating with the plc, maybe you guys have some hints for us to get along with it.

Hope you understand what i want to tell, my English is not that good^^.


Greetings

Simon N.
Last edit: 08 Nov 2013 22:47 by simon n..

Please Log in or Create an account to join the conversation.

More
09 Nov 2013 10:04 #40680 by cmorley
Replied by cmorley on topic Modbus to Hal
Classicladder doesn't use librarymodbus - it uses it's own routines.
Classicladder's GUI must be running for modbus to work.
If using linuxcnc 2.6 there is a HAL pin to hide/show the GUI if you like.

I've never used modbus over TCP so can't help you there.

Chris M

Please Log in or Create an account to join the conversation.

More
09 Nov 2013 21:06 #40686 by Todd Zuercher
Replied by Todd Zuercher on topic Modbus to Hal
Classicladder has its own modbus interface. To use it the Classicladder gui must remain open.

Modbus2hal is a separate modbus interface independent of Classicladder that creates pin signals for hal to communicate directly with the modbus equipment. Modbus2hal is relatively new and the documentation is incomplete at best on this subject. For starters the installation process is no longer relevant. All that is necessary is to install a current version of master via Buildbot. (You do not need to compile Libmodbus any longer, it is included.) Then follow the rest of the configuration instructions in the wiki.

To use communication from Modbus2hal in Classic ladder you will need to create signal connections in Hal between Modbus2hal's io pins and Classicladder's variable io pins.

Please Log in or Create an account to join the conversation.

More
09 Nov 2013 23:25 - 09 Nov 2013 23:26 #40689 by simon n.
Replied by simon n. on topic Modbus to Hal
Thanks,

we will test the modbus2hal instruction next week via wiki. I'll report if it worked or not then ^^

greetings

Simon N.
Last edit: 09 Nov 2013 23:26 by simon n..

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 17:53 #40781 by simon n.
Replied by simon n. on topic Modbus to Hal

Then follow the rest of the configuration instructions in the wiki.


Hey,

We want to try Mb2hal first, so we started with the wiki after installing libmod3, because it should already be installed in master branch. Is Git also already installed in master or do we have to install it? we did not compile or install git, we also do not have the " mb2hal_HOWTO.ini is located in src/hal/user_comps/mb2hal/ of your base git clone directory. " because there is no git clone i guess, so we have to install/compile it?.

If we decide to use modbus via classicladder and classicladder has to remain open for that, which pin do we have to set true to get it startet while the main programm is running? We tried the pin "classicladder.0.hide_gui" but nothing showed up when we set it true.

We are quite confused how to get it working via mb2hal or classicladder. we are no programmer and for git it seems you have to be a developer or at least have an account somewhere because it asked for usernamer and e-mail in the first steps.

Which step do we have to start with in the mb2hal wiki? we started with 2) but you said that we should start with the config, but there is no config file^^.

Greetings

Simon N.

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 19:47 #40786 by andypugh
Replied by andypugh on topic Modbus to Hal

Is Git also already installed in master or do we have to install it? we did not compile or install git, we also do not have the " mb2hal_HOWTO.ini is located in src/hal/user_comps/mb2hal/ of your base git clone directory. " because there is no git clone i guess, so we have to install/compile it?..


You shouldn't need Git if you are running with the Buildbot packages.

Which instructions are you working through? Perhaps they are out of date?

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 19:52 #40787 by andypugh
Replied by andypugh on topic Modbus to Hal
Incidentally, if all you need is to read a file that exists in the source tree then you can see the source code online:

git.linuxcnc.org/gitweb?p=linuxcnc.git;a...4fb2a302122f;hb=HEAD

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 21:02 #40788 by simon n.
Replied by simon n. on topic Modbus to Hal


Which instructions are you working through? Perhaps they are out of date?


Hi Andy,

we are working on this instructions:
wiki.linuxcnc.org/cgi-bin/wiki.pl?ModbusToHal

The first commentary :" #This .INI file is also the HELP, MANUAL and HOW-TO file for mb2hal.

#Load the modbus HAL userspace module as the examples below,
#change to match your own HAL_MODULE_NAME and .ini file name
#Using HAL_MODULE_NAME=mb2hal or nothing (default): loadusr -W mb2hal config=config_file.ini
#Using HAL_MODULE_NAME=mymodule: loadusr -Wn mymodule mb2hal config=config_file.ini"

What does "Modbus HAL userspace module" mean? Do we have to create a new HAL-file? We just dont get it.

Greetings

Simon N.

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 21:20 #40789 by andypugh
Replied by andypugh on topic Modbus to Hal

we are working on this instructions:
wiki.linuxcnc.org/cgi-bin/wiki.pl?ModbusToHal.


They certainly could be a lot clearer, that's for sure.

You need to add the command
loadusr -W mb2hal config=config_file.ini
to a HAL file.
You also need to create an INI file which tells mb2hal what to do. In the example above that file is called "config_file.ini" but you probably want to choose a different name.

The "loadusr" command could be added to the main HAL file of the configuration, but I actually think it might be better to add it to a separate HAL file. (this makes it more portable)

If you look a the INI file of your main config there is a section called [HAL] that defines all the HAL files that will be run. I would suggest adding a new file (possibly called modbus.hal) to that section. Then you can create a new file with that name and put it in the cofig directory. This file shouuld contain the "loadusr" line above, it would then be followed by all the HAL commands needed to link the Modbus packets to the HAL pins that will drive them. (for example, if you had a spindle VFD then you would need something like
net spinde-speed motion,spindle,speed-out => mb2hal.spindle-speed
assuming that the modbus config (ini) file created a modbus pin called spindle-speed.

To create the modbus INI file you will need to decipher that WIKI page. it basically consists of a set of comment lines (#) which are ignored but tell you what you _could_ have in that section, and some uncommented lines that make up a sample config file.

Please Log in or Create an account to join the conversation.

More
13 Nov 2013 22:10 - 13 Nov 2013 22:30 #40790 by simon n.
Replied by simon n. on topic Modbus to Hal
Hey Andy,

that seems to be working, we now get at least the mb2hal section in "display hal" (don't know if its called that way in english). We copied the config stuff from the wiki into the man ini-file of our project. we use a laptop with a "modbus tool" to simulate a slave for linuxcnc which should be the master?!

We connected the laptop and linuxcnc via ethernet cable. We set the IP of the slave in the ini file and also do some settings for the inputs and outputs. When we set some bits on the laptop we can't see the hal pins in linuxcnc changing their status, they all remain as before. It seems the laptop doesn't have connectivity with linuxcnc. What could be the problem if there is no connection now?

Sorry for all these stupi questions, but we are new to this modbus stuff^^

Great work Andy! We followed your instructions and creat a new hal file, which is called from the ini file first.

Edit: mb2hal does not exist in the thread/functions section in "display HAL". shouldn't it be in the servo thread to get the input/output read? Is there a "addf" missing somewhere ? :)

Greetings

Simon n.
Last edit: 13 Nov 2013 22:30 by simon n..

Please Log in or Create an account to join the conversation.

Time to create page: 0.367 seconds
Powered by Kunena Forum