MB2HAL Vacon vfd

More
7 years 5 hours ago #149278 by stes
MB2HAL Vacon vfd was created by stes
I have Vacon vfd connected to serial RS-485 to RS-232 converter. How to connect signals in Hal file, so that the Linux cnc can read the spindle speed and send run and speed commands to the vfd?

This is the INI file I have made
Code:
[MB2HAL_INIT] INIT_DEBUG=3 HAL_MODULE_NAME=mb2hal SLOWDOWN=0.0 TOTAL_TRANSACTIONS=3 [TRANSACTION_00] LINK_TYPE=serial SERIAL_PORT=/dev/ttyS0 SERIAL_BAUD=9600 SERIAL_BITS=8 SERIAL_PARITY=none SERIAL_STOP=1 SERIAL_DELAY_MS=10 MB_SLAVE_ID=1 FIRST_ELEMENT=8453 NELEMENTS=16 MB_TX_CODE=fnct_03_read_holding_registers MB_RESPONSE_TIMEOUT_MS=500 MB_BYTE_TIMEOUT_MS=500 HAL_TX_NAME=info MAX_UPDATE_RATE=0.0 DEBUG=1 [TRANSACTION_01] FIRST_ELEMENT=8193 NELEMENTS=16 MB_TX_CODE=fnct_06_write_single_register MB_RESPONSE_TIMEOUT_MS=500 MB_BYTE_TIMEOUT_MS=500 HAL_TX_NAME=runmode MAX_UPDATE_RATE=0.0 DEBUG=1 [TRANSACTION_02] FIRST_ELEMENT=8195 NELEMENTS=16 MB_TX_CODE=fnct_06_write_single_register MB_RESPONSE_TIMEOUT_MS=500 MB_BYTE_TIMEOUT_MS=500 HAL_TX_NAME=rpm MAX_UPDATE_RATE=0.0 DEBUG=1

Please Log in to join the conversation.

More
6 years 11 months ago #149337 by pl7i92
Replied by pl7i92 on topic MB2HAL Vacon vfd
Thank you for your WORK
good advice is only to get one SPACE line in the INI
it may tweek your interpreter to break away if there is to many space

Please Log in to join the conversation.

More
6 years 11 months ago #149351 by stes
Replied by stes on topic MB2HAL Vacon vfd
It's not actually my work but I edited the MB2HAL to suit my Vacon vfd.

But I have no idea how I can make Linux cnc to communicate with the vfd I'm using.

Please Log in to join the conversation.

More
6 years 11 months ago #149363 by Todd Zuercher
Replied by Todd Zuercher on topic MB2HAL Vacon vfd
Do you have a machine configuration that runs your machine?

You have to save your MB2HAL ini file you posed into your config directory. Then add the appropriate hal commands to the hal file(s) for your machines configuration.

MB2HAL will then create hal pins defined in your MB2HAL ini file. This isn't the same ini file as your Linuxcnc machine's configuration ini, that is a separate file in the same directory.

If you have your VFD and MB2HAL properly configured, when you start Linuxcnc, the VFD should start to communicate with Linuxcnc. You should then be able to send commands to the VFD by changing the values of the hal input pins created by MB2HAL and read info from the output pins.

You can check the status of and set values to the hal pins while Linuxcnc is running by using Halshow (Show Hal Configuration in the Axis, Machine menu). Or by using the Halcmd prompt from a terminal window (open this using the command "halcmd -kf").

Once you've confirmed that MB2HAL is working with your VFD, you will need to edit your hal files for your configuration to make the right hal pin connections to control your VFD.

I've done this once before, but it was a long time ago. I have posted my configuration for that machine on the forum before as an example. Here is a link to it.
forum.linuxcnc.org/media/kunena/attachments/3190/Digital6.zip
It is for a gang router that has 8 VFDs for 8 router spindles. The config also uses a small Classicladder program for modifying and reading some of the hal pin values that the VFDs use when communicating with MB2HAL. So for all of its complications maybe it is or isn't a good example config.

