Modbus drivers for NF 9000 VFD
07 Apr 2018 05:40 #108546
by Donno
Modbus drivers for NF 9000 VFD was created by Donno
I have Huangyang VFD that is setup on RS485 using these settings :
custom.hal
loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600
net spindle-cmd-rpm-abs => vfd.speed-command
net spindle-cw motion.spindle-forward => vfd.spindle-forward
net spindle-ccw motion.spindle-reverse => vfd.spindle-reverse
net on motion.spindle-on => vfd.spindle-on
custom_postgui.hal
setp vfd.enable 1
After years of use it only works when it feels like it, so i got a replacement NFliXin 9000 VFD. I read manual and setup Com method baud, address and so on ... I discovered that the VFD have different ways of communicating !
Has anyone setup NF 9000 using modbus ?
custom.hal
loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600
net spindle-cmd-rpm-abs => vfd.speed-command
net spindle-cw motion.spindle-forward => vfd.spindle-forward
net spindle-ccw motion.spindle-reverse => vfd.spindle-reverse
net on motion.spindle-on => vfd.spindle-on
custom_postgui.hal
setp vfd.enable 1
After years of use it only works when it feels like it, so i got a replacement NFliXin 9000 VFD. I read manual and setup Com method baud, address and so on ... I discovered that the VFD have different ways of communicating !
Has anyone setup NF 9000 using modbus ?
Please Log in or Create an account to join the conversation.
09 Apr 2018 18:08 - 09 Apr 2018 18:12 #108670
by Donno
Replied by Donno on topic Modbus drivers for NF 9000 VFD
I managed to learn Modbus and connected my VFD to PC It seems this is another copy of a cheap Chinese VFD
This is NF-9000 and there is similar one called WL-9000 [Same manual] ! Think it is a clone of original HPI6000 since it uses the communication form !
Anyway here is the settings i used :
On VFD Parameter i used P093 and set it to 22.01 (PB.id)
P = Modbus, no parity , 8 bit binary
B = 19200bps , 2 stopbits
id = Slave id 1
on PC
Now that i know the Modbus function to use and the Parameters Address for speed control and moving the spindle how do i write custom hal driver ?
This is NF-9000 and there is similar one called WL-9000 [Same manual] ! Think it is a clone of original HPI6000 since it uses the communication form !
Anyway here is the settings i used :
On VFD Parameter i used P093 and set it to 22.01 (PB.id)
P = Modbus, no parity , 8 bit binary
B = 19200bps , 2 stopbits
id = Slave id 1
on PC
Now that i know the Modbus function to use and the Parameters Address for speed control and moving the spindle how do i write custom hal driver ?
Last edit: 09 Apr 2018 18:12 by Donno.
Please Log in or Create an account to join the conversation.
10 Apr 2018 13:59 #108741
by andypugh
Replied by andypugh on topic Modbus drivers for NF 9000 VFD
You might be able to use mb2hal, and not have to write a special driver:
linuxcnc.org/docs/2.7/html/drivers/mb2hal.html
linuxcnc.org/docs/2.7/html/drivers/mb2hal.html
Please Log in or Create an account to join the conversation.
10 Apr 2018 14:28 #108742
by Donno
Replied by Donno on topic Modbus drivers for NF 9000 VFD
I have looked at it and don't understand these
[TRANSACTION_06]
MB_TX_CODE=fnct_03_read_holding_registers <- understand !
FIRST_ELEMENT=1024 <- what is this
NELEMENTS=1 <- what is this
HAL_TX_NAME=XDrive04 <- what is this
MAX_UPDATE_RATE=0.0 <- what is this
Where do you put the address ???
i have started looking at python script vfd.py and there is address
#spindle vfd has slave id 1
serialvfd1 = comms.Instrument(port, 1)
serialvfd1.serial.baudrate = baudrate
serialvfd1.serial.bytesize = bytesize
serialvfd1.serial.parity = parity
serialvfd1.serial.stopbits = stopbits
serialvfd1.serial.timeout = timeout
serialvfd1.mode = comms.MODE_CUSTOM
vfd = int(serialvfd1.read_register(0x2100, 0))
Do have more documentation on mb2hal please ?
[TRANSACTION_06]
MB_TX_CODE=fnct_03_read_holding_registers <- understand !
FIRST_ELEMENT=1024 <- what is this
NELEMENTS=1 <- what is this
HAL_TX_NAME=XDrive04 <- what is this
MAX_UPDATE_RATE=0.0 <- what is this
Where do you put the address ???
i have started looking at python script vfd.py and there is address
#spindle vfd has slave id 1
serialvfd1 = comms.Instrument(port, 1)
serialvfd1.serial.baudrate = baudrate
serialvfd1.serial.bytesize = bytesize
serialvfd1.serial.parity = parity
serialvfd1.serial.stopbits = stopbits
serialvfd1.serial.timeout = timeout
serialvfd1.mode = comms.MODE_CUSTOM
vfd = int(serialvfd1.read_register(0x2100, 0))
Do have more documentation on mb2hal please ?
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
10 Apr 2018 15:46 - 10 Apr 2018 15:49 #108755
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus drivers for NF 9000 VFD
FIRST_ELEMENT=1024 <- The register address, is the same thing as the element number
NELEMENTS=1 <- You can read or write to more than one sequential register with one transaction
HAL_TX_NAME=XDrive04 <- This is for defining part of the name of the hal pin(s) that are created for this transaction.
MAX_UPDATE_RATE=0.0 <- Sets the frequency that this transaction is performed.
Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = as fast as possible).
NOTE: This is a maximum rate and the actual rate may be lower.
If you want to calculate it in ms use (1000 / required_ms).
Example: 100 ms = MAX_UPDATE_RATE=10.0, because 1000.0 ms / 100.0 ms = 10.0 Hz
The documentation is basically a commented example configuration file.
linuxcnc.org/docs/html/drivers/mb2hal.html
NELEMENTS=1 <- You can read or write to more than one sequential register with one transaction
HAL_TX_NAME=XDrive04 <- This is for defining part of the name of the hal pin(s) that are created for this transaction.
MAX_UPDATE_RATE=0.0 <- Sets the frequency that this transaction is performed.
Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = as fast as possible).
NOTE: This is a maximum rate and the actual rate may be lower.
If you want to calculate it in ms use (1000 / required_ms).
Example: 100 ms = MAX_UPDATE_RATE=10.0, because 1000.0 ms / 100.0 ms = 10.0 Hz
The documentation is basically a commented example configuration file.
linuxcnc.org/docs/html/drivers/mb2hal.html
Last edit: 10 Apr 2018 15:49 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
17 Apr 2018 09:44 #109176
by Donno
Replied by Donno on topic Modbus drivers for NF 9000 VFD
Thanks for the reply.
Still have a few questions i creates an ini file called NF9000.ini
[MB2HAL_INIT]
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=9
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VAR1
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=1024
NELEMENTS=24
HAL_TX_NAME=VAR2
MAX_UPDATE_RATE=0.0
DEBUG=1
.......
Then in custom.hal i load the mb2hal using
loadusr -W mb2hal config=NF9000.ini
First question : How do i read from the file ?
net spindle-cmd-rpm-abs => vfd.speed-command
net spindle-cmd-rpm-abs => mb2hal.VAR1
Still have a few questions i creates an ini file called NF9000.ini
[MB2HAL_INIT]
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=9
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VAR1
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=1024
NELEMENTS=24
HAL_TX_NAME=VAR2
MAX_UPDATE_RATE=0.0
DEBUG=1
.......
Then in custom.hal i load the mb2hal using
loadusr -W mb2hal config=NF9000.ini
First question : How do i read from the file ?
net spindle-cmd-rpm-abs => vfd.speed-command
net spindle-cmd-rpm-abs => mb2hal.VAR1
Please Log in or Create an account to join the conversation.
17 Apr 2018 09:49 #109178
by Donno
Replied by Donno on topic Modbus drivers for NF 9000 VFD
Thanks for the reply.
Still have a few questions i creates an ini file called NF9000.ini
[MB2HAL_INIT]
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=9
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VAR1
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=1024
NELEMENTS=24
HAL_TX_NAME=VAR2
MAX_UPDATE_RATE=0.0
DEBUG=1
.......
Then in custom.hal i load the mb2hal using
loadusr -W mb2hal config=NF9000.ini
First question : How do i read from the file ?
net spindle-cmd-rpm-abs => vfd.speed-command
Change into this ?
net spindle-cmd-rpm-abs => vfd.VAR1
Does vfd get declared in loadusr with -n vfd like :
loadusr -W mb2hal -n vfd config=NF9000.ini
Then other question is how do write value in mb2hal :
[TRANSACTION_02]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14 <--address ?
NELEMENTS=16 <--value ?
HAL_TX_NAME=forward
MAX_UPDATE_RATE=0.0
Still have a few questions i creates an ini file called NF9000.ini
[MB2HAL_INIT]
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=9
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=0
NELEMENTS=16
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=VAR1
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=1024
NELEMENTS=24
HAL_TX_NAME=VAR2
MAX_UPDATE_RATE=0.0
DEBUG=1
.......
Then in custom.hal i load the mb2hal using
loadusr -W mb2hal config=NF9000.ini
First question : How do i read from the file ?
net spindle-cmd-rpm-abs => vfd.speed-command
Change into this ?
net spindle-cmd-rpm-abs => vfd.VAR1
Does vfd get declared in loadusr with -n vfd like :
loadusr -W mb2hal -n vfd config=NF9000.ini
Then other question is how do write value in mb2hal :
[TRANSACTION_02]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14 <--address ?
NELEMENTS=16 <--value ?
HAL_TX_NAME=forward
MAX_UPDATE_RATE=0.0
Please Log in or Create an account to join the conversation.
17 Apr 2018 13:53 #109185
by Donno
Replied by Donno on topic Modbus drivers for NF 9000 VFD
After a few hours i managed to get into LinuxCNC
NF9000.ini
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=4
[TRANSACTION_00]
#REQUIRED: You must specify either a "serial" or "tcp" link for the first transaction.
#Later transaction will use the previous transaction link if not specified.
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=58
NELEMENTS=1
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=OutputSpeed
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=1
HAL_TX_NAME=Forward
MAX_UPDATE_RATE=0.0
[TRANSACTION_02]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=1
HAL_TX_NAME=Reverse
MAX_UPDATE_RATE=0.0
[TRANSACTION_03]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=0
NELEMENTS=1
HAL_TX_NAME=SetSpeed
MAX_UPDATE_RATE=0.0
custom.hal
loadusr -W mb2hal config=NF9000.ini
net spindle−speed−out−rps−abs => mb2hal.SetSpeed.00
net spindle-cw motion.spindle-forward => mb2hal.Forward.00
net spindle-ccw motion.spindle-reverse => mb2hal.Reverse.00
Still can't figure out how to write values to mod-bus address. The Address for forward,reverse and stop is using the same address so i can make one transaction for it ! Address 14 : Forward is value 10 , reverse is value 14 and stop is value 0 but it would not allow me to link the same variable to different signals
NF9000.ini
INIT_DEBUG=3
HAL_MODULE_NAME=mb2hal
SLOWDOWN=0.0
TOTAL_TRANSACTIONS=4
[TRANSACTION_00]
#REQUIRED: You must specify either a "serial" or "tcp" link for the first transaction.
#Later transaction will use the previous transaction link if not specified.
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyS0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=2
SERIAL_DELAY_MS=3
MB_SLAVE_ID=1
FIRST_ELEMENT=58
NELEMENTS=1
MB_TX_CODE=fnct_03_read_holding_registers
MB_RESPONSE_TIMEOUT_MS=500
MB_BYTE_TIMEOUT_MS=500
HAL_TX_NAME=OutputSpeed
MAX_UPDATE_RATE=0.0
DEBUG=1
[TRANSACTION_01]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=1
HAL_TX_NAME=Forward
MAX_UPDATE_RATE=0.0
[TRANSACTION_02]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=1
HAL_TX_NAME=Reverse
MAX_UPDATE_RATE=0.0
[TRANSACTION_03]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=0
NELEMENTS=1
HAL_TX_NAME=SetSpeed
MAX_UPDATE_RATE=0.0
custom.hal
loadusr -W mb2hal config=NF9000.ini
net spindle−speed−out−rps−abs => mb2hal.SetSpeed.00
net spindle-cw motion.spindle-forward => mb2hal.Forward.00
net spindle-ccw motion.spindle-reverse => mb2hal.Reverse.00
Still can't figure out how to write values to mod-bus address. The Address for forward,reverse and stop is using the same address so i can make one transaction for it ! Address 14 : Forward is value 10 , reverse is value 14 and stop is value 0 but it would not allow me to link the same variable to different signals
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
17 Apr 2018 14:05 - 17 Apr 2018 14:11 #109186
by Todd Zuercher
Replied by Todd Zuercher on topic Modbus drivers for NF 9000 VFD
You probably will want to just start Linuxcnc to double check the pin names of the Mb2hal component you've set up, before you try using them to connect things in your hal files.
But here is what I think you are going to get from the ini file you've posted.
From Transaction_00 you will get 16 float output pins namedand from Transaction_01 you will get 24 Boolean output bit pins namedand from Transaction_02 you will get 16 Boolean input bit pins named
You will not be able to connect a spindle speed (a float) to any of those pins (bits). To get a float input you need to use a different MB_TX_CODE.
On my machine I used MB_TX_CODE=fnct_16_write_multiple_registers. to send the spindle speed.
FIRST_ELEMENT=14 <--address ?yes this is where you put the register number you want to write to
NELEMENTS=16 <--value ?Putting 16 here will create 16 hal pins that will comunicate with the 16 registers from #14 on.
What you probably want for transaction 2 is:
and in your hal fileThat would send your absolute spindle RPM speed command to register #14.
But here is what I think you are going to get from the ini file you've posted.
From Transaction_00 you will get 16 float output pins named
mb2hal.VAR1.00
mb2hal.VAR1.01
mb2hal.VAR1.02
mb2hal.VAR1.03
mb2hal.VAR1.04
mb2hal.VAR1.05
mb2hal.VAR1.06
mb2hal.VAR1.07
mb2hal.VAR1.08
mb2hal.VAR1.09
mb2hal.VAR1.10
mb2hal.VAR1.11
mb2hal.VAR1.12
mb2hal.VAR1.13
mb2hal.VAR1.14
mb2hal.VAR1.15
mb2hal.VAR1.00
mb2hal.VAR2.01
mb2hal.VAR2.02
mb2hal.VAR2.03
mb2hal.VAR2.04
mb2hal.VAR2.05
mb2hal.VAR2.06
mb2hal.VAR2.07
mb2hal.VAR2.08
mb2hal.VAR2.09
mb2hal.VAR2.10
mb2hal.VAR2.11
mb2hal.VAR2.12
mb2hal.VAR2.13
mb2hal.VAR2.14
mb2hal.VAR2.15
mb2hal.VAR2.16
mb2hal.VAR2.17
mb2hal.VAR2.18
mb2hal.VAR2.19
mb2hal.VAR2.20
mb2hal.VAR2.21
mb2hal.VAR2.22
mb2hal.VAR2.23
mb2hal.orward.00
mb2hal.forward.01
mb2hal.forward.02
mb2hal.forward.03
mb2hal.forward.04
mb2hal.forward.05
mb2hal.forward.06
mb2hal.forward.07
mb2hal.forward.08
mb2hal.forward.09
mb2hal.forward.10
mb2hal.forward.11
mb2hal.forward.12
mb2hal.forward.13
mb2hal.forward.14
mb2hal.forward.15
You will not be able to connect a spindle speed (a float) to any of those pins (bits). To get a float input you need to use a different MB_TX_CODE.
On my machine I used MB_TX_CODE=fnct_16_write_multiple_registers. to send the spindle speed.
FIRST_ELEMENT=14 <--address ?yes this is where you put the register number you want to write to
NELEMENTS=16 <--value ?Putting 16 here will create 16 hal pins that will comunicate with the 16 registers from #14 on.
What you probably want for transaction 2 is:
[TRANSACTION_02]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=14
NELEMENTS=1
HAL_TX_NAME=forward
MAX_UPDATE_RATE=0.0
and in your hal file
net spindle-cmd-rpm-abs => mb2hal.forward.00
Last edit: 17 Apr 2018 14:11 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
17 Apr 2018 14:51 #109191
by Todd Zuercher
Ok, so you need to look at register #14 as a binary number, and twiddle the individual bits as separate hal pins.
I am guessing that the values of 14, 10 and 0 are supposed to be either hexadecimal or octal (the binary works out better that way.)
And for that you will want to use:
MB_TX_CODE=fnct_15_write_multiple_coils
Do you have a list of what each bit in register #14 represents?
So for stop start forward reverse you would only use one transaction.
[TRANSACTION_01]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=4 (or 8 or 16 depending on your register size)
HAL_TX_NAME=runcontrol
MAX_UPDATE_RATE=0.0
And your hal pins would be something like
net run => mb2hal.runcontrol.03
net reverse => mb2hal.runcontrol.02
#To run the spindle in reverse both pins mb2hal.runcontrol.03 and mb2hal.runcontrol.02 must be true
Replied by Todd Zuercher on topic Modbus drivers for NF 9000 VFD
Still can't figure out how to write values to mod-bus address. The Address for forward,reverse and stop is using the same address so i can make one transaction for it ! Address 14 : Forward is value 10 , reverse is value 14 and stop is value 0 but it would not allow me to link the same variable to different signals
Ok, so you need to look at register #14 as a binary number, and twiddle the individual bits as separate hal pins.
I am guessing that the values of 14, 10 and 0 are supposed to be either hexadecimal or octal (the binary works out better that way.)
And for that you will want to use:
MB_TX_CODE=fnct_15_write_multiple_coils
Do you have a list of what each bit in register #14 represents?
So for stop start forward reverse you would only use one transaction.
[TRANSACTION_01]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=14
NELEMENTS=4 (or 8 or 16 depending on your register size)
HAL_TX_NAME=runcontrol
MAX_UPDATE_RATE=0.0
And your hal pins would be something like
net run => mb2hal.runcontrol.03
net reverse => mb2hal.runcontrol.02
#To run the spindle in reverse both pins mb2hal.runcontrol.03 and mb2hal.runcontrol.02 must be true
Please Log in or Create an account to join the conversation.
Moderators: cncbasher
Time to create page: 0.211 seconds