mb2hal: trying to control a Siemens Sinamics V20 VFD

More
5 years 1 month ago - 5 years 1 month ago #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:
[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: 5 years 1 month ago by flawapawacrew.

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

More
5 years 1 month ago #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
More
5 years 1 month ago #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.

More
5 years 4 weeks ago #222215 by flawapawacrew
Good News Everyone! (that's your Futurama quote for the day...)

I finally managed to reliably and correctly control the VFD! It did take some control word, bitwise fun using wsum, but it works flawlessly in the end. Some (slightly hidden) parameters from the VFD needed tweaking.

In general mb2hal works like a charm once you have the correct register addresses.

Thank you everyone for the help!

Also, is there a repo or something where I could contribute my ini and hal files in case anyone wants to do the same with their Sinamics VFD?

Cheers,

 

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

More
5 years 3 weeks ago #222276 by Todd Zuercher
You could post them as attachments here in this thread.

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

Time to create page: 0.068 seconds
Powered by Kunena Forum