Please Log in to join the conversation.

More
6 years 11 months ago #149368 by stes
Replied by stes on topic MB2HAL Vacon vfd
Yes, the machine is working otherwise.

I don't know how to connect the pins in hal file. 3 first bits control the VFD, or example 1 0 1 would mean run clockwise. right? But what I should write in the hal file, so when I click run spindle in Linux cnc the 1 0 1 control word will be sent to the VFD?

Please Log in to join the conversation.

More
6 years 11 months ago #149375 by Todd Zuercher
Replied by Todd Zuercher on topic MB2HAL Vacon vfd
I think I see a number of problems in your MB2HAL ini file and that is making it hard for me to pickout what you are asking for.

for example your first transaction defined is going to create 16 floating point hal output pins that would display the contents of 16 registers read from your VFD starting at the one found at 8453. Those pins will be called "mb2hal.info.00" - "mb2hal.info.15".

Your next two transactions don't even use the correct MB_TX_CODEs. As far as I know "fnct_06_write_single_register" may not even be a valid option in MB2HAL.

To set bits you would need to use "fnct_15_write_multiple_coils". If you changed the 2nd transaction to this, MB2HAL would create 16 hal input single bit pins called "mb2hal.runmode.00" - "mb2hal.runmode.15"

If those1st 3 registers would be the registers you are talking about needing to change to 1 0 1. Then you would need to connect them to the appropriate outputs in your hal file to get the responce you want, Probably pins such as motion.spindle-forward, motion.spindle-reverse, or motion.spindle-on.

If "fnct_06_write_single_register" will work, it would only work on a single register, so I think you will need to change the number of elements to 1.

All of this is kind of guessing from fuzzy memories of what I tried to do a number of years ago. May just need to run it and see what hal pins are made available and what they do.

Another option for you might be trying to use the modbus capabilities of ClassicLadder.

Please Log in to join the conversation.

More
6 years 11 months ago #150412 by stes
Replied by stes on topic MB2HAL Vacon vfd
I think function code 06 is valid because someone is using it.

Did you check the pdf I linked in the first post? My VFD doesn't support function code 15. Only codes 03, 04, 06 and 16 are supported.

If i have understood correctly, there are no coils to write. But I have to send a control word, and the first 3 bits of that control word will control the spindle.

Please Log in to join the conversation.

More
6 years 11 months ago #150428 by Todd Zuercher
Replied by Todd Zuercher on topic MB2HAL Vacon vfd
I meant that I don't think Mb2hal supports mode 06, because it isn't mentioned in the Mb2hal documentation. I think it can still work but it will make setting up your hal file a bit more difficult. Just use mode 16 instead of 06. This will be for registers that you are writing to (not reading). You will need to use a weighted_sum component to convert your bit inputs into an S32 integer, then convert that S32 into a float using conv_s32_float, then connect the output of the s32 conversion to the nessisary input of Mb2hal.

Perhaps it might be simpler for you to do all of this including the Modbus communication within Classicladder. (it can do Modbus as well.)
linuxcnc.org/docs/2.6/html/ladder/classic_ladder.html#_modbus
I believe it does support 06.
I would have used it in my configuration except that I needed to do more transactions than it could handle (limit is 16 I think and I needed 32.) I did use Classic ladder's modbus for my initial testing with just a couple VFDs. It was much simpler to configure and get working than Mb2hal.

Please Log in to join the conversation.

More
6 years 5 months ago #167960 by stes
Replied by stes on topic MB2HAL Vacon vfd
It's working now, except when spindle is reversed the pyVCP bar shows the rpm wrong, it's 60 000 instead of 5000. Guess it's because the rpm scale from vfd is +/-. Is the some way to convert it to get the correct rpm reading?

I didn't try Classicladder because not familiar with it.

