mb2hal: trying to control a Siemens Sinamics V20 VFD

More
07 Sep 2021 21:40 #219884 by flawapawacrew
Hello everyone,

I am new to the forum and to linuxcnc. I am currently trying to connect with a Sinamics VFD using mb2hal.

My setup is a RaspberryPi 4 with the "official" linuxcnc raspibian build with USB to RS485 adapter. This is connected to the VDF using a twisted pair and GND, and all terminating resistors, etc... are connected as recommended by the Operating instructions (attached). I scoped the signals, double, triple checked the parameters set in the VFD. I am 90% sure the communication setup in hardware is sane.

I wrote a very simple .ini file and .hal file to test the communication (attached). The .ini file was written based on the the Operating instructions for number of bits, partiy, etc...

I use
halcmd -f sinamics_mb2hal.hal
to start the hal component. Unfortunately, I get an error message after sending the first command (returned by the VFD if I am not mistaken):
ERROR Illegal data address

The complete output of the shell command is attached ("shell_mb2hal_output_short.txt"). This is with all debug levels set to 3.

From what I understand, the register addresses are wrongly defined...? I followed the table at page 142 of the Operating Instructions.
Is there something I am missing here?

Also, I noted an error at the beginning:
sinamics_mb2hal.hal:8: Pin 'mb2hal.00.00' does not exist

Which makes no sense to me as transaction 00 is defined and we read two registers. Note that this error is not present for mb2hal.00.01
Again, am I missing something?

I thank you in advance for your insight!

Cheers,

Flawa
Attachments:

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

More
07 Sep 2021 21:51 #219887 by flawapawacrew
Hello,

Apparently the attached pdf was not uploaded. The Operating Instructions can be consulted online at this address :
www.manualslib.com/manual/1203313/Siemen...html?page=142#manual

Cheers,

Flawa

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

More
12 Sep 2021 13:27 #220306 by andypugh
It is possible that the error you see is caised by the earlier error:
sinamics_mb2hal.hal:8: Pin 'mb2hal.00.00' does not exist

Is it possible to fix that? If you insert a line "show pin" straight after the loadrt mb2hal line then you will get a dump of all the pins that exist at that point in the output.

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

More
13 Sep 2021 16:29 #220458 by flawapawacrew
Hi andypugh,

thank you for your answer!

Using
show pin
, I was able to understand that there is a
mb2hal.00.00.int
and
mb2hal.00.00.float
pin. Using either of them did get rid of the aforementionned error. So that's a step forward!

Unfortunaltely, the
Illegal data address
error still shows up. I tried with different register addresses in the range 40000 - 40038 with no success. An example of modbus communication found on the siemens website (support.industry.siemens.com/cs/document...h-hmi?dti=0&lc=en-US) seems to confirm that I am using the correct range of addresses.

I will probably factory reset and re-configure, just to be sure.

I am also wondering if there is a precise order in which one needs to access the drive's registers...

Will keep you posted.

Cheers,

Thierry

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

More
13 Sep 2021 16:54 - 13 Sep 2021 16:57 #220463 by Aciera
I think in mb2hal you can turn on a debug mode that shows you the actual data being sent and recieved. That might be helpful to compare with the example modbus communication. So maybe set INIT_DEBUG=3
[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=3
Last edit: 13 Sep 2021 16:57 by Aciera.

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

More
15 Sep 2021 16:17 #220713 by Todd Zuercher
You might try using 38 (or 37 or 39) instead of 40038 as the element#.

I know the drives I'm using work that way (but they are not Siemens). The documentation lists the addresses as 400XX, but in my config I subract 40,000 from the number. So for address 40008, I'd use FIRST_ELEMENT=8 for 40038, I'd use FIRST_ELEMENT=38.

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

More
17 Sep 2021 15:51 - 17 Sep 2021 15:53 #220915 by flawapawacrew
Thank you folks for the advice!

@Aciera: I am using INIT_DEBUG=3. This is the typical output I get (here trying to access register 40011):
[code]halcmd -f sinamics_mb2hal.hal
...
mb2hal parse_ini_file OK: parse_transaction_section 0 OK
mb2hal main OK: parse_ini_file done OK
mb2hal init_mb_links DEBUG: LINK 0 (RTU) link_type[0] device[/dev/ttyUSB0] baud[9600] data[8] parity[E] stop[1] fd[-1]
mb2hal main OK: init_gbl.mb_link done OK
mb2hal init_mb_tx DEBUG: MB_TX 0 lk_n[0] tx_n[0] cfg_dbg[3] lk_dbg[1] t_inc[0.100] nxt_t[0.000]
mb2hal main OK: init_gbl.mb_tx done OK
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.accel_time.num_errors]
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.accel_time.00]
mb2hal main OK: HAL components created OK
mb2hal main OK: Link thread loop and logic 0 created OK
mb2hal main OK: mb2hal is running

