Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parker AC10 VFD mb2hal-configuration #491

Closed
chaotix- opened this issue Aug 23, 2018 · 5 comments
Closed

Parker AC10 VFD mb2hal-configuration #491

chaotix- opened this issue Aug 23, 2018 · 5 comments

Comments

@chaotix-
Copy link
Contributor

I connected my Parker AC10 VFD to LinuxCNC via mb2hal recently.

Is there interest in documenting what was necessary to get all the pieces working together? It would consist of the necessary settings for the VFD, mb2hal.ini, HAL configuration and a PYVCP-XML-file (to show current speed and at-speed-indicator LED).

Should I create a pull request and if so where should it go? At src/hal/user_comps/mb2hal/examples or docs/src/???

Or should I just put it in the issue here and someone will included it?

@superfunk58
Copy link

YES, there is GREAT interest in getting a little walkthrough - i am currently trying to control a parker ac10 with linuxcnc via modbus as well...

@chaotix-
Copy link
Contributor Author

chaotix- commented Sep 3, 2018

Here is just a quick summary:

  1. You need LinuxCNC > 2.7.14 (e.g. the next release), the master branch or need to compile mb2hal yourself with the PR mb2hal: add fnct_06_write_single_register #487 and mb2hal: call modbus_flush() on transaction error #489 .

  2. Configure the AC10 so your spindle is working. Then set F203 to 10. Then you can control it via ModBus. Use register 0x2000 to start/stop and set direction, register 0x010d (F113) to set the speed and register 0x1000+ to read the current status (see manual for more information).

You can use the attached configuration files to get you started. They are more compex than is necessary as I tried to display the current and mean power of the spindle. But I don't think the values retrieved from the VFD are correct and are much too high. So you can strip out the power calculation which should shrink the HAL configuration in half.

Please be aware that the minimum and maximum frequencies for the spindle need to be set in the AC10 configuration registers (F111 and F112) and the custom.hal file. And of course I don't give any guarantees that this won't burn down you house or cause an earthquake. All I can say is that it works fine for me.

Github does not allow me to attach the .ini and .hal files so you need to copy & paste them.

I hope, it helps.

mb2hal.ini

[MB2HAL_INIT]

#OPTIONAL: Debug level of init and INI file parsing.
# 0 = silent.
# 1 = error messages (default).
# 2 = OK confirmation messages.
# 3 = debugging messages.

INIT_DEBUG=3

#OPTIONAL: HAL module (component) name. Defaults to "mb2hal".

HAL_MODULE_NAME=spindle-vfd

#OPTIONAL: Insert a delay of "FLOAT seconds" between transactions in order
#to not to have a lot of logging and facilitate the debugging.
#Useful when using DEBUG=3 (NOT INIT_DEBUG=3)
#It affects ALL transactions.
#Use "0.0" for normal activity.

SLOWDOWN=0.0

#REQUIRED: The number of total Modbus transactions. There is no maximum.

TOTAL_TRANSACTIONS=4

#One transaction section is required per transaction, starting at 00 and counting up sequentially.
#If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time.
#Warning: Any OPTIONAL parameter not specified are copied from the previous transaction.

