Modbus2HAL configuration problem on Linux Mint 19.2

More
23 Jul 2020 06:39 - 23 Jul 2020 06:41 #175468 by FDA16_fan
Hello,

I would like to ask you for help. I'm trying to set the modbus connection with MB2HAL method from this link:

linuxcnc.org/docs/html/drivers/mb2hal.html

Previously, I had a working modbus connection using Classic Ladder module, but I recently changed my wheezy for Mint 19.2 linux, and those settings didn't work anymore. I think MB2HAL will work better, as I had some annoying errors with Classic Ladder before.

First of all, I added this command to my main .HAL file:
loadusr -W mb2hal config=test_modbus.ini
where "test_modbus" is a name I created.

Then, I created the test_modbus.ini file and put it in the config directory of my machine's LinuxCNC profile. Is there any other step that I didn't do?

Most importantly, my VFD is LG LG IG5A - SV015IG5A-4 (P: 1,5KW, U: 3X400V, I: 4A). I have a manual for it here:
inverterdrive.com/file/LS-Starvert-iG5A-Manual

I know that there is the instruction in the .INI file on how to set it up, but would you be so kind and tell if the code below is correct? I have doubts about setting the following parameters for each transaction:

HAL_TX_NAME (how to name the signals for spindle start, spindle forward and spindle backwards?)
MB_SLAVE_ID
FIRST_ELEMENT
NELEMENTS
SERIAL_STOP

Also, I am not entirely sure what is the "transaction" and how it works.

I would be so grateful, as this is something I will not be able to solve by myself. If you need more info from my side to be able to help me out, please let me know. Thank you!


My "test_modbus.ini" file below:
[MB2HAL_INIT]

INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=3


[TRANSACTION_00]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_16_write_multiple_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=
MAX_UPDATE_RATE=0.0
DEBUG=1


[TRANSACTION_01]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_16_write_multiple_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=
MAX_UPDATE_RATE=0.0
DEBUG=1

[TRANSACTION_02]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=
MAX_UPDATE_RATE=0.0
DEBUG=1
Last edit: 23 Jul 2020 06:41 by FDA16_fan.

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

More
23 Jul 2020 17:53 - 23 Jul 2020 17:54 #175557 by Todd Zuercher
It is rather annoying when they do this sort of thing but it looks like your drive might not be able to accept a write multiple coils command.
"fnct_15_write_multiple_coils (15 = 0x0F)"
Which would be the best thing to use for one of your transactions. If function 15 won't work (try it anyway and see if it doesn't work.)
This would write the individual bits and set up hal pins for them starting at the first bit of the register.

If function 15 won't work, to work around this you'd need to use a a function 16 to write a word, You'll have to use a something like the hal component weighted sum to string together all of the nessisary bits to form the word that needs written to register 0x0006.

It looks like you'd want to write to registers 0x0005 (to set the freq.) and 0x0006 (preferably write coils on 0x0006) and read 0x000A for the output frequency. If the drive won't take a write coils command I'd combine writing 5 and 6 into a single transaction with 2 elements (NELEMENTS=2).

MB_SLAVE_ID (is the id number of your slave device on the MB, probably 0 or 1)
FIRST_ELEMENT (the 1st register address you are accessing in this transaction)
NELEMENTS (how many addresses this transaction sets up)
SERIAL_STOP (what kind of stop bit is used)
Last edit: 23 Jul 2020 17:54 by Todd Zuercher.

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

More
23 Jul 2020 18:03 #175558 by Todd Zuercher
Something like this
[MB2HAL_INIT]

INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=3


[TRANSACTION_00]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=5
NELEMENTS=1
MB_TX_CODE=fnct_16_write_multiple_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VFD-FREQ-CMD
MAX_UPDATE_RATE=0.0
DEBUG=1


[TRANSACTION_01]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=6
NELEMENTS=8
MB_TX_CODE=fnct_15_write_multiple_coils
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VFD-CMD
MAX_UPDATE_RATE=0.0
DEBUG=1

[TRANSACTION_02]

LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=10
MB_SLAVE_ID=1
FIRST_ELEMENT=10
NELEMENTS=1
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VFD-FREQ
MAX_UPDATE_RATE=0.0
DEBUG=1

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

More
27 Jul 2020 18:14 #176112 by FDA16_fan
Hi Todd,

Thank you for help. I tried your code, also with changing some parameters, but it still didn't work. Is there any way to see that something at all is going on at communication level? I'm afraid that it works, but doesn't steer correct things in VFD.. I don't get any error messages like I was getting in classicladder. At least I knew that something is wrong then..

