- Configuring LinuxCNC
- Advanced Configuration
- MB2HAL I can read but cannot change the registry. fnct_16_write
MB2HAL I can read but cannot change the registry. fnct_16_write
- Adam Maszynotwór
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 2
03 Jan 2022 12:25 #230646
by Adam Maszynotwór
Hi
I am trying to switch from ClassicLadder to MB2HAL.
I have a VFD configuration in CL that works (but sometimes it issues an error)
I am doing a trial configuration in MB2HAL (in CL -ModBUS department the value changes well).
Her task:
Write the value 5.3A to the register H05 and Read the register H05 to check if the changes have occurred.
The VFD is the N700E - linyxcnc 2.7.15
the set current in H05 (1541Dec = 0605Hex) is 8.2A = 82Dec
and such is read by MB2HAL
In my opinion, the frame for shipping should be like this (and you can see that it is wrong)
01 10 0605 0001 02 0035 0012 where 0035 is the Hex record of the value 53
As you can see it doesn't work
Communication is because the value reads correctly.
www.forum.linuxcnc.org/10-advanced-confi...nuxcnc-2-7-14#229642
I helped myself with this github.com/swepeter/PrintNC/tree/11a4edd...eea4399d0a321ed9a344
I am trying to switch from ClassicLadder to MB2HAL.
I have a VFD configuration in CL that works (but sometimes it issues an error)
I am doing a trial configuration in MB2HAL (in CL -ModBUS department the value changes well).
Her task:
Write the value 5.3A to the register H05 and Read the register H05 to check if the changes have occurred.
The VFD is the N700E - linyxcnc 2.7.15
the set current in H05 (1541Dec = 0605Hex) is 8.2A = 82Dec
and such is read by MB2HAL
In my opinion, the frame for shipping should be like this (and you can see that it is wrong)
01 10 0605 0001 02 0035 0012 where 0035 is the Hex record of the value 53
As you can see it doesn't work
Communication is because the value reads correctly.
loadusr -Wn bestia mb2hal config=mb2hal.ini
loadrt near names=near.speed
addf near.speed servo-thread
net spindle-cw classicladder.0.in-00 <= motion.spindle-on
net spindle-ccw classicladder.0.in-01 <= motion.spindle-forward
net spindle-start classicladder.0.in-02 <= motion.spindle-reverse
#net spindle-runmode bestia.command.00 <= classicladder.0.floatout-00
net freq bestia.HzOut.00 <= classicladder.0.floatout-01
#net sp classicladder.0.floatin-01 <= bestia.HzOut.00.float
#Infos:
#DC67 26.12.2019
#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
#Initialisierung:
[MB2HAL_INIT]
#OPTIONAL: Debug level of init and INI file parsing.
# 0 = silent.
# 1 = error messages (default).
# 2 = OK confirmation messages.
# 3 = debugging messages.
INIT_DEBUG=1
#OPTIONAL: HAL module (component) name. Defaults to "mb2hal".
HAL_MODULE_NAME=bestia
#OPTIONAL: Insert a delay of "FLOAT seconds" between transactions in order
#to not to have a lot of logging and facilitate the debugging.
#Useful when using DEBUG=3 (NOT INIT_DEBUG=3)
#It affects ALL transactions.
#Use "0.0" for normal activity.
SLOWDOWN=0.0
#REQUIRED: The number of total Modbus transactions. There is no maximum.
TOTAL_TRANSACTIONS=2
#One transaction section is required per transaction, starting at 00 and counting up sequentially.
#If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time.
#Warning: Any OPTIONAL parameter not specified are copied from the previous transaction.
[TRANSACTION_00]
#Fehler aus FU einlesen:
#Der FU hat verschiedene Fehlermeldungen, diese werden hier alle eingelesen
#NOTSTOP Funktion!
#St500 Adresse: 0x8000 (-> 32768 Dez)
#Allgememeine Kommunkitaktionseinstellungen:
LINK_TYPE=Serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
#Data bits. One of 5,6,7,8.
SERIAL_BITS=8
#Data parity. One of: even, odd, none.
SERIAL_PARITY=none
#Stop bits. One of 1, 2.
SERIAL_STOP=1
#Serial port delay between for this transaction only.
#In ms. Defaults to 0.
# AC10 does not keep up if this value is too small
SERIAL_DELAY_MS=0
MB_SLAVE_ID=1
##St500 Adresse: 0x8000 (-> 32768 Dez)
#dla falowninka N700E rejest dla CW CCW STOP to 0002hex inaczej 2dec
#FIRST_ELEMENT= pierwszy nr. rejsetru
#udaga wartośc ject podawana w dec ale nie może być 2 trzeba uzupoełnic puste 0002
FIRST_ELEMENT=1541
#z nieznanych przyczyn polecienie PIN_NAMES=runmode niedziała zastępujue je NELEMENTS=(tu można tylko liczby)
#PIN_NAMES=runmode
NELEMENTS=1
#REQUIRED: Modbus transaction function code (see www.modbus.org specifications).
# fnct_03_read_holding_registers (03 = 0x03)
# fnct_06_write_single_register (06 = 0x06)
#REQUIRED: Modbus transaction function code (see www.modbus.org specifications).
# fnct_02_read_discrete_inputs (02 = 0x02)
# fnct_03_read_holding_registers (03 = 0x03)
# fnct_04_read_input_registers (04 = 0x04)
# fnct_15_write_multiple_coils (15 = 0x0F)
# fnct_16_write_multiple_registers (16 = 0x10)
#fnct_02_read_discrete_inputs: creates boolean output HAL pins.
#fnct_03_read_holding_registers: creates a floating point output HAL pins.
# also creates a u32 output HAL pins.
#fnct_04_read_input_registers: creates a floating point output HAL pins.
# also creates a u32 output HAL pins.
#fnct_15_write_multiple_coils: creates boolean input HAL pins.
#fnct_16_write_multiple_registers: creates a floating point input HAL pins.
#The pins are named based on component name, transaction number and order number.
#Example: mb2hal.00.01 (transaction=00, second register=01 (00 is the first one))
#fnct_03_read_holding_registers: creates a floating point output HAL pins, also creates a u32 output HAL pins.
#The pins are named based on component name, transaction number and order number.
#Example: mb2hal.00.01 (transaction=00, second register=01 (00 is the first one))
# funkca 06 niedziała MB_TX_CODE=fnct_06_write_single_register
MB_TX_CODE=fnct_03_read_holding_registers
#OPTIONAL: Response timeout for this transaction. In INTEGER ms. Defaults to 500 ms
#This is how much to wait for 1st byte before raise an error.
##St500: Kein Wert angegeben, jedoch mit 250ms getestet!
MB_RESPONSE_TIMEOUT_MS=500
#OPTIONAL: Byte timeout for this transaction. In INTEGER ms. Defaults to 500 ms.
#This is how much to wait from byte to byte before raise an error.
##St500: Kein Wert angegeben, jedoch mit 250ms getestet!
MB_BYTE_TIMEOUT_MS=500
#OPTIONAL: Instead of giving the transaction number, use a name.
#Example: mb2hal.00.01 could become mb2hal.plcin.01
#The name must not exceed 32 characters.
#NOTE: when using names be careful that you dont end up with two transactions
#usign the same name.
HAL_TX_NAME=A
#OPTIONAL: Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = infinit).
#NOTE: This is a maximum rate and the actual rate may be lower.
#If you want to calculate it in ms use (1000 / required_ms).
#Example: 100 ms = MAX_UPDATE_RATE=10.0, because 1000.0 ms / 100.0 ms = 10.0 Hz
MAX_UPDATE_RATE=100
#OPTIONAL: Debug level for this transaction only.
#See INIT_DEBUG parameter above.
DEBUG=0
#[TRANSACTION_01]
#read control register
#MB_TX_CODE=fnct_16_write_multiple_registers
#FIRST_ELEMENT=1541
#NELEMENTS=1
#HAL_TX_NAME=HzOut
#MAX_UPDATE_RATE=100.0
#DEBUG=0
[TRANSACTION_01]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=1541
NELEMENTS=1
HAL_TX_NAME=HzOut
MAX_UPDATE_RATE=100.0
DEBUG=3
www.forum.linuxcnc.org/10-advanced-confi...nuxcnc-2-7-14#229642
I helped myself with this github.com/swepeter/PrintNC/tree/11a4edd...eea4399d0a321ed9a344
Attachments:
Please Log in or Create an account to join the conversation.
- Adam Maszynotwór
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 2
04 Jan 2022 10:14 #230744
by Adam Maszynotwór
Replied by Adam Maszynotwór on topic MB2HAL I can read but cannot change the registry. fnct_16_write
I guess I got to the bottom of the problem.
I connected the logic analyzer:
-Mb2HAL write to multiple registers even though I only send 1 register in other words use command 16.
-Clasiccladder, although it cannot be selected whether we will use code 6 (writing a single register) or code 16 (writing multiple registers), when the user sends only one register from the machine, the command is selected as 06 and when many 16
Everything indicates that my VFD cannot interpret the command "write to many registers" (strange because I read somewhere that it can, but now I look at the datasheet and in the examples there is actually no 0x10 / 16, only examples with 0x06
Now the important question is HOW TO CHANGE MB2HAL to be able to use the code 0x06?
I found this function added github.com/protenwr/linuxcnc-py/commit/9...451c86409968ef991925
Is it possible to update the MB2HAL itself or do I have to upgrade the entire linuxcnc version to 2.8.2? (this version on my pc has higher jitter ;( )
I connected the logic analyzer:
-Mb2HAL write to multiple registers even though I only send 1 register in other words use command 16.
-Clasiccladder, although it cannot be selected whether we will use code 6 (writing a single register) or code 16 (writing multiple registers), when the user sends only one register from the machine, the command is selected as 06 and when many 16
Everything indicates that my VFD cannot interpret the command "write to many registers" (strange because I read somewhere that it can, but now I look at the datasheet and in the examples there is actually no 0x10 / 16, only examples with 0x06
Now the important question is HOW TO CHANGE MB2HAL to be able to use the code 0x06?
I found this function added github.com/protenwr/linuxcnc-py/commit/9...451c86409968ef991925
Is it possible to update the MB2HAL itself or do I have to upgrade the entire linuxcnc version to 2.8.2? (this version on my pc has higher jitter ;( )
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
05 Jan 2022 14:34 #230868
by Todd Zuercher
Replied by Todd Zuercher on topic MB2HAL I can read but cannot change the registry. fnct_16_write
This may seem like a stupid question but... Did you try inputing "fnct_06_write_single_register" on the MB_TX_CODE= line, to see if it works?
I know older versions of the MB2HAL.ini doc did not list it. But that doesn't mean that it isn't necessarily supported, and it is listed in the current version in Master. See here.
github.com/LinuxCNC/linuxcnc/blob/master...hal/mb2hal_HOWTO.ini
I know older versions of the MB2HAL.ini doc did not list it. But that doesn't mean that it isn't necessarily supported, and it is listed in the current version in Master. See here.
github.com/LinuxCNC/linuxcnc/blob/master...hal/mb2hal_HOWTO.ini
Please Log in or Create an account to join the conversation.
- Adam Maszynotwór
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 2
06 Jan 2022 10:14 #230931
by Adam Maszynotwór
Replied by Adam Maszynotwór on topic MB2HAL I can read but cannot change the registry. fnct_16_write
Thank you again for your interest
Yes, of course, I tried 06 but Linuxnc does not even turn on then, it only crashes an error right away, so you can't use PIN_NAMES instead of NELEMENTS.
This is generally strange because this problem was discovered many years ago and from around 2018-2019 there is information about patches where the last updates to 2.7.15 were made relatively recently.
Oddly enough, even the instruction for 2.8.2 does not provide function 06 until development 2.9, this function is in the instruction
I have been struggling with this topic for the next few days and we have a breakthrough & pageNo = 1
I was able to update by pulling the MB2HAL file from version 2.9 and uploading it to my 2.7.15
PIN_NAMES and NELEMENTS work now, as well as writing to single register 06.
I am at the stage of getting along with the inverter -It is strange that the communication errors that I encountered during attempts with ClassicLaddder have disappeared
Some information for posterity in the appendices
Yes, of course, I tried 06 but Linuxnc does not even turn on then, it only crashes an error right away, so you can't use PIN_NAMES instead of NELEMENTS.
This is generally strange because this problem was discovered many years ago and from around 2018-2019 there is information about patches where the last updates to 2.7.15 were made relatively recently.
Oddly enough, even the instruction for 2.8.2 does not provide function 06 until development 2.9, this function is in the instruction
I have been struggling with this topic for the next few days and we have a breakthrough & pageNo = 1
I was able to update by pulling the MB2HAL file from version 2.9 and uploading it to my 2.7.15
PIN_NAMES and NELEMENTS work now, as well as writing to single register 06.
I am at the stage of getting along with the inverter -It is strange that the communication errors that I encountered during attempts with ClassicLaddder have disappeared
Some information for posterity in the appendices
cnc@192:~$ cd /tmp/
cnc@192:/tmp$ wget http://buildbot.linuxcnc.org/dists/wheezy/master-rt/binary-i386/linuxcnc_2.9.0~pre0.3879.g9a26e69_i386.deb
--2022-01-05 10:08:46-- http://buildbot.linuxcnc.org/dists/wheezy/master-rt/binary-i386/linuxcnc_2.9.0~pre0.3879.g9a26e69_i386.deb
Translacja buildbot.linuxcnc.org (buildbot.linuxcnc.org)... 75.166.176.174
Łączenie się z buildbot.linuxcnc.org (buildbot.linuxcnc.org)|75.166.176.174|:80... połączono.
Żądanie HTTP wysłano, oczekiwanie na odpowiedź... 200 OK
Długość: 25565922 (24M) [application/x-debian-package]
Zapis do: `linuxcnc_2.9.0~pre0.3879.g9a26e69_i386.deb'
100%[======================================>] 25.565.922 955K/s w 26s
2022-01-05 10:09:13 (953 KB/s) - zapisano `linuxcnc_2.9.0~pre0.3879.g9a26e69_i386.deb' [25565922/25565922]
cnc@192:/tmp$ dpkg -x linuxcnc_2.9.0~pre0.3879.g9a26e69_i386.deb temp
cnc@192:/tmp$ ldd temp/usr/bin/mb2hal
linux-gate.so.1 => (0xb773b000)
liblinuxcnchal.so.0 => /usr/lib/liblinuxcnchal.so.0 (0xb7718000)
liblinuxcncini.so.0 => /usr/lib/liblinuxcncini.so.0 (0xb7714000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb76fa000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb75fd000)
libmodbus.so.5 => /usr/lib/libmodbus.so.5 (0xb75f2000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb748a000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb739e000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb7377000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb735a000)
/lib/ld-linux.so.2 (0xb773c000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb731c000)
librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xb7313000)
cnc@192:/tmp$ sudo cp /usr/bin/mb2hal /usr/bin/mb2hal.backup
[sudo] password for cnc:
cnc@192:/tmp$ sudo cp temp/usr/bin/mb2hal /usr/bin/mb2hal
cnc@192:/tmp$
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
06 Jan 2022 14:14 - 06 Jan 2022 14:15 #230961
by Todd Zuercher
Replied by Todd Zuercher on topic MB2HAL I can read but cannot change the registry. fnct_16_write
So what version of Linuxcnc are(were) you actually running?
If you are running 2.7, that would explain it. support for "fnct_06_write_single_register" was only added master shortly before the release of 2.8, and was never back-ported to 2.7.
"fnct_06_write_single_register" isn't in the docs for 2.8, but it does look like it is in the code, so should probably work in 2.8.
Glad you were able to get it working.
If you are running 2.7, that would explain it. support for "fnct_06_write_single_register" was only added master shortly before the release of 2.8, and was never back-ported to 2.7.
"fnct_06_write_single_register" isn't in the docs for 2.8, but it does look like it is in the code, so should probably work in 2.8.
Glad you were able to get it working.
Last edit: 06 Jan 2022 14:15 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Advanced Configuration
- MB2HAL I can read but cannot change the registry. fnct_16_write
Time to create page: 0.147 seconds