2.8.0~pre1 python linuxcnc.home(0) not working

More
02 May 2020 16:26 #166416 by LearningLinuxCNC
Not sure where to post this.

I had a bit of python code that was working in 2.7

I have switched to 2.8.0~pre1 on rpi4 for this project.

The bit of python code that I was using is no longer working. I understand that things changed when joints-axis was implemented however the home portion did not change base on the docs.

my code is as follows.
import linuxcnc
. . .

self.emc = linuxcnc
self.status = linuxcnc.status

. . .

#check to see if the machine is homed

       s = self.status
       data = s.joint[0]['homed'] + s.joint[1]['homed'] + s.joint[2]['homed'] + s.joint[3]['homed']
       print "Joint 0 homed: ", s.joint[0]["homed"]
       print "Joint 1 homed: ", s.joint[1]["homed"]
       print "Joint 2 homed: ", s.joint[2]["homed"]
       print "Joint 3 homed: ", s.joint[3]["homed"]
       print "data: ", data
       if data < 4:
          #machine is not homed
          I = self.emc.command()
          I.home(0)
          s = self.status
          print "Joint 0 homed: ", s.joint[0]["homed"]
          if s.joint[0]['homed']:
            msg = ("   joint 0 homed")
            self.appendpgmlog(msg)
          I.home(1)
          s = self.status
          print "Joint 1 homed: ", s.joint[1]["homed"]
          if s.joint[1]['homed']:
            msg = ("   joint 1 homed")
            self.appendpgmlog(msg)
          I.home(2)
          s = self.status
          print "Joint 2 homed: ", s.joint[2]["homed"]
          if s.joint[2]['homed']:
            msg = ("   joint 2 homed")
            self.appendpgmlog(msg)
          I.home(3)
          s = self.status
          print "Joint 3 homed: ", s.joint[3]["homed"]
          if s.joint[3]['homed']:
            msg = ("   joint 3 homed")
            self.appendpgmlog(msg)

using this code the joints don't home and the report in the terminal window after this code has ran is as follows.
Joint 0 homed:  0
Joint 1 homed:  0
Joint 2 homed:  0
Joint 3 homed:  0
data:  0
Joint 0 homed:  0
Joint 1 homed:  0
Joint 2 homed:  0
Joint 3 homed:  0

Is there an issue with linuxcnc.home(x) with 2.8.0~pre1?

most of this is for debugging purposes since it is not working. previously I simply had
I.home(0)
I.home(1)
I.home(2)
I.home(3)

Please Log in or Create an account to join the conversation.

More
02 May 2020 18:24 #166419 by cmorley
when checking status you must poll() first or your info is state.

to home you must be in manual mode and telop mode must be false:

I.teleop_enable(False)

I might add that Gstat would probably be useful to you:
linuxcnc.org/docs/2.8/html/gui/GStat.html

Please Log in or Create an account to join the conversation.

More
02 May 2020 21:56 #166433 by LearningLinuxCNC
Ok, So I implemented the changes suggested by cmorley.

I have changed to manual mode and teleop to false. This still does not allow homing.
s = self.status
       s.poll()
       data = s.joint[0]["homed"] + s.joint[1]["homed"] + s.joint[2]["homed"] + s.joint[3]["homed"]
       print "Joint 0 homed: ", s.joint[0]["homed"]
       print "Joint 1 homed: ", s.joint[1]["homed"]
       print "Joint 2 homed: ", s.joint[2]["homed"]
       print "Joint 3 homed: ", s.joint[3]["homed"]
       print "data: ", data
       if data < 4:
          #machine is not homed
          I = self.emc.command()
          I.mode(linuxcnc.MODE_MANUAL)
          print "linuxcnc MODE_MDI: ", linuxcnc.MODE_MDI
          print "linuxcnc MODE_AUTO: ", linuxcnc.MODE_AUTO
          print "linuxcnc MODE_MANUAL: ", linuxcnc.MODE_MANUAL
          I.wait_complete()
          I.teleop_enable(False)
          I.wait_complete()
          I.home(0)
          I.wait_complete(10)
          s.poll()
          print "linuxcnc mode: ", s.task_mode
          print "linuxcnc TRAJ_MODE_COORD, TRAJ_MODE_FREE, TRAJ_MODE_TELEOP: ", linuxcnc.TRAJ_MODE_COORD, linuxcnc.TRAJ_MODE_FREE, linuxcnc.TRAJ_MODE_TELEOP
          print "teleop_mode: ", s.motion_mode
          print "Joint 0 homed: ", s.joint[0]["homed"]
          if s.joint[0]['homed']:
            msg = ("   joint 0 homed")
            self.appendpgmlog(msg)
          I.home(1)
          I.wait_complete(10)
          s.poll()
          print "linuxcnc mode: ", s.task_mode
          print "teleop_mode: ", s.motion_mode
          print "Joint 1 homed: ", s.joint[1]["homed"]
          if s.joint[1]['homed']:
            msg = ("   joint 1 homed")
            self.appendpgmlog(msg)
          I.home(2)
          I.wait_complete(10)
          s.poll()
          print "linuxcnc mode: ", s.task_mode
          print "teleop_mode: ", s.motion_mode
          print "Joint 2 homed: ", s.joint[2]["homed"]
          if s.joint[2]['homed']:
            msg = ("   joint 2 homed")
            self.appendpgmlog(msg)
          I.home(3)
          I.wait_complete(10)
          s.poll()
          print "linuxcnc mode: ", s.task_mode
          print "teleop_mode: ", s.motion_mode
          print "Joint 3 homed: ", s.joint[3]["homed"]
          if s.joint[3]['homed']:
            msg = ("   joint 3 homed")
            self.appendpgmlog(msg)