I leave the code here, maybe it's useful for someone else. And if you use Vacon remember to subtract 1 from the address number.
Code:
[MB2HAL_INIT] INIT_DEBUG=0 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=1 SERIAL_DELAY_MS=150 MB_SLAVE_ID=1 FIRST_ELEMENT=2104 NELEMENTS=1 MB_TX_CODE=fnct_03_read_holding_registers MB_RESPONSE_TIMEOUT_MS=500 MB_BYTE_TIMEOUT_MS=500 HAL_TX_NAME=rpm MAX_UPDATE_RATE=0.0 [TRANSACTION_01] FIRST_ELEMENT=2000 NELEMENTS=1 MB_TX_CODE=fnct_16_write_multiple_registers HAL_TX_NAME=control MAX_UPDATE_RATE=0.0 [TRANSACTION_02] FIRST_ELEMENT=2002 NELEMENTS=1 MB_TX_CODE=fnct_16_write_multiple_registers HAL_TX_NAME=speed MAX_UPDATE_RATE=0.0
Code:
# Include your customized HAL commands here # This file will not be overwritten when you run stepconf again loadusr -W mb2hal config=mb2hal.ini loadrt mult2 loadrt mux4 loadrt and2 count=2 loadrt near addf mult2.0 servo-thread addf mux4.0 servo-thread addf and2.0 servo-thread addf and2.1 servo-thread addf near.0 servo-thread setp mult2.0.in0 31.25 #320 x 31.25 = 10 000 net spindle-cmd-rps-abs => mult2.0.in1 net speed.vfd mb2hal.speed.00 <= mult2.0.out net spindle-cmd-rps-abs <= motion.spindle-speed-out-rps-abs net S-on and2.0.in0 <= motion.spindle-on net S-fwd and2.0.in1 <= motion.spindle-forward net S-on and2.1.in0 net S-rev and2.1.in1 <= motion.spindle-reverse net S-on-fwd mux4.0.sel0 <= and2.0.out net S-on-rev mux4.0.sel1 <= and2.1.out setp mux4.0.in0 4 #100stop setp mux4.0.in1 5 #101forward setp mux4.0.in2 7 #111reverse setp mux4.0.in3 4 #100reset net control mb2hal.control.00 <= mux4.0.out net rpm-abs motion.spindle-speed-out-abs => near.0.in1 #spindle rpm command net rpm.vfd => near.0.in2 #spindle rpm from vfd net spindle-at-speed motion.spindle-at-speed <= near.0.out setp near.0.scale 1.02
Code:
# Include your customized HAL commands here # The commands in this file are run after the AXIS GUI (including PyVCP panel) starts net rpm.vfd mb2hal.rpm.00.float => pyvcp.spindle-speed net spindle-at-speed => pyvcp.spindle-at-speed
Code:
<?xml version="1.0" encoding="UTF-8"?> <pyvcp> <labelframe text="VFD"> <font>("Helvetica",10)</font> <table> <tablerow/> <tablesticky sticky="w"/> <label> <text>"Spindle at speed:"</text> </label> <tablesticky sticky="e"/> <led> <halpin>"spindle-at-speed"</halpin> <size>"10"</size> <on_color>"green"</on_color> <off_color>"red"</off_color> </led> <tablerow/> <label> <text>" "</text> </label> </table> <table> <tablesticky sticky="nsew"/> <tablerow/> <tablesticky sticky="nsew"/> <label> <text>"Spindle Speed (RPM)"</text> <font>("Helvetica",10)</font> </label> <tablerow/> <tablesticky sticky="nsew"/> <label> <text>" "</text> <font>("Helvetica",2)</font> </label> <tablerow/> <tablesticky sticky="nsew"/> <bar> <halpin>"spindle-speed"</halpin> <min_>5000</min_> <max_>19200</max_> </bar> </table> </labelframe> </pyvcp>

Please Log in to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum