2 servos 1 stepper
04 Jul 2012 07:23 #21546
by arthur
2 servos 1 stepper was created by arthur
Ok, Im building a "Frankenstein" CNC mill from an MFP and printer. So its 2 servos and one stepper. X and Z are servo, and Y is stepper.
I have gotten the servos mostly working in "Etch-Servo". X needs some tuning, giving follow error, Z is good.
Stepper also works in Stepconf.
Now I have two saved "machines" that need to be combined. What would be the best way to do this?
Thanks
I have gotten the servos mostly working in "Etch-Servo". X needs some tuning, giving follow error, Z is good.
Stepper also works in Stepconf.
Now I have two saved "machines" that need to be combined. What would be the best way to do this?
Thanks
Please Log in or Create an account to join the conversation.
04 Jul 2012 07:28 #21547
by cncbasher
Replied by cncbasher on topic 2 servos 1 stepper
you dont state how your hardware is connected ... parrell port or mesa io card etc ...
it''s realy just a matter of combining the 2 hal files , follow error is probably just a tuning matter or increase follow error value in INI file
post your hal files would be a good starting point
it''s realy just a matter of combining the 2 hal files , follow error is probably just a tuning matter or increase follow error value in INI file
post your hal files would be a good starting point
Please Log in or Create an account to join the conversation.
04 Jul 2012 12:33 #21557
by andypugh
Replied by andypugh on topic 2 servos 1 stepper
arthur wrote:
You can very nearly just transfer the HAL file from one configuration into the config directory of the other, and then add the filename of the second HAL file to the INI.
It isn't quite that simple as you will need to remove duplicated lines from the second HAL file, but that is nearly all that there is to it.
Now I have two saved "machines" that need to be combined. What would be the best way to do this?
You can very nearly just transfer the HAL file from one configuration into the config directory of the other, and then add the filename of the second HAL file to the INI.
It isn't quite that simple as you will need to remove duplicated lines from the second HAL file, but that is nearly all that there is to it.
Please Log in or Create an account to join the conversation.
04 Jul 2012 16:56 #21563
by arthur
Replied by arthur on topic 2 servos 1 stepper
Sorry, I posted at 3am. But They all go through the parallel port. The two servos to a dual h bridge, and the stepper to its own dual h bridge and simple driver circuit.
I'll post the hal and ini files in a few.
I'll post the hal and ini files in a few.
Please Log in or Create an account to join the conversation.
04 Jul 2012 17:31 - 04 Jul 2012 17:33 #21565
by arthur
Replied by arthur on topic 2 servos 1 stepper
Servo .hal
servo .ini
stepper .hal
stepper .ini
# load realtime modules
# kinematics
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hal_parport cfg="1030"
loadrt encoder num_chan=2
loadrt pid num_chan=2
loadrt pwmgen output_type=1,1
loadrt ddt count=4
loadrt constant count=1
# define the order of execution for RT code
addf parport.0.read base-thread
addf encoder.update-counters base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf encoder.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.0.do-pid-calcs servo-thread
addf pid.1.do-pid-calcs servo-thread
addf constant.0 servo-thread
addf pwmgen.update servo-thread
addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf ddt.3 servo-thread
# hook stuff together
setp encoder.0.position-scale [AXIS_0]INPUT_SCALE
setp encoder.1.position-scale [AXIS_1]INPUT_SCALE
net enc0A encoder.0.phase-A <= parport.0.pin-10-in
net enc0B encoder.0.phase-B <= parport.0.pin-11-in
net enc1A encoder.1.phase-A <= parport.0.pin-12-in
net enc1B encoder.1.phase-B <= parport.0.pin-13-in
net Xpos-fb <= encoder.0.position
net Ypos-fb <= encoder.1.position
net Xpos-fb => pid.0.feedback
net Ypos-fb => pid.1.feedback
net Xpos-fb => axis.0.motor-pos-fb
net Ypos-fb => axis.1.motor-pos-fb
net Xvel-cmd <= pid.0.output
net Yvel-cmd <= pid.1.output
net Xvel-cmd => pwmgen.0.value
net Yvel-cmd => pwmgen.1.value
net Xpwm pwmgen.0.pwm
net Ypwm pwmgen.1.pwm
net Xdir <= pwmgen.0.dir
net Ydir <= pwmgen.1.dir
net Xdir => parport.0.pin-06-out
net Xdir => parport.0.pin-07-out
setp parport.0.pin-07-out-invert TRUE
net Xpwm => parport.0.pin-05-out
net Ydir => parport.0.pin-03-out
net Ydir => parport.0.pin-04-out
setp parport.0.pin-04-out-invert TRUE
net Ypwm => parport.0.pin-02-out
setp pid.0.maxoutput 1.0
setp pid.1.maxoutput 1.0
# the values below come from the ini
setp pid.0.Pgain [AXIS_0]P
setp pid.0.Igain [AXIS_0]I
setp pid.0.Dgain [AXIS_0]D
setp pid.0.bias [AXIS_0]BIAS
setp pid.0.FF0 [AXIS_0]FF0
setp pid.0.FF1 [AXIS_0]FF1
setp pid.0.FF2 [AXIS_0]FF2
# deadband should be just over 1 count
setp pid.0.deadband [AXIS_0]DEADBAND
setp pid.1.Pgain [AXIS_1]P
setp pid.1.Igain [AXIS_1]I
setp pid.1.Dgain [AXIS_1]D
setp pid.1.bias [AXIS_1]BIAS
setp pid.1.FF0 [AXIS_1]FF0
setp pid.1.FF1 [AXIS_1]FF1
setp pid.1.FF2 [AXIS_1]FF2
# deadband should be just over 1 count
setp pid.1.deadband [AXIS_1]DEADBAND
net Xpos-cmd <= axis.0.motor-pos-cmd
net Ypos-cmd <= axis.1.motor-pos-cmd
net Xpos-cmd => pid.0.command
net Ypos-cmd => pid.1.command
net Xenable <= axis.0.amp-enable-out
net Yenable <= axis.1.amp-enable-out
net Xenable => pid.0.enable
net Xenable => pwmgen.0.enable
net Yenable => pid.1.enable
net Yenable => pwmgen.1.enable
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
net Xpos-cmd => ddt.0.in
net Xvel <= ddt.0.out
net Xvel => ddt.1.in
net Xacc <= ddt.1.out
net Ypos-cmd => ddt.2.in
net Yvel <= ddt.2.out
net Yvel => ddt.3.in
net Yacc <= ddt.3.out
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
servo .ini
# EMC controller parameters for generic controller. Make these what you need
# for your system.
# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.
# Settings with a + at the front of the comment are likely needed to get
# changed by the user.
# Settings with a - at the front are highly unneeded to be changed
###############################################################################
# General section
###############################################################################
[EMC]
#- Version of this INI file
VERSION = $Revision$
#+ Name of machine, for use with display, etc.
MACHINE = LinuxCNC-ETCH-SERVO
#+ Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
DEBUG = 0
# DEBUG = 0x00000007
# DEBUG = 0x7FFFFFFF
###############################################################################
# Sections for display options
###############################################################################
[DISPLAY]
#+ Name of display program, e.g., xemc
DISPLAY = axis
# DISPLAY = usrmot
# DISPLAY = mini
# DISPLAY = tkemc
# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME = 0.200
#- Path to help file
HELP_FILE = doc/help.txt
#- Initial display setting for position, RELATIVE or MACHINE
POSITION_OFFSET = RELATIVE
#- Initial display setting for position, COMMANDED or ACTUAL
POSITION_FEEDBACK = ACTUAL
#+ Highest value that will be allowed for feed override, 1.0 = 100%
MAX_FEED_OVERRIDE = 10
#- Prefix to be used
PROGRAM_PREFIX = /home/arthur/linuxcnc/nc_files
#- Introductory graphic
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
# Editor to be used with Axis
EDITOR = gedit
###############################################################################
# Task controller section
###############################################################################
[TASK]
# Name of task controller program, e.g., milltask
TASK = milltask
#- Cycle time, in seconds, that task controller will sleep between polls
CYCLE_TIME = 0.010
###############################################################################
# Part program interpreter section
###############################################################################
[RS274NGC]
#- File containing interpreter variables
PARAMETER_FILE = etch.var
###############################################################################
# Motion control section
###############################################################################
[EMCMOT]
#- Name of the motion controller to use (only one exists for nontrivkins)
EMCMOT = motmod
#- Timeout for comm to emcmot, in seconds
COMM_TIMEOUT = 1.0
#- Interval between tries to emcmot, in seconds
COMM_WAIT = 0.010
#+ Base task period, in nanosecs - this is the fastest thread in the machine
BASE_PERIOD = 20000
#- Servo task period, in nanosecs - will be rounded to an int multiple of BASE_PERIOD
SERVO_PERIOD = 1000000
###############################################################################
# Hardware Abstraction Layer section
###############################################################################
[HAL]
# The run script first uses halcmd to execute any HALFILE
# files, and then to execute any individual HALCMD commands.
#
# list of hal config files to run through halcmd
#+ files are executed in the order in which they appear
HALFILE = etch.hal
#- list of halcmd commands to execute
# commands are executed in the order in which they appear
#HALCMD = save neta
###############################################################################
# Trajectory planner section
###############################################################################
[TRAJ]
#+ machine specific settings
AXES = 3
# COORDINATES = X Y Z A B C
COORDINATES = X Y z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 1
MAX_VELOCITY = 30
DEFAULT_ACCELERATION = 15.0
MAX_ACCELERATION = 20.0
###############################################################################
# Axes sections
###############################################################################
#+ First axis
[AXIS_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 10
MAX_ACCELERATION = 5
BACKLASH = 0.000
INPUT_SCALE = 500
OUTPUT_SCALE = 500.000
MIN_LIMIT = 0.0
MAX_LIMIT = 6
FERROR = 0.2
MIN_FERROR = 0.10
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
P = 10
I = 100
D = 0
BIAS = 0.0
FF0 = 0
FF1 = 1000
FF2 = 0
DEADBAND=.002
#+ Second axis
[AXIS_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 10
MAX_ACCELERATION = 5
BACKLASH = 0.000
INPUT_SCALE = 500
OUTPUT_SCALE = 500.000
MIN_LIMIT = 0
MAX_LIMIT = 20
FERROR = 0.200
MIN_FERROR = 0.100
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
P = 10
I = 200
D = 0.1
BIAS = 0.0
FF0 = 4
FF1 = 1
FF2 = 0.0
DEADBAND=.002
#+ Third axis
[AXIS_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 100
MAX_ACCELERATION = 200
BACKLASH = 0.000
INPUT_SCALE = 200
OUTPUT_SCALE = 1.000
MIN_LIMIT = 0.0
MAX_LIMIT = 6.5
FERROR = 0.2
MIN_FERROR = 0.10
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
P = 150
I = 100
D = 0.1
BIAS = 0.0
FF0 = 0
FF1 = 1
FF2 = 0.0
DEADBAND=.002
###############################################################################
# section for main IO controller parameters
###############################################################################
[EMCIO]
#- Name of IO controller program, e.g., io
EMCIO = io
#- cycle time, in seconds
CYCLE_TIME = 0.100
#- tool table file
TOOL_TABLE = etch.tbl
stepper .hal
# Generated by stepconf at Wed Mar 15 02:19:04 2000
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg="1030 out "
setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
net spindle-cmd <= motion.spindle-speed-out
net ystep => parport.0.pin-08-out
setp parport.0.pin-08-out-reset 1
net ydir => parport.0.pin-09-out
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 21000
setp stepgen.0.dirsetup 21000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 21000
setp stepgen.1.dirsetup 21000
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable
setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 21000
setp stepgen.2.dirsetup 21000
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
stepper .ini
# Generated by stepconf at Wed Mar 15 02:19:04 2000
# If you make changes to this file, they will be
# overwritten when you run stepconf again
[EMC]
MACHINE = my-mill
DEBUG = 0
[DISPLAY]
DISPLAY = axis
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.2
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/arthur/linuxcnc/nc_files
INCREMENTS = .1in .05in .01in .005in .001in .0005in .0001in
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000
[HAL]
HALFILE = my-mill.hal
HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal
[TRAJ]
AXES = 3
COORDINATES = X Y Z
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 0.10
MAX_LINEAR_VELOCITY = 1.00
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[AXIS_0]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 1.0
MAX_ACCELERATION = 30.0
STEPGEN_MAXACCEL = 37.5
SCALE = 8000.0
FERROR = 0.05
MIN_FERROR = 0.01
MIN_LIMIT = -0.01
MAX_LIMIT = 8.0
HOME_OFFSET = 0.0
[AXIS_1]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 0.9
MAX_ACCELERATION = 0.9
STEPGEN_MAXACCEL = 1.125
SCALE = 1248.0
FERROR = 0.05
MIN_FERROR = 0.01
MIN_LIMIT = -0.01
MAX_LIMIT = 8.0
HOME_OFFSET = 0.0
[AXIS_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 1.0
MAX_ACCELERATION = 30.0
STEPGEN_MAXACCEL = 37.5
SCALE = 8000.0
FERROR = 0.05
MIN_FERROR = 0.01
MIN_LIMIT = -4.0
MAX_LIMIT = 0.01
HOME_OFFSET = 0.0
Last edit: 04 Jul 2012 17:33 by arthur.
Please Log in or Create an account to join the conversation.
04 Jul 2012 18:09 #21566
by arthur
Replied by arthur on topic 2 servos 1 stepper
Ok, I copied over the stepper part to the servo file's, renumbered the axis I will try it in a few and report back.
Please Log in or Create an account to join the conversation.
05 Jul 2012 02:15 - 05 Jul 2012 02:16 #21595
by arthur
Replied by arthur on topic 2 servos 1 stepper
Cool, I got it working, thanks for the tips!
Last edit: 05 Jul 2012 02:16 by arthur.
Please Log in or Create an account to join the conversation.
30 Nov 2020 06:46 #190653
by Profed81
Replied by Profed81 on topic 2 servos 1 stepper
Can you share your ini file?
Please Log in or Create an account to join the conversation.
Time to create page: 0.135 seconds