[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=9600

#Data bits. One of 5,6,7,8.
SERIAL_BITS=8

#Data parity. One of: even, odd, none.
SERIAL_PARITY=none

#Stop bits. One of 1, 2.
SERIAL_STOP=2

#Serial port delay between for this transaction only.
#In ms. Defaults to 0.
SERIAL_DELAY_MS=150

MB_SLAVE_ID=1

FIRST_ELEMENT=4096
NELEMENTS=8

#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_06_write_single_register    (06 = 0x06)
#    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))

MB_TX_CODE=fnct_03_read_holding_registers

#OPTIONAL: Response timeout for this transaction. In INTEGER ms. Defaults to 500 ms.
#This is how much to wait for 1st byte before raise an error.

MB_RESPONSE_TIMEOUT_MS=500

#OPTIONAL: Byte timeout for this transaction. In INTEGER ms. Defaults to 500 ms.
#This is how much to wait from byte to byte before raise an error.

MB_BYTE_TIMEOUT_MS=500

#OPTIONAL: Instead of giving the transaction number, use a name.
#Example: mb2hal.00.01 could become mb2hal.plcin.01
#The name must not exceed 32 characters.
#NOTE: when using names be careful that you dont end up with two transactions
#usign the same name.

HAL_TX_NAME=info

#OPTIONAL: Maximum update rate in HZ. Defaults to 0.0 (0.0 = as soon as available = infinit).
#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

MAX_UPDATE_RATE=2.0

#OPTIONAL: Debug level for this transaction only.
#See INIT_DEBUG parameter above.

DEBUG=1

#While DEBUGGING transactions note the returned "ret[]" value correspond to:
#/* Modbus protocol exceptions */
#ILLEGAL_FUNCTION        -0x01 the FUNCTION code received in the query is not allowed or invalid.
#ILLEGAL_DATA_ADDRESS    -0x02 the DATA ADDRESS received in the query is not an allowable address for the slave or is invalid.
#ILLEGAL_DATA_VALUE      -0x03 a VALUE contained in the data query field is not an allowable value or is invalid.
#SLAVE_DEVICE_FAILURE    -0x04 SLAVE (or MASTER) device unrecoverable FAILUER while attemping to perform the requested action.
#SERVER_FAILURE          -0x04 (see above).
#ACKNOWLEDGE             -0x05 This response is returned to PREVENT A TIMEOUT in the master.
#                              A long duration of time is required to process the request in the slave.
#SLAVE_DEVICE_BUSY       -0x06 The slave (or server) is BUSY. Retrasmit the request later.
#SERVER_BUSY             -0x06 (see above).
#NEGATIVE_ACKNOWLEDGE    -0x07 Unsuccessful programming request using function code 13 or 14.
#MEMORY_PARITY_ERROR     -0x08 SLAVE parity error in MEMORY.
#GATEWAY_PROBLEM_PATH    -0x0A (-10) Gateway path(s) not available.
#GATEWAY_PROBLEM_TARGET  -0x0B (-11) The target device failed to repond (generated by master, not slave).
#/* Program or connection */
#COMM_TIME_OUT           -0x0C (-12)
#PORT_SOCKET_FAILURE     -0x0D (-13)
#SELECT_FAILURE          -0x0E (-14)
#TOO_MANY_DATAS          -0x0F (-15)
#INVALID_CRC             -0x10 (-16)
#INVALID_EXCEPTION_CODE  -0x11 (-17)

[TRANSACTION_01]
MB_TX_CODE=fnct_03_read_holding_registers
FIRST_ELEMENT=4119
HAL_TX_NAME=info2
PIN_NAMES=rpm

[TRANSACTION_02]
MB_TX_CODE=fnct_06_write_single_register
FIRST_ELEMENT=8192
HAL_TX_NAME=runmode
PIN_NAMES=command

[TRANSACTION_03]
MB_TX_CODE=fnct_06_write_single_register
FIRST_ELEMENT=269
HAL_TX_NAME=frequency
PIN_NAMES=hz

custom.hal

# Include your customized HAL commands here
# This file will not be overwritten when you run stepconf again

loadusr -Wn spindle-vfd mb2hal config=mb2hal.ini

loadrt mux4 names=mux4.runmode
loadrt mult2 names=mult2.freq,mult2.power-in,mult2.power-out,mult2.power-mean
loadrt limit1 names=limit1.freq
loadrt comp names=comp.status-ok
loadrt and2 names=and2.estop-in
loadrt estop_latch
loadrt near names=near.speed
loadrt sum2 names=sum2.count,sum2.power
loadrt conv_bit_u32 names=cbu.running
loadrt conv_u32_float names=cuf.running
loadrt invert names=invert.count

addf mux4.runmode servo-thread
addf mult2.freq servo-thread
addf mult2.power-in servo-thread
addf mult2.power-out servo-thread
addf mult2.power-mean servo-thread
addf limit1.freq servo-thread
addf comp.status-ok servo-thread
addf and2.estop-in servo-thread
addf estop-latch.0 servo-thread
addf near.speed servo-thread
addf sum2.count servo-thread
addf sum2.power servo-thread
addf cbu.running servo-thread
addf cuf.running servo-thread
addf invert.count servo-thread

# Choose command: Forward/Reverse/Stop
setp mux4.runmode.in0 3         # Dec. stop
setp mux4.runmode.in1 2         # Reverse
setp mux4.runmode.in2 3         # Dec. stop
setp mux4.runmode.in3 1         # Forward
net spindle-on motion.spindle-on => mux4.runmode.sel0
net spindle-fwd motion.spindle-forward => mux4.runmode.sel1
net spindle-runmode mux4.runmode.out => spindle-vfd.runmode.command

# Calculate frequency from desired speed
net spindle-speed motion.spindle-speed-out-abs => mult2.freq.in0
setp mult2.freq.in1 1.666667    # 100 / 120 * motor poles
net spindle-speed-raw mult2.freq.out => limit1.freq.in

# Limit speed output
setp limit1.freq.min 10000      # Min. Frequency * 100
setp limit1.freq.max 40000      # Max. Frequency * 100
net spindle-speed-cmd limit1.freq.out => spindle-vfd.frequency.hz

# Check spindle status for faults
net spindle-status-raw spindle-vfd.info.05.float => comp.status-ok.in0
setp comp.status-ok.in1 25603   # 0x6403 MSB: Drive Ratio (1 * 100), LSB: Status. < 3 = OK

# Trigger estop when vfd reports a fault or estop is pressed in GUI
net estop-ioc-in iocontrol.0.user-enable-out => and2.estop-in.in0
net estop-vfd-in comp.status-ok.out => and2.estop-in.in1

net spindle-status-ok and2.estop-in.out => estop-latch.0.ok-in
net estop-out estop-latch.0.ok-out => iocontrol.0.emc-enable-in
net estop-reset iocontrol.0.user-request-enable => estop-latch.0.reset

# Set motion.spindle-at-speed
net spindle-speed near.speed.in1
net spindle-speed-in spindle-vfd.info2.rpm.float => near.speed.in2
setp near.speed.scale 1.05
net spindle-at-speed near.speed.out => motion.spindle-at-speed

# temperature in °C
net vfd-temp spindle-vfd.info.07.int

# voltage * current * 0.01 = power in W
net spindle-vfd-voltage spindle-vfd.info.01.float => mult2.power-in.in0
net spindle-vfd-current spindle-vfd.info.02.float => mult2.power-in.in1
net spindle-vfd-power mult2.power-in.out => mult2.power-out.in0
setp mult2.power-out.in1 0.01
net vfd-power mult2.power-out.out

# Increment counter when spindle is running
setp sum2.count.in1 0
net spindle-on cbu.running.in
net vfd-power-run-u cbu.running.out => cuf.running.in
net vfd-power-run cuf.running.out => sum2.count.in0
net vfd-power-count sum2.count.out => sum2.count.in1

# Add Power measurements
setp sum2.power.in1 0
net vfd-power sum2.power.in0
net vfd-power-sum sum2.power.out => sum2.power.in1

# Mean power = power-sum / power-count
net vfd-power-count invert.count.in
net count-inverted invert.count.out => mult2.power-mean.in0
net vfd-power-sum mult2.power-mean.in1
net vfd-power-mean mult2.power-mean.out

custompanel.xml

<?xml version='1.0' encoding='UTF-8'?>
<pyvcp>
        <labelframe text="Parker AC10 VFD">
                <font>("Helvetica",12)</font>
                <table>
                        <tablerow/>
                                <tablespan columns="2" />
                                <tablesticky sticky="nsew" />
                                <label>
                                        <text>" "</text>
                                        <font>("Helvetica",2)</font>
                                </label>
                        <tablerow/>
                                <tablesticky sticky="w" />
                                <label>
                                        <text>"Power (current):"</text>
                                </label>
                                <tablesticky sticky="e" />
                                <number>
                                        <halpin>"vfd-power-cur"</halpin>
                                        <format>".0f W"</format>
                                </number>
                        <tablerow/>
                                <tablesticky sticky="w" />
                                <label>
                                        <text>"Power (mean):"</text>
                                </label>
                                <tablesticky sticky="e" />
                                <number>
                                        <halpin>"vfd-power-mean"</halpin>
                                        <format>".0f W"</format>
                                </number>
                        <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-in"</halpin>
                                <max_>24000</max_>
                        </bar>
                </table>
        </labelframe>
</pyvcp>

custom_postgui.hal

# Include your customized HAL commands here
# The commands in this file are run after the AXIS GUI (including PyVCP panel) starts

net vfd-power-mean pyvcp.vfd-power-mean
net vfd-power pyvcp.vfd-power-cur
net spindle-at-speed pyvcp.spindle-at-speed
net spindle-speed-in pyvcp.spindle-speed-in

@superfunk58
Copy link

superfunk58 commented Sep 4, 2018 via email

@andypugh
Copy link
Collaborator

Maybe this belongs on the Wiki? Leaving it here as an open issue looks bad...

@chaotix-
Copy link
Contributor Author

I have added a wiki page at http://wiki.linuxcnc.org/cgi-bin/wiki.pl?VFD_Parker_AC10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants