Hi all!

I've just crafted a simple config in the simulator for this application.
You can find the INI and HAL files in the attachment. The Z position
(our needle) is driven by a siggen component to follow a sine wave. This
may or may not be appropriate, but it's easy enough to test. Some logic
in HAL ensures that the siggen always runs until the needle reaches the
uppermost level no matter when it is commanded to stop. A comparator
drives motion.feed-hold to let the machine move only when the needle has
at least level 1mm. andy's suggestions would be better of course, but as
you can see in the attached screenshot, it already does what it should.
What would be needed anyways is a machine with quite reasonable
acceleration limits if it should go fast.

Oh yes, the screenshot shows the machine executing the following MDI
comamnds:

S100 M3
G1 F1000 X100

Cheers,
Philipp

On 27.08.2014 21:00, andy pugh wrote:
> On 27 August 2014 16:21, alex chiosso <achio...@gmail.com> wrote:
>> I would like to discuss with you what do you think about the conversion to
>> LCNC.
> 
> One very easy way (maybe too easy) would be to pass needle height
> through a lincurve component (I use that for nearly everything,
> because we use them for nearly everything in the day job) and then use
> the output to drive the motion.adaptive-feed pin. You can then define
> zones where movement is possible and have a gentle decel up to those
> zones defined in the curve shape.
> 
# EMC controller parameters for a simulated machine.

# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.

# General section -------------------------------------------------------------
[EMC]

# Version of this INI file
VERSION =               $Revision$

# Name of machine, for use with display, etc.
MACHINE =               LinuxCNC-HAL-SIM-AXIS

# Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
# DEBUG =               0x7FFFFFFF
DEBUG = 0

# Sections for display options ------------------------------------------------
[DISPLAY]

# Name of display program, e.g., xemc
DISPLAY =             axis

# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME =            0.100

# 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 =     1.2
MAX_SPINDLE_OVERRIDE =  1.0
# Prefix to be used
PROGRAM_PREFIX = ../../nc_files/

# Introductory graphic
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5

EDITOR = gedit

INCREMENTS = 1 mm, .01 in, .1mm, 1 mil, .1 mil, 1/8000 in
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script

png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python

# 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.001

# Part program interpreter section --------------------------------------------
[RS274NGC]

# File containing interpreter variables
PARAMETER_FILE = sim_mm.var

# Motion control section ------------------------------------------------------
[EMCMOT]

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_PERIOD is unused in this configuration but specified in core_sim.hal
BASE_PERIOD  =               0
# Servo task period, in nano-seconds
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 = core_sim.hal
#HALFILE = sim_spindle_encoder.hal
#HALFILE = axis_manualtoolchange.hal
#HALFILE = simulated_home.hal

# list of halcmd commands to execute
# commands are executed in the order in which they appear
#HALCMD =                    save neta

# Single file that is executed after the GUI has started.  Only supported by
# AXIS at this time (only AXIS creates a HAL component of its own)
#POSTGUI_HALFILE = test_postgui.hal

#HALUI = halui

# Trajectory planner section --------------------------------------------------
[TRAJ]

AXES =                  3
COORDINATES =           X Y Z
HOME =                  0 0 0
LINEAR_UNITS =          mm
ANGULAR_UNITS =         degree
CYCLE_TIME =            0.010
DEFAULT_VELOCITY =      30.48
MAX_VELOCITY =          53.34
DEFAULT_ACCELERATION =  508
MAX_ACCELERATION =      508
POSITION_FILE = position_mm.txt
ARC_BLEND_ENABLE =      1
ARC_BLEND_FALLBACK_ENABLE = 1
ARC_BLEND_OPTIMIZATION_DEPTH = 50
#Use this setting for no smoothing (for debugging and stress-testing)
ARC_BLEND_SMOOTHING_THRESHOLD = .75
#Use this setting for "normal" smoothing, i.e. if we blend over more than 40% 
of a segment
#ARC_BLEND_SMOOTHING_THRESHOLD = 0.40

# Axes sections ---------------------------------------------------------------

# First axis
[AXIS_0]

