Setting up USB -> Modbus (CH340) for VFD control

More
9 years 8 months ago #88149 by cncnoob1979
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
Code:
lsusb

I get the output of:
Code:
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.
Code:
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!

Please Log in to join the conversation.

More
9 years 8 months ago #88166 by Victor
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!

Please Log in to join the conversation.

More
9 years 8 months ago #88172 by cncnoob1979
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.

Please Log in to join the conversation.

More
9 years 8 months ago #88182 by Todd Zuercher
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)
Code:
[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))

Please Log in to join the conversation.

More
9 years 8 months ago #88657 by Victor
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!

Please Log in to join the conversation.

More
9 years 8 months ago #88664 by Todd Zuercher

Victor wrote: 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.

Please Log in to join the conversation.

More
9 years 7 months ago #89173 by Victor
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

Please Log in to join the conversation.

Time to create page: 0.265 seconds
Powered by Kunena Forum