Commit 5adb0e41 authored by Michael Büsch's avatar Michael Büsch

Add linuxcnc-demo-dummyphy

LinuxCNC-demo that can run without any hardware.
Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent b291dbcb
......@@ -5,6 +5,7 @@ include README.md
graft doc
graft debian
graft linuxcnc-demo-et200s
graft linuxcnc-demo-dummyphy
graft tests
prune build
......
;
; pyprofibus - Dummy GSD file
;
#Profibus_DP
GSD_Revision=1
Slave_Family=3@Digital@24V
Vendor_Name="PYPROFIBUS"
Model_Name="PYPROFIBUS DUMMY"
OrderNumber="42-42-42"
Revision="42"
Hardware_Release="42"
Software_Release="42"
Ident_Number=0x4224
Protocol_Ident=0
Station_Type=0
Fail_Safe=1
DPV1_Slave=1
PrmText=1
Text(0)="disabled"
Text(1)="enabled"
EndPrmText
ExtUserPrmData=1 "dummy feature 1"
Bit(2) 0 0-1
Prm_Text_Ref=1
EndExtUserPrmData
ExtUserPrmData=2 "dummy feature 2"
Bit(3) 0 0-1
Prm_Text_Ref=1
EndExtUserPrmData
Auto_Baud_supp=1
9.6_supp=1
19.2_supp=1
45.45_supp=1
93.75_supp=1
187.5_supp=1
500_supp=1
1.5M_supp=1
3M_supp=1
6M_supp=1
12M_supp=1
MaxTsdr_9.6=60
MaxTsdr_19.2=60
MaxTsdr_45.45=250
MaxTsdr_93.75=60
MaxTsdr_187.5=60
MaxTsdr_500=100
MaxTsdr_1.5M=150
MaxTsdr_3M=250
MaxTsdr_6M=450
MaxTsdr_12M=800
Min_Slave_Intervall=10
Max_Diag_Data_Len=128
User_Prm_Data_Len=4
User_Prm_Data = 0x00,0x00,0x00,0x42
Max_User_Prm_Data_Len=16
Ext_User_Prm_Data_Const(0)=0x00,0x00,0x00,0x42
Ext_User_Prm_Data_Ref(3)=1
Ext_User_Prm_Data_Ref(3)=2
Modular_Station=1
Modul_Offset=1
Max_Module=32
FixPresetModules=1
Max_Input_Len=249
Max_Output_Len=249
Max_Data_Len=498
Module="fixed module" 0x00
Preset=1
EndModule
Module="dummy input module" 0x10
EndModule
Module="dummy output module" 0x20
EndModule
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES
loadrt stepgen step_type=0,0,0
loadrt charge_pump
loadrt comp count=3
loadusr -W hal_manualtoolchange
# Base thread
addf stepgen.make-pulses base-thread
# Servo thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf charge-pump servo-thread
addf comp.0 servo-thread
addf comp.1 servo-thread
addf comp.2 servo-thread
# Spindle control
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
# Coolant control
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
# heartbeat generator
setp charge-pump.enable 1
net heartbeat <= charge-pump.out-4
# Emergency stop logic
net estop-out-not <= iocontrol.0.user-enable-out
net estop-in-not => iocontrol.0.emc-enable-in
# Manual tool change
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
# X joint
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen [STEPCONF]STEPLEN
setp stepgen.0.stepspace [STEPCONF]STEPSPACE
setp stepgen.0.dirhold [STEPCONF]DIRHOLD
setp stepgen.0.dirsetup [STEPCONF]DIRSETUP
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
net home-x => axis.0.home-sw-in
net limit-x => axis.0.neg-lim-sw-in
net limit-x => axis.0.pos-lim-sw-in
# Y joint
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen [STEPCONF]STEPLEN
setp stepgen.1.stepspace [STEPCONF]STEPSPACE
setp stepgen.1.dirhold [STEPCONF]DIRHOLD
setp stepgen.1.dirsetup [STEPCONF]DIRSETUP
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
net home-y => axis.1.home-sw-in
net limit-y => axis.1.neg-lim-sw-in
net limit-y => axis.1.pos-lim-sw-in
# Z joint
setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen [STEPCONF]STEPLEN
setp stepgen.2.stepspace [STEPCONF]STEPSPACE
setp stepgen.2.dirhold [STEPCONF]DIRHOLD
setp stepgen.2.dirsetup [STEPCONF]DIRSETUP
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 home-z => axis.2.home-sw-in
net limit-z => axis.2.neg-lim-sw-in
net limit-z => axis.2.pos-lim-sw-in
# Simulate home switches
net xpos-cmd => comp.0.in0
setp comp.0.in1 0
setp comp.0.hyst 0.1
net home-x <= comp.0.out
net ypos-cmd => comp.1.in0
setp comp.1.in1 0
setp comp.1.hyst 0.1
net home-y <= comp.1.out
net zpos-cmd => comp.2.in0
setp comp.2.in1 0
setp comp.2.hyst 0.1
net home-z <= comp.2.out
# Simulate hardware limit switches
sets limit-x 0
sets limit-y 0
sets limit-z 0
[EMC]
MACHINE = linuxcnc-demo
DEBUG = 0
[DISPLAY]
DISPLAY = axis
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.2
INTRO_GRAPHIC = emc2.gif
INTRO_TIME = 0
PROGRAM_PREFIX = /tmp
INCREMENTS = 0.1mm 0.05mm 0.01mm 0.005mm 0.001mm
OPEN_FILE = linuxcnc-demo.ngc
[FILTER]
PROGRAM_EXTENSION = .py Python script
py = python
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = emc.var
RS274NGC_STARTUP_CODE = G17 G21 G40 G49 G80 G90 G94
[EMCMOT]
EMCMOT = motmod
SHMEM_KEY = 111
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 20000
SERVO_PERIOD = 1000000
[HAL]
HALFILE = linuxcnc-demo.hal
HALFILE = profibus.hal
HALUI = halui
[TRAJ]
AXES = 3
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
CYCLE_TIME = 0.001
DEFAULT_VELOCITY = 10.0
MAX_LINEAR_VELOCITY = 30.0
NO_FORCE_HOMING = 1
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[STEPCONF]
STEPLEN = 1000
STEPSPACE = 10000
DIRHOLD = 500
DIRSETUP = 500
# X
[AXIS_0]
TYPE = LINEAR
HOME = -100
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 100
STEPGEN_MAXACCEL = 120
SCALE = 100
FERROR = 20.0
MIN_LIMIT = -202
MAX_LIMIT = 2
HOME_OFFSET = -10
HOME_SEARCH_VEL = -5.0
HOME_LATCH_VEL = -0.5
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_SEQUENCE = 1
# Y
[AXIS_1]
TYPE = LINEAR
HOME = -100
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 100
STEPGEN_MAXACCEL = 120
SCALE = 100
FERROR = 20.0
MIN_LIMIT = -202
MAX_LIMIT = 2
HOME_OFFSET = -10
HOME_SEARCH_VEL = -5.0
HOME_LATCH_VEL = 0.5
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_SEQUENCE = 1
# Z
[AXIS_2]
TYPE = LINEAR
HOME = -50
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 100
STEPGEN_MAXACCEL = 120
SCALE = 100
FERROR = 20.0
MIN_LIMIT = -202
MAX_LIMIT = 2
HOME_OFFSET = -10
HOME_SEARCH_VEL = -5.0
HOME_LATCH_VEL = 0.5
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_SEQUENCE = 0
This diff is collapsed.
# ---------------------------------------
# --- PROFIBUS DP
# --- LinuxCNC HAL configuration file
# ------
# --- Load the pyprofibus HAL userspace module ---
#
# Parameters:
# --loglevel LVL : Change the log level.
#
# --nice NICE : Renice the process. -20 <= NICE <= 19.
# Default: Do not renice.
#
# The last parameter is the configuration file describing the PROFIBUS.
#
loadusr -Wn profibus pyprofibus-linuxcnc-hal pyprofibus.conf
# --- Enable the used output pins ---
# All output pins are deactivated by default.
# So all output pins connected below, should be activated here by writing
# a '1' to the '.active' pin.
# Deactivated output pins will not be forwarded from LinuxCNC to the PROFIBUS.
setp profibus.slave.8.output.bit.0.0.active 1
setp profibus.slave.8.output.bit.0.1.active 1
setp profibus.slave.8.output.bit.1.0.active 1
setp profibus.slave.8.output.bit.1.1.active 1
setp profibus.slave.8.output.bit.1.2.active 1
setp profibus.slave.8.output.bit.1.3.active 1
setp profibus.slave.8.output.bit.1.4.active 1
setp profibus.slave.8.output.float.4.active 1
setp profibus.slave.8.output.float.8.active 1
setp profibus.slave.8.output.float.12.active 1
setp profibus.slave.8.output.u8.16.active 1
setp profibus.slave.8.output.u16.18.active 1
setp profibus.slave.8.output.s16.20.active 1
setp profibus.slave.8.output.u31.22.active 1
setp profibus.slave.8.output.s32.26.active 1
# --- Connect output pins ---
net heartbeat => profibus.slave.8.output.bit.0.0
net estop-out-not => profibus.slave.8.output.bit.0.1
net spindle-cw => profibus.slave.8.output.bit.1.0
net spindle-ccw => profibus.slave.8.output.bit.1.1
net xpos-cmd => profibus.slave.8.output.float.4
net ypos-cmd => profibus.slave.8.output.float.8
net zpos-cmd => profibus.slave.8.output.float.12
setp profibus.slave.8.output.bit.1.2 1 # limit-x inverted dummy loopback
setp profibus.slave.8.output.bit.1.3 1 # limit-y inverted dummy loopback
setp profibus.slave.8.output.bit.1.4 1 # limit-z inverted dummy loopback
setp profibus.slave.8.output.bit.1.5 0 # estop-in-not inverted dummy loopback
# --- Enable the used input pins ---
# All input pins are deactivated by default.
# So all input pins connected below, should be activated here by writing
# a '1' to the '.active' pin.
# Deactivated input pins will not be forwarded from the PROFIBUS to LinuxCNC.
setp profibus.slave.8.input.bit.0.0.active 1
setp profibus.slave.8.input.bit.0.1.active 1
setp profibus.slave.8.input.bit.1.0.active 1
setp profibus.slave.8.input.bit.1.1.active 1
setp profibus.slave.8.input.bit.1.2.active 1
setp profibus.slave.8.input.bit.1.3.active 1
setp profibus.slave.8.input.bit.1.4.active 1
setp profibus.slave.8.input.bit.1.5.active 1
setp profibus.slave.8.input.float.4.active 1
setp profibus.slave.8.input.float.8.active 1
setp profibus.slave.8.input.float.12.active 1
setp profibus.slave.8.input.u8.16.active 1
setp profibus.slave.8.input.u16.18.active 1
setp profibus.slave.8.input.s16.20.active 1
setp profibus.slave.8.input.u31.22.active 1
setp profibus.slave.8.input.s32.26.active 1
# --- Connect input pins ---
net limit-x <= profibus.slave.8.input.bit.1.2
net limit-y <= profibus.slave.8.input.bit.1.3
net limit-z <= profibus.slave.8.input.bit.1.4
net estop-in-not <= profibus.slave.8.input.bit.1.5
# Always keep this at the end of this file.
# This will activate data transfer between pyprofibus and LinuxCNC.
setp profibus.config.ready 1
; ----------------------------------------------- ;
; ;
; PROFIBUS configuration ;
; ;
; This file configures a pyprofibus instance. ;
; ;
; ----------------------------------------------- ;
; General settings
[PROFIBUS]
; Enable/disable debug mode.
; 0 -> no debugging.
; 1 -> DP debugging.
; 2 -> DP and PHY debugging.
debug=0
; PHY protocol layer configuration
[PHY]
; The PHY layer driver type.
type=dummy_slave
; The PHY device name/path.
; Can be a device like /dev/ttyS0 or /dev/ttyAMA0 for 'serial'.
dev=/dev/ttyS0
; The Profibus on-wire baud rate.
baud=19200
; FDL protocol layer configuration
[FDL]
; DP protocol layer configuration
[DP]
; The master device class. Either 1 or 2.
master_class=1
; The Profibus address of this device.
master_addr=2
; ---
; Slave configurations
; Add as many [SLAVE_xxx] sections as needed.
; ---
; First slave configuration
[SLAVE_0]
; This slave's Profibus address
addr=8
; The path to the GSD file.
gsd=dummy.gsd
; Boolean: Sync mode enabled/available?
sync_mode=1
; Boolean: Freeze mode enabled/available?
freeze_mode=1
; 8 bit integer specifying the Profibus group ident mask.
group_mask=1
; This slave's watchdog timeout, in milliseconds.
watchdog_ms=300
; Module configuration.
; For each module plugged into the slave, add a module_xxx
; entry with the name of the module.
; The module name must match the name from the GSD file (approximately).
; The modules are used in the order of the index number.
module_0=dummy input module
module_1=dummy output module
; The number of output bytes this slave transmits to the
; master in Data_Exchange.
; This usually depends on the modules plugged into the slave.
output_size=32
; The number of input bytes this slave expects to receive
; in Data_Exchange.
; This usually depends on the modules plugged into the slave.
input_size=32
#!/bin/sh
die()
{
echo "$*" >&2
exit 1
}
usage()
{
echo "Usage: run-linuxcnc-demo.sh [/path/to/linuxcnc]"
echo
echo " /path/to/linuxcnc: Path to 'linuxcnc' start script"
}
if [ $# -ge 1 ] && [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
if [ $# -eq 0 ]; then
linuxcnc="linuxcnc"
elif [ $# -eq 1 ]; then
linuxcnc="$1"
else
usage
exit 1
fi
# basedir = directory where this script lives in
basedir="$(dirname "$0")"
[ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
# rootdir = root of the pyprofibus repository
rootdir="$basedir/.."
[ -x "$rootdir/pyprofibus-linuxcnc-hal" ] || die "pyprofibus-linuxcnc-hal not found"
cleanup()
{
rm -f "/tmp/linuxcnc-demo.ngc"
}
cleanup
trap cleanup EXIT
cp "$basedir/linuxcnc-demo.ngc" /tmp/ || die "Failed to copy linuxcnc-demo.ngc"
# Start LinuxCNC
(
cd "$basedir" || die "Failed to 'cd $basedir'"
PATH="$rootdir/:$PATH"\
PYTHONPATH="$rootdir/:$PYTHONPATH"\
"$linuxcnc" "$basedir/linuxcnc-demo.ini" ||\
die "LinuxCNC exited with an error"
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment