Modbus Examples?
09 May 2013 22:31 #33847
by ArcEye
Replied by ArcEye on topic Modbus Examples?
There is another python library you need since linuxcnc-2.6, think it is libboost-python.
./configure will prompt you for it if it is not installed
linuxcnc has become a sea of slithering serpents over the last years
./configure will prompt you for it if it is not installed
linuxcnc has become a sea of slithering serpents over the last years
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
10 May 2013 03:54 - 10 May 2013 09:36 #33858
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
I still need to compile the actual Mb2hal driver correct?
How is that done?
Never mind, I didn't have libmodbus3 installed properly. I fixed that then recompiled and installed master and now mb2hal is installed. Now to see if I can make it work for me.
How is that done?
Never mind, I didn't have libmodbus3 installed properly. I fixed that then recompiled and installed master and now mb2hal is installed. Now to see if I can make it work for me.
Last edit: 10 May 2013 09:36 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
10 May 2013 11:36 - 10 May 2013 11:39 #33864
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
Before this thread got onto the mb2hal tangent. I had promised to post what I had learned about using modbus with classicladder.
1st thing I learned is that you can set CL to use 8 bits, no parity, 2 stop bits to communicate in RTU mode. To set this just edit that part of the clp file with a text editor.
2nd in the CL modbus config, modbus register io setup, Element = Register, so if you need to read register 24-29 you would put down 24 as the first element, and 6 as the number of elements, then in the last column you if you put 1. it would write the results of reading those 6 registers to W1-W6
3rd the type access column has several selections you can choose from
Read_INPUTS fnct-2 - This will write what is read from the register(element) to the specified I or B variable in CL (these are 1s or 0s/ on or off)
Write_COIL(s) fnct-5/15 - This will write what is stored in the specified I, B or Q variable to the register(s) specified (these are 1s or 0s/ on or off)
Read_REGS fnct-4 - This will write what is read from the register(element) to the specified W or WQ variable in CL (these are S32)
Write_REGS fnct-6/16 - This will write what is read from the specified W, WQ, or WI variable in CL to the register(s) specified (these are S32)
Read_HOLD fnct-3 - This will write what is read from the register(element) to the specified W or WQ variable in CL (these are S32) (my drives respond the same to this as to Read_REGS fnct-4, I don't know what is supposed to be different)
Slave_echo fnct-8 - (I don't have a clue what this does)
Attached is a clp file that I could start/stop and set the speed on at least one of my drives for testing purposes.
1st thing I learned is that you can set CL to use 8 bits, no parity, 2 stop bits to communicate in RTU mode. To set this just edit that part of the clp file with a text editor.
2nd in the CL modbus config, modbus register io setup, Element = Register, so if you need to read register 24-29 you would put down 24 as the first element, and 6 as the number of elements, then in the last column you if you put 1. it would write the results of reading those 6 registers to W1-W6
3rd the type access column has several selections you can choose from
Read_INPUTS fnct-2 - This will write what is read from the register(element) to the specified I or B variable in CL (these are 1s or 0s/ on or off)
Write_COIL(s) fnct-5/15 - This will write what is stored in the specified I, B or Q variable to the register(s) specified (these are 1s or 0s/ on or off)
Read_REGS fnct-4 - This will write what is read from the register(element) to the specified W or WQ variable in CL (these are S32)
Write_REGS fnct-6/16 - This will write what is read from the specified W, WQ, or WI variable in CL to the register(s) specified (these are S32)
Read_HOLD fnct-3 - This will write what is read from the register(element) to the specified W or WQ variable in CL (these are S32) (my drives respond the same to this as to Read_REGS fnct-4, I don't know what is supposed to be different)
Slave_echo fnct-8 - (I don't have a clue what this does)
Attached is a clp file that I could start/stop and set the speed on at least one of my drives for testing purposes.
Last edit: 10 May 2013 11:39 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
10 May 2013 11:55 #33865
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
One other detail specific to these AC-Tech drives.
For some reason I had to set parameter 14 to 1 (terminal only control) instead of 2 (serial keypad). The info in the manual lead me to believe that it should be set to 2, but in that setting I was not able to figure out how to clear the initial JF fault (serial communication watchdog). Once I had the drive talking with CL then I could change P14 back to 2 and it would run fine (until serial communication was lost for some reason). I will have to investigate further to try to find out what the real problem is here or if there even is one.
For some reason I had to set parameter 14 to 1 (terminal only control) instead of 2 (serial keypad). The info in the manual lead me to believe that it should be set to 2, but in that setting I was not able to figure out how to clear the initial JF fault (serial communication watchdog). Once I had the drive talking with CL then I could change P14 back to 2 and it would run fine (until serial communication was lost for some reason). I will have to investigate further to try to find out what the real problem is here or if there even is one.
Please Log in or Create an account to join the conversation.
13 May 2013 21:39 #33999
by bigalex
Replied by bigalex on topic Modbus Examples?
Hi Todd.
Did you make any progress on the modbus2hal component application ?
bigalex
Did you make any progress on the modbus2hal component application ?
bigalex
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
13 May 2013 22:17 #34001
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
I am still working on building the configuration files to test with. (Hal, Classicladder, and pyvcp stuff)
I am hoping to do some testing with the drives hooked up later today.
I am hoping to do some testing with the drives hooked up later today.
The following user(s) said Thank You: bigalex
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
14 May 2013 10:19 #34041
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
Well, today was an exercise in frustration. Maybe tomorrow I'll have a clear enough head that that I might be able to formulate some intelligent questions.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
15 May 2013 11:02 #34112
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
Well it took me nearly two days to straighten out all the i/o pins I am using between mb2hal and classicladder, but I think I've gotten it figured out. I was able to chain together a few drives and turn them on/off and set the speed.
I just have one big question that is going to need a real modbus guru to help me straighten out.
These drives registers can have data formatted in 4 different ways.
From the manual (see pg 5 in the manual attached on the 1st post of this thread)
3.1 Register Format
All registers are 16 bits. The data within these registers can take on the following forms:
• Individual bit commands (16 per register).
Example: Register #1 (Modbus Register #2).
• Individual bit flags (16 per register).
Example: Register #22.
• A chain of two 8 bit unsigned integers.
• A 16 bit unsigned integer.
This unsigned integer could in turn represent many different types of data with various scaling
rules and units, which are defined by the DATA TYPE of the register.
The register that I am currently most interested in reading is register 26
This register uses the 3rd type of register format "A chain of two 8 bit unsigned integers".
Is there an easy way to separate these two bytes, in order to send their data to separate pins?
I am most interested in getting the 2nd 8 bits by its self.
I just have one big question that is going to need a real modbus guru to help me straighten out.
These drives registers can have data formatted in 4 different ways.
From the manual (see pg 5 in the manual attached on the 1st post of this thread)
3.1 Register Format
All registers are 16 bits. The data within these registers can take on the following forms:
• Individual bit commands (16 per register).
Example: Register #1 (Modbus Register #2).
• Individual bit flags (16 per register).
Example: Register #22.
• A chain of two 8 bit unsigned integers.
• A 16 bit unsigned integer.
This unsigned integer could in turn represent many different types of data with various scaling
rules and units, which are defined by the DATA TYPE of the register.
The register that I am currently most interested in reading is register 26
This register uses the 3rd type of register format "A chain of two 8 bit unsigned integers".
Is there an easy way to separate these two bytes, in order to send their data to separate pins?
I am most interested in getting the 2nd 8 bits by its self.
Please Log in or Create an account to join the conversation.
15 May 2013 14:25 - 15 May 2013 14:35 #34114
by bigalex
Replied by bigalex on topic Modbus Examples?
Hi Todd.
I'm not a Modbus guru but I try to help you if I can.
I'm hoping that you are using ClassicLadder Modbus to communicate with your driver.
In case it is , I usually do in this way :
In this way you can extract each bit from the register you are reading from Modbus.
You can use this approach also if you are using modbus2hal for the communication
and Classic Ladder for the logic.
In this case you have to "copy" the register read from modbus2hal pin to ClassicLadder hal input pin.
So ClassicLadder can make the bit extracting job and the logic you need to do.
I hope I'm clear enough .
bigalex
I'm not a Modbus guru but I try to help you if I can.
I'm hoping that you are using ClassicLadder Modbus to communicate with your driver.
In case it is , I usually do in this way :
|--| %W10 & 1 |-----------( %B0)---|
|--| %W10 & 2 |-----------( %B1)---|
|--| %W10 & 4 |-----------( %B2)---|
::::::::::::::::::::::
::::::::::::::::::::::
|--| %W10 & 128 |---------( %B7)---|
| |
| This is the value to AND with
|
This is the register
I'm reading from Modbus
In this way you can extract each bit from the register you are reading from Modbus.
You can use this approach also if you are using modbus2hal for the communication
and Classic Ladder for the logic.
In this case you have to "copy" the register read from modbus2hal pin to ClassicLadder hal input pin.
So ClassicLadder can make the bit extracting job and the logic you need to do.
I hope I'm clear enough .
bigalex
Last edit: 15 May 2013 14:35 by bigalex.
The following user(s) said Thank You: willburrrr2003, Todd Zuercher
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1440
15 May 2013 21:02 #34131
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus Examples?
I don't think I understand completely what the & does. But if it is giving me the indevidual bit values, I don't think that will be quite what I want.
The register I am trying to work with gives the drives load as a percentage on the high bit, and the drives status on the low bit (fault, stop, accel, run,...). I only want to see the value of the low bit.
Just playing with my calculator a bit, and I think that If I use the modulus 16 of the varaible, should give me the value of the low bit I need. 256 might actualy be the right number to use but I think 16 works for all the possible values in this situation (0-11).
Thanks for the idea though.
The register I am trying to work with gives the drives load as a percentage on the high bit, and the drives status on the low bit (fault, stop, accel, run,...). I only want to see the value of the low bit.
Just playing with my calculator a bit, and I think that If I use the modulus 16 of the varaible, should give me the value of the low bit I need. 256 might actualy be the right number to use but I think 16 works for all the possible values in this situation (0-11).
Thanks for the idea though.
Please Log in or Create an account to join the conversation.
Time to create page: 0.142 seconds