TYPE =                          LINEAR
HOME =                          0.000
MAX_VELOCITY =                  30.48
MAX_ACCELERATION =              508
BACKLASH = 0.000
INPUT_SCALE =                   157.48
OUTPUT_SCALE = 1.000
MIN_LIMIT =                     -254
MAX_LIMIT =                     254
FERROR = 1.27
MIN_FERROR = .254
HOME_OFFSET =                    0.0
HOME_SEARCH_VEL =                0
HOME_LATCH_VEL =                 0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO
HOME_SEQUENCE = 0
HOME_IS_SHARED = 1

# Second axis
[AXIS_1]

TYPE =                          LINEAR
HOME =                          0.000
MAX_VELOCITY =                  30.48
MAX_ACCELERATION =              508
BACKLASH = 0.000
INPUT_SCALE =                   157.48
OUTPUT_SCALE = 1.000
MIN_LIMIT =                     -254
MAX_LIMIT =                     254
FERROR = 1.27
MIN_FERROR = .254
HOME_OFFSET =                    0.0
HOME_SEARCH_VEL =                0
HOME_LATCH_VEL =                 0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO
HOME_SEQUENCE = 0

# Third axis
[AXIS_2]

TYPE =                          LINEAR
HOME =                          0.0
MAX_VELOCITY =                  1000
MAX_ACCELERATION =              1000
BACKLASH = 0.000
INPUT_SCALE =                   1.0
OUTPUT_SCALE = 1.000
MIN_LIMIT =                     -100
MAX_LIMIT =                     100
FERROR = 50
MIN_FERROR = 50
HOME_OFFSET =                    0
HOME_SEARCH_VEL =                0
HOME_LATCH_VEL =                 0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO
HOME_SEQUENCE = 0
HOME_IS_SHARED = 1

# 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 = sim_mm.tbl
TOOL_CHANGE_POSITION = 0 0 50.8
# core HAL config file for simulation

# first load all the RT modules that will be needed
# kinematics
loadrt trivkins
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD 
servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
# load additional blocks
loadrt hypot names=vel_xy,vel_xyz

# Signal generator for the needle position.
loadrt siggen names=needle_z_gen

# Needle position comparators.
loadrt comp names=needle_safe_comp,needle_stop_comp

# Needle signal generator frequency multiplexer. This also serves as a
# storage to keep the previous frequency while the needle is below the
# stop height.
loadrt mux2 names=needle_freq_mux

# Edge detector to find out when the spindle should be started.
loadrt edge names=spindle_on_edge

# AND gate to force the spindle speed into the siggen when the spindle
# is turned on.
loadrt and2 names=spindle_force_and

addf spindle_on_edge servo-thread
addf spindle_force_and servo-thread
addf needle_freq_mux servo-thread
addf needle_z_gen.update servo-thread
addf needle_safe_comp servo-thread
addf needle_stop_comp servo-thread

# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread

# Generate the needle Z position using the signal generator. Its frequency
# is commanded by the spindle speed, but it is also kept running while
# not in the uppermost position to ensure that the needle never stays down
# in the fabric, no matter when an M5 is programmed.
setp needle_z_gen.amplitude 10
setp needle_safe_comp.in1 1.0   # Safe height for the needle.
setp needle_stop_comp.in1 9.0   # Stopping height for the needle.
setp spindle_on_edge.out-width-ns 100000000
setp spindle_on_edge.in-edge FALSE
net needle-speed-keep needle_freq_mux.out => needle_freq_mux.in1
net needle-speed-cmd motion.spindle-speed-out-rps => needle_freq_mux.in0
net needle-speed-keep needle_z_gen.frequency
net Zpos needle_z_gen.sine => axis.2.motor-pos-fb
net Zpos needle_safe_comp.in0
net Zpos needle_stop_comp.in0
net stop-feed needle_safe_comp.out => motion.feed-hold  # NEEDS M53 P1!
net keep-needle-on needle_stop_comp.out => spindle_force_and.in0
net needle-speed-trig spindle_on_edge.out-invert => spindle_force_and.in1
net needle-speed-sel spindle_force_and.out => needle_freq_mux.sel
net spindle-on motion.spindle-on => spindle_on_edge.in

# Our spindle is always at speed.
setp motion.spindle-at-speed 1

# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos axis.0.motor-pos-cmd => axis.0.motor-pos-fb
net Ypos axis.1.motor-pos-cmd => axis.1.motor-pos-fb


# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in

# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to