Setting up USB -> Modbus (CH340) for VFD control
- cncnoob1979
-
- Offline
- Platinum Member
-
Less
More
- Posts: 403
- Thank you received: 75
18 Feb 2017 01:21 #88149
by cncnoob1979
Replied by cncnoob1979 on topic Setting up USB -> Modbus (CH340) for VFD control
Is there a component already written for you VFD? What vfd did you purchase? Im using the cheap hyang or someting via "modbus" well their non-compliant version of it.
When you load the user-space component, the component will create pins for you to connect to. In my custom.hal file listed below is an example of what I have.
I had to chmod 666 the usb dongle to connect with it. If you try to connect and get an error then more than likely you will need to add a rule to connect to the device. But I'm getting ahead of myself, lets see what you have and Ill try to help you as best as I can.
when issueing the command in a terminal
I get the output of:
This is my dongle.
What do you get? You may need to install usbtools I believe it is called for the lsusb to work. Let me know if you run into a snag.
When you load the user-space component, the component will create pins for you to connect to. In my custom.hal file listed below is an example of what I have.
I had to chmod 666 the usb dongle to connect with it. If you try to connect and get an error then more than likely you will need to add a rule to connect to the device. But I'm getting ahead of myself, lets see what you have and Ill try to help you as best as I can.
when issueing the command in a terminal
lsusb
I get the output of:
bridgeport@bridgeport-H81M-S2PH ~ $ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 003 Device 005: ID 222a:0045
Bus 003 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 003 Device 003: ID 10ce:eb70 Silicon Labs
Bus 003 Device 002: ID 1c4f:0034 SiGma Micro
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
This is my dongle.
Bus 003 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
What do you get? You may need to install usbtools I believe it is called for the lsusb to work. Let me know if you run into a snag.
Warning: Spoiler!
# Load the Huanyang VFD user component
loadusr -Wn spindle-vfd hy_vfd -d /dev/ttyUSB0 -n spindle-vfd
#String With all the different options## loadusr -Wn spindle-vfd hy_vfd -n spindle-vfd -n -r 19200 -b 8 -p none -s 1 -t 1
# connect the spindle direction pins to the VFD
net hy-fwd <= motion.spindle-forward => spindle-vfd.spindle-forward
net hy-rev <= motion.spindle-reverse => spindle-vfd.spindle-reverse
# connect the spindle on pin to the VFD
net hy-on <= motion.spindle-on => spindle-vfd.spindle-on
# connect the spindle RPM to the VFD
# Note: spindle-cmd created by stepconf wizard
net spindle-vel-cmd-rpm => spindle-vfd.speed-command
The following user(s) said Thank You: Victor
Please Log in or Create an account to join the conversation.
- Victor
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
18 Feb 2017 09:24 #88166
by Victor
Replied by Victor on topic Setting up USB -> Modbus (CH340) for VFD control
Hi!
unfortunately there is no component written for my VFD what i can find.
i purchased a ENC EN600-4T0037G/0055P inverter.
if i run the lsusb i get pretty much the same as you: Bus 003 Device 006: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
and it is on /dev/ttyUSB0
So i guess creating the user space component for VFD is my main problem..
Thankful for any help i can get as i'm really stuck on this one!
unfortunately there is no component written for my VFD what i can find.
i purchased a ENC EN600-4T0037G/0055P inverter.
if i run the lsusb i get pretty much the same as you: Bus 003 Device 006: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
and it is on /dev/ttyUSB0
So i guess creating the user space component for VFD is my main problem..
Thankful for any help i can get as i'm really stuck on this one!
Please Log in or Create an account to join the conversation.
- cncnoob1979
-
- Offline
- Platinum Member
-
Less
More
- Posts: 403
- Thank you received: 75
18 Feb 2017 16:58 #88172
by cncnoob1979
Replied by cncnoob1979 on topic Setting up USB -> Modbus (CH340) for VFD control
Hmm,
well if i was faced with that issue I would control the vfd via analog voltage. The issue is that a user component has to be written and then you can connect via modbus. Perhaps someone here with more experience can help you write one for your use. Or if you are skilled in that particular area you would have to write one yourself. I wish I could help you with that task but I am not talented in that area.
I can help you once a component has been written and afterwards however.
Another solution is to return the ENC EN600-4T0037G and go with a VFD that is commonly used and already has a component written for it.
well if i was faced with that issue I would control the vfd via analog voltage. The issue is that a user component has to be written and then you can connect via modbus. Perhaps someone here with more experience can help you write one for your use. Or if you are skilled in that particular area you would have to write one yourself. I wish I could help you with that task but I am not talented in that area.
I can help you once a component has been written and afterwards however.
Another solution is to return the ENC EN600-4T0037G and go with a VFD that is commonly used and already has a component written for it.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Away
- Platinum Member
-
Less
More
- Posts: 4981
- Thank you received: 1451
18 Feb 2017 20:16 - 19 Feb 2017 21:31 #88182
by Todd Zuercher
Replied by Todd Zuercher on topic Setting up USB -> Modbus (CH340) for VFD control
It should be able to be done with the generic mb2hal component or using Classicladder. (in fact using Classicladder might be simpler.) You just have to sort out all the details.
something like this (I make no claims about it's correctness)
something like this (I make no claims about it's correctness)
[MB2HAL_INIT]
INIT_DEBUG=0
.
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=3
# Set Run Status
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=9600
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=1
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=7680
NELEMENTS=1
MB_TX_CODE=fnct_16_write_multiple_registers
HAL_TX_NAME=run
MAX_UPDATE_RATE=0.0
DEBUG=3
# Set Frequency
[TRANSACTION_01]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=7681
NELEMENTS=1
HAL_TX_NAME=frequency
MAX_UPDATE_RATE=0.0
DEBUG=3
# VFD Status
[TRANSACTION_02]
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=0
NELEMENTS=16
HAL_TX_NAME=is-running
MAX_UPDATE_RATE=0.0
DEBUG=3
#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))
Last edit: 19 Feb 2017 21:31 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- Victor
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
27 Feb 2017 09:07 #88657
by Victor
Replied by Victor on topic Setting up USB -> Modbus (CH340) for VFD control
Ok, could you explain what the diffrent codes would translate to in my VFD manual? i'm having a hard time seeing the connection.
FIRST_ELEMENT=7680 = What is this?
NELEMENTS=1 = What is this?
MB_TX_CODE=fnct_16_write_multiple_registers = is this a standard function in modbus to be able to write values to the vfd?
HAL_TX_NAME=run = is this for linuxcnc's side?
MAX_UPDATE_RATE=0.0
DEBUG=3
# Set Frequency
[TRANSACTION_01] = what would this be?
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=7681
NELEMENTS=1
HAL_TX_NAME=frequency
MAX_UPDATE_RATE=0.0
DEBUG=3
Thanks!
FIRST_ELEMENT=7680 = What is this?
NELEMENTS=1 = What is this?
MB_TX_CODE=fnct_16_write_multiple_registers = is this a standard function in modbus to be able to write values to the vfd?
HAL_TX_NAME=run = is this for linuxcnc's side?
MAX_UPDATE_RATE=0.0
DEBUG=3
# Set Frequency
[TRANSACTION_01] = what would this be?
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=7681
NELEMENTS=1
HAL_TX_NAME=frequency
MAX_UPDATE_RATE=0.0
DEBUG=3
Thanks!
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Away
- Platinum Member
-
Less
More
- Posts: 4981
- Thank you received: 1451
27 Feb 2017 14:04 #88664
by Todd Zuercher
I was having a little trouble understanding how your drive numbers it's register addresses in the manual you posted, and 7680 is just the decimal version of the hex number(s) listed in your manual and was my best guess at what to use.
Replied by Todd Zuercher on topic Setting up USB -> Modbus (CH340) for VFD control
Ok, could you explain what the diffrent codes would translate to in my VFD manual? i'm having a hard time seeing the connection.
FIRST_ELEMENT=7680 = What is this?This is the register address you are reading or writing to
NELEMENTS=1 = What is this?The number of register addresses in this block (can be more than one)
MB_TX_CODE=fnct_16_write_multiple_registers = is this a standard function in modbus to be able to write values to the vfd?yes
HAL_TX_NAME=run = is this for linuxcnc's side?It can define a unique name for the hal pin that is created
MAX_UPDATE_RATE=0.0
DEBUG=3
# Set Frequency
[TRANSACTION_01] = what would this be?each read/write that MB2HAL does needs a unique number this is it
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=7681
NELEMENTS=1
HAL_TX_NAME=frequency
MAX_UPDATE_RATE=0.0
DEBUG=3
Thanks!
I was having a little trouble understanding how your drive numbers it's register addresses in the manual you posted, and 7680 is just the decimal version of the hex number(s) listed in your manual and was my best guess at what to use.
The following user(s) said Thank You: Victor
Please Log in or Create an account to join the conversation.
- Victor
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
07 Mar 2017 22:00 #89173
by Victor
Replied by Victor on topic Setting up USB -> Modbus (CH340) for VFD control
Hi!
Unfortunately i was unable to get this to work, and this is way over my head and comfort zone.
So i got myself an Mesa 7i76E and will use the analog spindle control instead.
But sincerely a big thanks for your help!
// Victor
Unfortunately i was unable to get this to work, and this is way over my head and comfort zone.
So i got myself an Mesa 7i76E and will use the analog spindle control instead.
But sincerely a big thanks for your help!
// Victor
Please Log in or Create an account to join the conversation.
Time to create page: 0.070 seconds