Still no joy. I get the following output and the joint's don't even attempt to home.
Joint 0 homed:  0
Joint 1 homed:  0
Joint 2 homed:  0
Joint 3 homed:  0
data:  0
linuxcnc MODE_MDI:  3
linuxcnc MODE_AUTO:  2
linuxcnc MODE_MANUAL:  1
linuxcnc mode:  1
linuxcnc TRAJ_MODE_COORD, TRAJ_MODE_FREE, TRAJ_MODE_TELEOP:  2 1 3
teleop_mode:  1
Joint 0 homed:  0
linuxcnc mode:  1
teleop_mode:  1
Joint 1 homed:  0
linuxcnc mode:  1
teleop_mode:  1
Joint 2 homed:  0
linuxcnc mode:  1
teleop_mode:  1
Joint 3 homed:  0

Actually now that I think about it, the old code worked before in 2.8.0~pre1 on a simulation configuration. Could there be something in the INI that would keep this from working?

The same INI homing worked in Axis GUI. Only changes are GUI and HAL related.

Please Log in or Create an account to join the conversation.

More
02 May 2020 22:31 #166437 by cmorley
please post your config files.

Please Log in or Create an account to join the conversation.

More
04 May 2020 13:55 #166619 by LearningLinuxCNC
Here is the .ini file
# Generated by PNCconf at Fri May  1 15:48:56 2020
# Using LinuxCNC version:  UNAVAILABLE
# If you make changes to this file, they will be
# overwritten when you run PNCconf again

[EMC]
MACHINE = Holloway America Ventilator
DEBUG = 0
VERSION = 1.1

[DISPLAY]
DISPLAY = HAVentGui
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.000000
MAX_SPINDLE_OVERRIDE = 1.000000
MIN_SPINDLE_OVERRIDE = 0.500000

##TODO CHANGE INTRO GRAPHIC.
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/pi/linuxcnc/nc_files
INCREMENTS = .1in .05in .01in .005in .001in .0005in .0001in
POSITION_FEEDBACK = ACTUAL
DEFAULT_LINEAR_VELOCITY = 0.250000
MAX_LINEAR_VELOCITY = 12.000000
MIN_LINEAR_VELOCITY = 0.016670
DEFAULT_ANGULAR_VELOCITY = 12.000000
MAX_ANGULAR_VELOCITY = 1200.000000
MIN_ANGULAR_VELOCITY = 1.666667
EDITOR = gedit
GEOMETRY = xyz