Also, I checked my jitter levels and they are around 30000-40000 and overall LinuxCNC speed seems a bit slow. Could that also be the reason why modbus doesn't work?

Furthermore, I checked boot log and there are some usb errors. Please check a fragment with those errors below:
...
[    5.129856] usb 2-8: device descriptor read/64, error -62
[    5.419857] usb 2-8: device descriptor read/64, error -62
[    5.700857] usb 2-8: new low-speed USB device number 5 using ohci-pci
[    5.746457] usb-storage 1-3:1.0: USB Mass Storage device detected
[    5.747723] scsi host4: usb-storage 1-3:1.0
[    5.748597] usbcore: registered new interface driver usb-storage
[    5.752002] usbcore: registered new interface driver uas
[    5.881861] usb 2-8: device descriptor read/64, error -62
[    6.171864] usb 2-8: device descriptor read/64, error -62
[    6.199139] random: plymouthd: uninitialized urandom read (8 bytes read)
[    6.199402] random: plymouthd: uninitialized urandom read (8 bytes read)
[    6.278888] usb usb2-port8: attempt power cycle
[    6.332124] raid6: sse2x1   gen()  2136 MB/s
[    6.348942] raid6: sse2x1   xor()  2046 MB/s
[    6.365966] raid6: sse2x2   gen()  2738 MB/s
[    6.382914] raid6: sse2x2   xor()  2292 MB/s
[    6.399958] raid6: sse2x4   gen()  2945 MB/s
[    6.416914] raid6: sse2x4   xor()  1664 MB/s
[    6.416916] raid6: using algorithm sse2x4 gen() 2945 MB/s
[    6.416917] raid6: .... xor() 1664 MB/s, rmw enabled
[    6.416919] raid6: using intx1 recovery algorithm
[    6.429399] xor: measuring software checksum speed
[    6.438893]    prefetch64-sse:  5060.000 MB/sec
[    6.449005]    generic_sse:  4816.000 MB/sec
[    6.449007] xor: using function: prefetch64-sse (5060.000 MB/sec)
[    6.495909] Btrfs loaded, crc32c=crc32c-generic
[    6.759869] scsi 4:0:0:0: Direct-Access     USB      Disk 2.0         2.00 PQ: 0 ANSI: 4
[    6.761473] sd 4:0:0:0: Attached scsi generic sg2 type 0
[    6.761594] sd 4:0:0:0: [sdb] 30433280 512-byte logical blocks: (15.6 GB/14.5 GiB)
[    6.762213] sd 4:0:0:0: [sdb] Write Protect is off
[    6.762217] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00
[    6.762828] sd 4:0:0:0: [sdb] No Caching mode page found
[    6.762897] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[    6.764923] usb 2-8: new low-speed USB device number 6 using ohci-pci
[    6.766355]  sdb: sdb1
[    6.769202] sd 4:0:0:0: [sdb] Attached SCSI removable disk
[    6.914585] random: crng init done
[    7.182860] usb 2-8: device not accepting address 6, error -62
[    7.356860] usb 2-8: new low-speed USB device number 7 using ohci-pci
[    7.774858] usb 2-8: device not accepting address 7, error -62
[    7.774875] usb usb2-port8: unable to enumerate USB device
[   19.112131] print_req_error: I/O error, dev fd0, sector 0
...

I would be really, really grateful for your expertise, as I don't feel like being able to solve this problem alone...

Many thanks!!

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

More
27 Jul 2020 18:35 #176119 by tommylight
Some device on port 8 is causing issues, so try removing USB stuff one by one and checking the error log.

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

More
27 Jul 2020 19:45 #176140 by Todd Zuercher
I'm also concerned that you say it was working with ClassicLadder, then it wasn't. What ever changed to stop the drive's modbus communication with CL is likely still stopping it with Mb2hal.

Also when testing the Modbus connection it is wise to start Linuxcnc from the command line, then errors from the modbus connection will be printed to there.

You also need to be sure what the address of your USB/RS485 dongle. Is it in fact ttyUSB0, as specified int the Mb2hal ini?

Really the hardest part for me was gathering all the info for and correctly configure the drives to receive the modbus commands. It is essential that all the baud rates, parity bits, addresses, and register numbers be correct for it all to work properly.

Personally I thought setting up the modbus communication was easier using CL than Mb2hal. The only reason I am using Mb2hal is because, CL is limited in the number of modbus transactions it can do. I needed more than it's limit of 16 to control 8 VFDs with 4 transactions each. So I never did more than testing with CL to see that I could actually control a couple of the drives at the same time.

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

Time to create page: 0.070 seconds
Powered by Kunena Forum