Component Pins:
Owner   Type  Dir         Value  Name
     4  float OUT             0  mb2hal.accel_time.00.float
     4  s32   OUT             0  mb2hal.accel_time.00.int
     4  u32   OUT    0x00000000  mb2hal.accel_time.num_errors

mb2hal link_loop_and_logic DEBUG: mb_tx_num[0] mb_links[0] thread[0] fd[-1] going to TEST availability
mb2hal link_loop_and_logic DEBUG: mb_tx_num[0] mb_links[0] thread[0] fd[-1] going to TEST connection
mb2hal get_tx_connection DEBUG: mb_tx_num[0] mb_links[0] new connection -> fd[4]
mb2hal link_loop_and_logic DEBUG: mb_tx_num[0] mb_links[0] thread[0] fd[4] lk_dbg[1] going to EXECUTE transaction
[b]mb2hal fnct_03_read_holding_registers DEBUG: mb_tx[0] mb_links[0] slave[1] fd[4] 1st_addr[40011] nelem[1]
[01][03][9C][4B][00][01][DA][4C]
Waiting for a confirmation...
<01><83><02><C0><F1>
ERROR Illegal data address
mb2hal fnct_03_read_holding_registers ERR: mb_tx[0] mb_links[0] slave[1] = ret[-1] fd[4]
mb2hal link_loop_and_logic ERR: mb_tx_num[0] mb_links[0] thread[0] fd[4] transaction failure, num_errors[1]
Bytes flushed (0)
mb2hal link_loop_and_logic DEBUG: mb_tx_num[0] mb_links[0] thread[0] fd[4] SERIAL_DELAY_MS activated [0]
mb2hal link_loop_and_logic DEBUG: mb_tx_num[0] mb_links[0] thread[0] fd[4] gbl.slowdown activated [1.000]
...
sudo pkill mb2hal
mb2hal quit_signal DEBUG: signal [15] received
mb2hal quit_cleanup DEBUG: started
mb2hal quit_cleanup DEBUG: unloading HAL module [4] ret[0]
mb2hal quit_cleanup DEBUG: done OK
mb2hal main OK: going to exit![/b]
[/code]
As you see the only error is the illegal data address, everything else seems to be fine. And the response bytes are consistent. This leads me to suppose that the hardware comm is fine (since everything is consistent), and the sent bytes and answer bytes are coherent with what should be sent and received (I checked that).

@Todd: Ok, will try! I just thought "It can't be that simple"...
Last edit: 17 Sep 2021 15:53 by flawapawacrew.

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

More
17 Sep 2021 16:01 #220917 by Aciera
Ah yes, I'm sorry I didn't catch that you were using debug level 3 in your first post. And yes your hardware and com parameters seem correct given the answer from the vfd.

An example of modbus communication found on the siemens website

I couldn't find the example but I expected it to show an actual Modbus telegram.  My approach would be to try and replicate that telegram and verify that using the debug information:[01][03][9C][4B][00][01][DA][4C]

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

More
17 Sep 2021 23:43 #220962 by tommylight

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

More
20 Sep 2021 16:44 #221207 by flawapawacrew
So it turns out Todd was correct. I tried to access register 11 (instead of 40011) and the communication went through! Thanks Todd :)

I now have to figure out how to write my hal file in order to send the correct commands.

I might need your insight on that, but I have to do some reading and testing first :)

Cheers!

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

Time to create page: 0.114 seconds
Powered by Kunena Forum