[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
SERVO_PERIOD = 1000000

[HMOT]
# **** This is for info only ****
CARD0=hm2_7i76e.0

[HAL]
HALUI = halui
HALFILE = my_LinuxCNC_machine.hal
#HALFILE = HAVent.hal # this was the old halfile for 2.7 linuxcnc
HALFILE = Ventilator.hal
#HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal
#SHUTDOWN = shutdown.hal

[HALUI]

[KINS]
JOINTS = 4
KINEMATICS = trivkins coordinates=XYZA

[TRAJ]
COORDINATES =  XYZA
MAX_ANGULAR_VELOCITY = 2400.00
DEFAULT_ANGULAR_VELOCITY = 60.00
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.20
MAX_LINEAR_VELOCITY = 12.00

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

#******************************************
[AXIS_X]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 160.0
MIN_LIMIT = -0.001
MAX_LIMIT = 4.375

[JOINT_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 160.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 15.00
STEPGEN_MAXACCEL = 200.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = -4063.9999
MIN_LIMIT = -0.001
MAX_LIMIT = 4.375
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -0.316667
HOME_LATCH_VEL = -0.016667
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************

#******************************************
[AXIS_Y]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
MIN_LIMIT = -0.001
MAX_LIMIT = 8.0

[JOINT_1]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 15.00
STEPGEN_MAXACCEL = 225.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 1016.0
MIN_LIMIT = -0.001
MAX_LIMIT = 8.0
HOME_OFFSET = 0.0
#******************************************

#******************************************
[AXIS_Z]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
MIN_LIMIT = -4.0
MAX_LIMIT = 0.001

[JOINT_2]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 12.00
STEPGEN_MAXACCEL = 225.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 1016.0
MIN_LIMIT = -4.0
MAX_LIMIT = 0.001
HOME_OFFSET = 0.0
#******************************************

#******************************************
[AXIS_A]
MAX_VELOCITY = 2400.0
MAX_ACCELERATION = 10000.0
MIN_LIMIT = -0.001
MAX_LIMIT = 180.0

[JOINT_3]
TYPE = ANGULAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 1200.0
MAX_ACCELERATION = 10000.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 1500.00
STEPGEN_MAXACCEL = 12500.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 36.0
MIN_LIMIT = -0.001
MAX_LIMIT = 180.0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -12.000000
HOME_LATCH_VEL = -0.500000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************


Here is the main HAL file my_LinuxCNC_machine.hal
# Generated by PNCconf at Fri May  1 15:48:57 2020
# Using LinuxCNC version:  UNAVAILABLE
# If you make changes to this file, they will be
# overwritten when you run PNCconf again

loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hostmot2
loadrt hm2_eth board_ip="192.168.1.121" config=" num_encoders=1 num_pwmgens=1 num_stepgens=4 sserial_port_0=00xxxx" 
setp    hm2_7i76e.0.watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.y,pid.z,pid.a,pid.s

addf hm2_7i76e.0.read          servo-thread
addf motion-command-handler   servo-thread
addf motion-controller        servo-thread
addf pid.x.do-pid-calcs       servo-thread
addf pid.y.do-pid-calcs       servo-thread
addf pid.z.do-pid-calcs       servo-thread
addf pid.a.do-pid-calcs       servo-thread
addf pid.s.do-pid-calcs       servo-thread
addf hm2_7i76e.0.write         servo-thread
setp hm2_7i76e.0.dpll.01.timer-us -50
setp hm2_7i76e.0.stepgen.timer-number 1

# external output signals


# --- X-ENABLE ---
net x-enable  =>     hm2_7i76e.0.7i76.0.0.output-00

# --- A-ENABLE ---
net a-enable  =>     hm2_7i76e.0.7i76.0.0.output-01

# external input signals


# --- HOME-A ---
net home-a     <=  hm2_7i76e.0.7i76.0.0.input-00

# --- HOME-X ---
net home-x     <=  hm2_7i76e.0.7i76.0.0.input-01

#*******************
#  AXIS X JOINT 0
#*******************

setp   pid.x.Pgain     [JOINT_0]P
setp   pid.x.Igain     [JOINT_0]I
setp   pid.x.Dgain     [JOINT_0]D
setp   pid.x.bias      [JOINT_0]BIAS
setp   pid.x.FF0       [JOINT_0]FF0
setp   pid.x.FF1       [JOINT_0]FF1
setp   pid.x.FF2       [JOINT_0]FF2
setp   pid.x.deadband  [JOINT_0]DEADBAND
setp   pid.x.maxoutput [JOINT_0]MAX_OUTPUT
setp   pid.x.error-previous-target true
setp   pid.x.maxerror .0005

net x-index-enable  <=> pid.x.index-enable
net x-enable        =>  pid.x.enable
net x-pos-cmd       =>  pid.x.command
net x-pos-fb        =>  pid.x.feedback
net x-output        <=  pid.x.output

# Step Gen signals/setup

setp   hm2_7i76e.0.stepgen.00.dirsetup        [JOINT_0]DIRSETUP
setp   hm2_7i76e.0.stepgen.00.dirhold         [JOINT_0]DIRHOLD
setp   hm2_7i76e.0.stepgen.00.steplen         [JOINT_0]STEPLEN
setp   hm2_7i76e.0.stepgen.00.stepspace       [JOINT_0]STEPSPACE
setp   hm2_7i76e.0.stepgen.00.position-scale  [JOINT_0]STEP_SCALE
setp   hm2_7i76e.0.stepgen.00.step_type        0
setp   hm2_7i76e.0.stepgen.00.control-type     1
setp   hm2_7i76e.0.stepgen.00.maxaccel         [JOINT_0]STEPGEN_MAXACCEL
setp   hm2_7i76e.0.stepgen.00.maxvel           [JOINT_0]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net x-pos-cmd    <= joint.0.motor-pos-cmd
net x-vel-cmd    <= joint.0.vel-cmd
net x-output     <= hm2_7i76e.0.stepgen.00.velocity-cmd
net x-pos-fb     <= hm2_7i76e.0.stepgen.00.position-fb
net x-pos-fb     => joint.0.motor-pos-fb
net x-enable     <= joint.0.amp-enable-out
net x-enable     => hm2_7i76e.0.stepgen.00.enable

# ---setup home / limit switch signals---

net home-x     =>  joint.0.home-sw-in
net x-neg-limit     =>  joint.0.neg-lim-sw-in
net x-pos-limit     =>  joint.0.pos-lim-sw-in

#*******************
#  AXIS Y JOINT 1
#*******************

setp   pid.y.Pgain     [JOINT_1]P
setp   pid.y.Igain     [JOINT_1]I
setp   pid.y.Dgain     [JOINT_1]D
setp   pid.y.bias      [JOINT_1]BIAS
setp   pid.y.FF0       [JOINT_1]FF0
setp   pid.y.FF1       [JOINT_1]FF1
setp   pid.y.FF2       [JOINT_1]FF2
setp   pid.y.deadband  [JOINT_1]DEADBAND
setp   pid.y.maxoutput [JOINT_1]MAX_OUTPUT
setp   pid.y.error-previous-target true
setp   pid.y.maxerror .0005

net y-index-enable  <=> pid.y.index-enable
net y-enable        =>  pid.y.enable
net y-pos-cmd       =>  pid.y.command
net y-pos-fb        =>  pid.y.feedback
net y-output        <=  pid.y.output

# Step Gen signals/setup

setp   hm2_7i76e.0.stepgen.02.dirsetup        [JOINT_1]DIRSETUP
setp   hm2_7i76e.0.stepgen.02.dirhold         [JOINT_1]DIRHOLD
setp   hm2_7i76e.0.stepgen.02.steplen         [JOINT_1]STEPLEN
setp   hm2_7i76e.0.stepgen.02.stepspace       [JOINT_1]STEPSPACE
setp   hm2_7i76e.0.stepgen.02.position-scale  [JOINT_1]STEP_SCALE
setp   hm2_7i76e.0.stepgen.02.step_type        0
setp   hm2_7i76e.0.stepgen.02.control-type     1
setp   hm2_7i76e.0.stepgen.02.maxaccel         [JOINT_1]STEPGEN_MAXACCEL
setp   hm2_7i76e.0.stepgen.02.maxvel           [JOINT_1]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net y-pos-cmd    <= joint.1.motor-pos-cmd
net y-vel-cmd    <= joint.1.vel-cmd
net y-output     <= hm2_7i76e.0.stepgen.02.velocity-cmd
net y-pos-fb     <= hm2_7i76e.0.stepgen.02.position-fb
net y-pos-fb     => joint.1.motor-pos-fb
net y-enable     <= joint.1.amp-enable-out
net y-enable     => hm2_7i76e.0.stepgen.02.enable

# ---setup home / limit switch signals---

net y-home-sw     =>  joint.1.home-sw-in
net y-neg-limit     =>  joint.1.neg-lim-sw-in
net y-pos-limit     =>  joint.1.pos-lim-sw-in

#*******************
#  AXIS Z JOINT 2
#*******************

setp   pid.z.Pgain     [JOINT_2]P
setp   pid.z.Igain     [JOINT_2]I
setp   pid.z.Dgain     [JOINT_2]D
setp   pid.z.bias      [JOINT_2]BIAS
setp   pid.z.FF0       [JOINT_2]FF0
setp   pid.z.FF1       [JOINT_2]FF1
setp   pid.z.FF2       [JOINT_2]FF2
setp   pid.z.deadband  [JOINT_2]DEADBAND
setp   pid.z.maxoutput [JOINT_2]MAX_OUTPUT
setp   pid.z.error-previous-target true
setp   pid.z.maxerror .0005

net z-index-enable  <=> pid.z.index-enable
net z-enable        =>  pid.z.enable
net z-pos-cmd       =>  pid.z.command
net z-pos-fb        =>  pid.z.feedback
net z-output        <=  pid.z.output

# Step Gen signals/setup

setp   hm2_7i76e.0.stepgen.03.dirsetup        [JOINT_2]DIRSETUP
setp   hm2_7i76e.0.stepgen.03.dirhold         [JOINT_2]DIRHOLD
setp   hm2_7i76e.0.stepgen.03.steplen         [JOINT_2]STEPLEN
setp   hm2_7i76e.0.stepgen.03.stepspace       [JOINT_2]STEPSPACE
setp   hm2_7i76e.0.stepgen.03.position-scale  [JOINT_2]STEP_SCALE
setp   hm2_7i76e.0.stepgen.03.step_type        0
setp   hm2_7i76e.0.stepgen.03.control-type     1
setp   hm2_7i76e.0.stepgen.03.maxaccel         [JOINT_2]STEPGEN_MAXACCEL
setp   hm2_7i76e.0.stepgen.03.maxvel           [JOINT_2]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net z-pos-cmd    <= joint.2.motor-pos-cmd
net z-vel-cmd    <= joint.2.vel-cmd
net z-output     <= hm2_7i76e.0.stepgen.03.velocity-cmd
net z-pos-fb     <= hm2_7i76e.0.stepgen.03.position-fb
net z-pos-fb     => joint.2.motor-pos-fb
net z-enable     <= joint.2.amp-enable-out
net z-enable     => hm2_7i76e.0.stepgen.03.enable

# ---setup home / limit switch signals---

net z-home-sw     =>  joint.2.home-sw-in
net z-neg-limit     =>  joint.2.neg-lim-sw-in
net z-pos-limit     =>  joint.2.pos-lim-sw-in

#*******************
#  AXIS A JOINT 3
#*******************

setp   pid.a.Pgain     [JOINT_3]P
setp   pid.a.Igain     [JOINT_3]I
setp   pid.a.Dgain     [JOINT_3]D
setp   pid.a.bias      [JOINT_3]BIAS
setp   pid.a.FF0       [JOINT_3]FF0
setp   pid.a.FF1       [JOINT_3]FF1
setp   pid.a.FF2       [JOINT_3]FF2
setp   pid.a.deadband  [JOINT_3]DEADBAND
setp   pid.a.maxoutput [JOINT_3]MAX_OUTPUT
setp   pid.a.error-previous-target true
setp   pid.a.maxerror .0005

net a-index-enable  <=> pid.a.index-enable
net a-enable        =>  pid.a.enable
net a-pos-cmd       =>  pid.a.command
net a-pos-fb        =>  pid.a.feedback
net a-output        <=  pid.a.output

# Step Gen signals/setup

setp   hm2_7i76e.0.stepgen.01.dirsetup        [JOINT_3]DIRSETUP
setp   hm2_7i76e.0.stepgen.01.dirhold         [JOINT_3]DIRHOLD
setp   hm2_7i76e.0.stepgen.01.steplen         [JOINT_3]STEPLEN
setp   hm2_7i76e.0.stepgen.01.stepspace       [JOINT_3]STEPSPACE
setp   hm2_7i76e.0.stepgen.01.position-scale  [JOINT_3]STEP_SCALE
setp   hm2_7i76e.0.stepgen.01.step_type        0
setp   hm2_7i76e.0.stepgen.01.control-type     1
setp   hm2_7i76e.0.stepgen.01.maxaccel         [JOINT_3]STEPGEN_MAXACCEL
setp   hm2_7i76e.0.stepgen.01.maxvel           [JOINT_3]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net a-pos-cmd    <= joint.3.motor-pos-cmd
net a-vel-cmd    <= joint.3.vel-cmd
net a-output     <= hm2_7i76e.0.stepgen.01.velocity-cmd
net a-pos-fb     <= hm2_7i76e.0.stepgen.01.position-fb
net a-pos-fb     => joint.3.motor-pos-fb
net a-enable     <= joint.3.amp-enable-out
net a-enable     => hm2_7i76e.0.stepgen.01.enable

# ---setup home / limit switch signals---

net home-a     =>  joint.3.home-sw-in
net a-neg-limit     =>  joint.3.neg-lim-sw-in
net a-pos-limit     =>  joint.3.pos-lim-sw-in


#******************************
# connect miscellaneous signals
#******************************

#  ---HALUI signals---

net axis-select-x  halui.axis.x.select
net jog-x-pos      halui.axis.x.plus
net jog-x-neg      halui.axis.x.minus
net jog-x-analog   halui.axis.x.analog
net x-is-homed     halui.joint.0.is-homed
net axis-select-y  halui.axis.y.select
net jog-y-pos      halui.axis.y.plus
net jog-y-neg      halui.axis.y.minus
net jog-y-analog   halui.axis.y.analog
net y-is-homed     halui.joint.1.is-homed
net axis-select-z  halui.axis.z.select
net jog-z-pos      halui.axis.z.plus
net jog-z-neg      halui.axis.z.minus
net jog-z-analog   halui.axis.z.analog
net z-is-homed     halui.joint.2.is-homed
net axis-select-a  halui.axis.a.select
net jog-a-pos      halui.axis.a.plus
net jog-a-neg      halui.axis.a.minus
net jog-a-analog   halui.axis.a.analog
net a-is-homed     halui.joint.3.is-homed
net jog-selected-pos      halui.axis.selected.plus
net jog-selected-neg      halui.axis.selected.minus
net spindle-manual-cw     halui.spindle.0.forward
net spindle-manual-ccw    halui.spindle.0.reverse
net spindle-manual-stop   halui.spindle.0.stop
net machine-is-on         halui.machine.is-on
net jog-speed             halui.axis.jog-speed
net MDI-mode              halui.mode.is-mdi

#  ---coolant signals---

net coolant-mist      <=  iocontrol.0.coolant-mist
net coolant-flood     <=  iocontrol.0.coolant-flood

#  ---probe signal---

net probe-in     =>  motion.probe-input

#  ---motion control signals---

net in-position               <=  motion.in-position
net machine-is-enabled        <=  motion.motion-enabled

#  ---digital in / out signals---

#  ---estop signals---

net estop-out     <=  iocontrol.0.user-enable-out
net estop-out     =>  iocontrol.0.emc-enable-in

#  ---toolchange signals for custom tool changer---

net tool-number             <=  iocontrol.0.tool-prep-number
net tool-change-request     <=  iocontrol.0.tool-change
net tool-change-confirmed   =>  iocontrol.0.tool-changed
net tool-prepare-request    <=  iocontrol.0.tool-prepare
net tool-prepare-confirmed  =>  iocontrol.0.tool-prepared

The second HAL file.
# this hal file connects the ventilator specific information to linuxcnc.

loadrt ventilator
loadrt oneshot count=1
loadrt and2 count=5
loadrt or2 count=3
loadrt timetrigger count=1
loadrt integ count=1
loadrt not count=1

addf ventilator.0 servo-thread
addf oneshot.0 servo-thread
addf and2.4 servo-thread
addf and2.3 servo-thread
addf and2.2 servo-thread
addf and2.1 servo-thread
addf and2.0 servo-thread
addf or2.0 servo-thread
addf or2.1 servo-thread
addf or2.2 servo-thread
addf not.0 servo-thread
addf timetrigger.0 servo-thread
addf integ.0 servo-thread

# oneshot params
oneshot.0.rising = true
oneshot.0.falling = false
oneshot.0.width = 0.050

# ventilator params
ventilator.0.piston-area = 27.1084
ventilator.0.acceleration-factor = 1.35

#integrator params
integ.0.gain = 16.66666666667

# ventilator inputs
net x-vel-cmd => ventilator.0.velocity 
net vent_bpm => ventilator.0.bpm
net vent_tv => ventilator.0.tv

# ventilator outputs
net vent_dist <= ventilator.0.dist
net vent_speed <= ventilator.0.speed
net vent_cycletime <= ventilator.0.cycletime
net vent_flowrate <= ventilator.0.flowrate

# connect two analog inputs for linuxcnc into the ventilator speed and distance
# these will be used in the .ngc file with the M
net vent_dist => motion.analog-in-00
net vent_speed => motion.analog-in-01

# connect the signals to run the program repeatedly
# first there is a signal from the UI that is a run button
net ui_run_btn => and2.1.in0
net ui_run_btn => oneshot.0.in

# connect the signals to an or gate that will reset the timetrigger
net oneshot_trigger or2.0.in0 <= oneshot.0.out
net breathtrigger_pgmrun => or2.0.in1

# connect the oneshot_trigger to one of the inputs of or2.2
net oneshot_trigger => or2.2.in0
net timetrigger_pgmrun => or2.2.in1

# connect the output of or2.2 to the second input of or2.1
net pgmortrigger or2.1.in1 <= or2.2.out

# connect the or2.0 to the timetrigger
net reset_timetrigger timetrigger.0.reset <= or2.0.out

# connect the vent_flowrate to the integrator to get the TV integrated
# we are leaving the gain for the integrator at 1.
net vent_flowrate => integ.0.in
# connect the integrated TV to a signal for used in the gui
net vent_int_tv <= integ.0.out

# connect the runbutton to a not and then to the reset of the integrator
#net ui_run_btn => not.0.in
#net not_ui_run_btn integ.0.reset <= not.0.out
net vent_oneshot integ.0.reset <= ventilator.0.oneshot

# connect the vent_cycletime to the timetrigger
net vent_cycletime => timetrigger.0.timeperiod

# connect the output of the timetrigger to an or gate
net timetrigger_pgmrun <= timetrigger.0.out
# connect other side of or2.1 to breath trigger
net breathtrigger_pgmrun => or2.1.in0

# connect the output of the or gate to the input of the and2 gate
net trgr_pgmrun or2.1.out => and2.0.in1

# connect the output of the and2.0 gate to the program run functions
net programrun_trigger <= and2.0.out
net programrun_trigger => halui.mode.auto
net programrun_trigger => halui.program.run

# connect homed signals to a bunch of ands so that we wait for the homing to complete
# prior to running the program
net ahomed joint.3.homed => and2.4.in0
net zhomed joint.2.homed => and2.4.in1
net zahomed and2.4.out => and2.3.in0
net yhomed joint.1.homed => and2.3.in1
net yzahomed and2.3.out => and2.2.in1
net xhomed joint.0.homed => and2.2.in0
net xyzahomed and2.2.out => and2.1.in1
net homed_and_runbtn and2.1.out => and2.0.in0

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

#connect signals to hal graphs
net vent_flowrate => HAVentGui.hg_iflow
net vent_int_tv => HAVentGui.hg_tv

#connect the setpiont input boxesc
net vent_bpm => HAVentGui.hal_sb_bpm-f
net vent_tv => HAVentGui.hal_sb_tv-f

#connect the alarm input boxes

#connect the run button to the run circuit
net ui_run_btn <= HAVentGui.hal_run_vent

#connect the simulated breath trigger
net breathtrigger_pgmrun <= HAVentGui.cb_breath

Please Log in or Create an account to join the conversation.

More
05 May 2020 16:37 #166778 by LearningLinuxCNC
So I made some changes in the INI file. As it was I could home individual axes and it worked fine. It would not home all as the home sequence was missing.

Here is the revised ini file.
# Generated by PNCconf at Fri May  1 15:48:56 2020
# Using LinuxCNC version:  UNAVAILABLE
# If you make changes to this file, they will be
# overwritten when you run PNCconf again

[EMC]
MACHINE = Holloway America Ventilator
DEBUG = 0
VERSION = 1.1

[DISPLAY]
DISPLAY = HAVentGui
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.000000
MAX_SPINDLE_OVERRIDE = 1.000000
MIN_SPINDLE_OVERRIDE = 0.500000

##TODO CHANGE INTRO GRAPHIC.
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/pi/linuxcnc/nc_files
INCREMENTS = .1in .05in .01in .005in .001in .0005in .0001in
POSITION_FEEDBACK = ACTUAL
DEFAULT_LINEAR_VELOCITY = 0.250000
MAX_LINEAR_VELOCITY = 12.000000
MIN_LINEAR_VELOCITY = 0.016670
DEFAULT_ANGULAR_VELOCITY = 12.000000
MAX_ANGULAR_VELOCITY = 1200.000000
MIN_ANGULAR_VELOCITY = 1.666667
EDITOR = gedit
GEOMETRY = xyz

[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
SERVO_PERIOD = 1000000

[HMOT]
# **** This is for info only ****
CARD0=hm2_7i76e.0

[HAL]
HALUI = halui
HALFILE = my_LinuxCNC_machine.hal
#HALFILE = HAVent.hal # this was the old halfile for 2.7 linuxcnc
HALFILE = Ventilator.hal
#HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal
#SHUTDOWN = shutdown.hal

[HALUI]

[KINS]
JOINTS = 4
KINEMATICS = trivkins coordinates=XYZA

[TRAJ]
COORDINATES =  XYZA
MAX_ANGULAR_VELOCITY = 2400.00
DEFAULT_ANGULAR_VELOCITY = 60.00
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.20
MAX_LINEAR_VELOCITY = 12.00

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

#******************************************
[AXIS_X]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 160.0
MIN_LIMIT = -0.001
MAX_LIMIT = 4.375

[JOINT_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 160.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 15.00
STEPGEN_MAXACCEL = 200.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = -4063.9999
MIN_LIMIT = -0.001
MAX_LIMIT = 4.375
HOME_SEQUENCE = 0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -0.316667
HOME_LATCH_VEL = -0.016667
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************

#******************************************
[AXIS_Y]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
MIN_LIMIT = -0.001
MAX_LIMIT = 8.0

[JOINT_1]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 15.00
STEPGEN_MAXACCEL = 225.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 1016.0
MIN_LIMIT = -0.001
MAX_LIMIT = 8.0
HOME_SEQUENCE = 0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = 0.000000
HOME_LATCH_VEL = 0.000000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************

#******************************************
[AXIS_Z]
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
MIN_LIMIT = -4.0
MAX_LIMIT = 0.001

[JOINT_2]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 12.0
MAX_ACCELERATION = 180.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 12.00
STEPGEN_MAXACCEL = 225.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 1016.0
MIN_LIMIT = -4.0
MAX_LIMIT = 0.001
HOME_SEQUENCE = 0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = 0.000000
HOME_LATCH_VEL = 0.000000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************

#******************************************
[AXIS_A]
MAX_VELOCITY = 2400.0
MAX_ACCELERATION = 10000.0
MIN_LIMIT = -0.001
MAX_LIMIT = 180.0

[JOINT_3]
TYPE = ANGULAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 1200.0
MAX_ACCELERATION = 10000.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 1500.00
STEPGEN_MAXACCEL = 12500.00
P = 1000.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 36.0
MIN_LIMIT = -0.001
MAX_LIMIT = 180.0
HOME_SEQUENCE = 0
HOME_OFFSET = 0.000000
HOME_SEARCH_VEL = -12.000000
HOME_LATCH_VEL = -0.500000
HOME_FINAL_VEL = 0.000000
HOME_USE_INDEX = NO
#******************************************

Then I added some additional buttons to the GUI to test homing using the VCP_ACTION_HOME glade widget.

The button with the VCP_ACTION_HOME worked.

The button using the linuxcnc.home(0) did not work.

After some more testing with linuxcnc.home(0) it appeared that some of the joints would try to home but they would stop for some reason. Some would home and others would not. It appeared that if one joint homed then the others quit trying to home.

Finally i wound up putting a loop in to check each axis if it had homed individually.
          I.home(0)
          self.waithomed(0)

          I.home(1)
          self.waithomed(1)

          I.home(2)
          self.waithomed(2)

          I.home(3)
          self.waithomed(3)


  def waithomed(self, joint):
       s = linuxcnc.stat()
       s.poll()
       t = 0.0
       i = 0
       homed = s.joint[joint]["homed"]
       while not homed:
         time.sleep(0.1)
         t = t + 0.1
         i = i + 1
         s.poll()
         homed = s.joint[joint]["homed"]
         if i == 10:
            i = 0
            print "Time: ", t, " Joint ", joint, " homed: ", homed

This then worked. For some reason the previous code with the i.wait_complete() was not waiting for the homing to finish.
I even tried it with 5 seconds to wait, but it did not finish. Come to find out that the time it takes to complete the homing is about 5 seconds per axis based on the above loop so I should have used i.wait_complete(10) and that would have worked.

I tried setting i.wait_complete(20) just to see if it would work and commented out the self.waithomed(joint) lines. This did not work either. Some of the joints would home but not all of them. In particular joints 0, 1 and 2 would home but joint 3 would not ever finish homing.

I have resorted to using the self.waithomed(joint) subroutine that I have posted above. I am interested in why this does not appear to work correctly. I can test out any other ideas if you like but I have found a work around for now.

Please Log in or Create an account to join the conversation.

Time to create page: 0.112 seconds
Powered by Kunena Forum