Why my closed loop stepper runs on grbl(Arduino) and not on linuxcnc?

  • PhilipME
  • PhilipME's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
15 Nov 2021 10:14 - 16 Nov 2021 09:31 #226562 by PhilipME
Good peacful day

I had another thread on this topic, but now since I made progress in isolating the problem, I felt in order not to confuse people, it will be better to start a new thread and since I have specific questions now.

my closed loop stepper motor is not running proper with linuxcnc, while it runs very good with grbl controler. below 2 videos showing the running of the motor in both cases.

 Both my machines (running linuxcnc) have less than 35000 ns max jitter after considrable abuse. with computer 1 has better reading than computer 2. But computer 2 has a graphic card that is why it runs better even with the higher nano seconds of max jitter. 

using linuxcnc you can hear the pulsing very slowly (in the video below) and the motor turns very slowly, that is why I suspected linuxcnc settings or latency related issue.

I placed order for mesa 7i76e, but my order was rejected (not sure why) I did not try to place a second order, I thought it is easier to work with parallel port while studying hal and linuxcnc in general. And when my confidence improve, I will place order for mesa again.

All my open loop steppers run perfectly with linuxcnc/ parallel port including the motor in subject when I use open loop controler.

Any hint will be appreciated

Philip




Last edit: 16 Nov 2021 09:31 by PhilipME.

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

More
15 Nov 2021 10:17 #226563 by Clive S

Good peacful day

I had another thread on this topic, but now since I made progress in isolating the problem, I felt in order not to confuse people, it will be better to start a new thread and since I have specific questions now.

my closed loop stepper motor is not running proper with linuxcnc, while it runs very good with grbl controler. below 2 videos showing the running of the motor in both cases.

 Both my machines (running linuxcnc) have less than 35000 ns in latency test. with computer 1 has better reading than computer 2. But computer 2 has a graphic card that is why it runs better even with the higher nano seconds of latency. 

using linuxcnc you can hear the pulsing very slowly (in the video below) and the motor turns very slowly, that is why I suspected linuxcnc settings or latency related issue.

I placed order for mesa 7i76e, but my order was rejected (not sure why) I did not try to place a second order, I thought it is easier to work with parallel port while studying hal and linuxcnc in general. And when my confidence improve, I will place order for mesa again.

All my open loop steppers run perfectly with linuxcnc/ parallel port including the motor in subject when I use open loop controler.

Any hint will be appreciated

Philip


Might be a good idea to post your hal and ini files
The following user(s) said Thank You: PhilipME

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

  • PhilipME
  • PhilipME's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
15 Nov 2021 10:26 #226564 by PhilipME
I did not make any changes to hal or ini . I used the stepconf files . Same what I do with open loop steppers. I did not feed any incoder signals to linux.


hal file
# Generated by stepconf 1.1 at Sun Nov 14 19:56:37 2021
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hal_parport cfg="0 out"
setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=1

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf pwmgen.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
addf pwmgen.update servo-thread

net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100.0
setp pwmgen.0.scale 1166.66666667
setp pwmgen.0.offset 0.114285714286
setp pwmgen.0.dither-pwm true
net spindle-cmd-rpm     <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps     <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed    => spindle.0.at-speed
net spindle-cw <= spindle.0.forward

net estop-out       => parport.0.pin-01-out
net xstep           => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir            => parport.0.pin-03-out
net ystep           => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
net ydir            => parport.0.pin-05-out
net zstep           => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net zdir            => parport.0.pin-07-out
net astep           => parport.0.pin-08-out
setp parport.0.pin-08-out-reset 1
net adir            => parport.0.pin-09-out
net spindle-cw      => parport.0.pin-14-out
net spindle-pwm     => parport.0.pin-16-out
net xenable         => parport.0.pin-17-out

setp stepgen.0.position-scale [JOINT_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 25000
setp stepgen.0.dirsetup 25000
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
net xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable joint.0.amp-enable-out => stepgen.0.enable

setp stepgen.1.position-scale [JOINT_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 25000
setp stepgen.1.dirsetup 25000
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
net ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable joint.1.amp-enable-out => stepgen.1.enable

setp stepgen.2.position-scale [JOINT_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 25000
setp stepgen.2.dirsetup 25000
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
net zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable joint.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



ini file
# Generated by stepconf 1.1 at Sun Nov 14 19:56:37 2021
# If you make changes to this file, they will be
# overwritten when you run stepconf again

[EMC]
MACHINE = closed-loop
DEBUG = 0
VERSION = 1.1

[DISPLAY]
DISPLAY = gmoccapy
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
ARCDIVISION = 64
GRIDS = 10mm 20mm 50mm 100mm 1in 2in 5in 10in
MAX_FEED_OVERRIDE = 1.2
MIN_SPINDLE_OVERRIDE = 0.5
MAX_SPINDLE_OVERRIDE = 1.2
DEFAULT_LINEAR_VELOCITY = 10.00
MIN_LINEAR_VELOCITY = 0
MAX_LINEAR_VELOCITY = 100.00
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/omar/linuxcnc/nc_files
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm

[KINS]
JOINTS = 3
KINEMATICS = trivkins coordinates=XYZ

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
PROGRAM_EXTENSION = .nc,.tap G-Code File
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
BASE_PERIOD = 30000
SERVO_PERIOD = 1000000

[HAL]
HALFILE = closed-loop.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal

[TRAJ]
COORDINATES =  X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 10.00
MAX_LINEAR_VELOCITY = 100.00

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

[AXIS_X]
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
MIN_LIMIT = -0.001
MAX_LIMIT = 200.0

[JOINT_0]
TYPE = LINEAR
HOME = 0.0
MIN_LIMIT = -0.001
MAX_LIMIT = 200.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 80.0
FERROR = 1
MIN_FERROR = .25
HOME_OFFSET = 0.0

[AXIS_Y]
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
MIN_LIMIT = -0.001
MAX_LIMIT = 200.0

[JOINT_1]
TYPE = LINEAR
HOME = 0.0
MIN_LIMIT = -0.001
MAX_LIMIT = 200.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 80.0
FERROR = 1
MIN_FERROR = .25
HOME_OFFSET = 0.0

[AXIS_Z]
MAX_VELOCITY = 24.7395833333
MAX_ACCELERATION = 750.0
MIN_LIMIT = -100.0
MAX_LIMIT = 0.001

[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MIN_LIMIT = -100.0
MAX_LIMIT = 0.001
MAX_VELOCITY = 24.7395833333
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 1280.0
FERROR = 1
MIN_FERROR = .25
HOME_OFFSET = 0.0

 

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

More
15 Nov 2021 18:22 #226594 by gitin
It works for me, BASE PERIOD = 80000
The following user(s) said Thank You: PhilipME

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

More
15 Nov 2021 21:52 #226604 by d2inventory
Maybe use higher steplen and step dir?

try

setp stepgen.2.steplen 10000
setp stepgen.2.stepspace 10000
The following user(s) said Thank You: PhilipME

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

  • PhilipME
  • PhilipME's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
15 Nov 2021 23:12 #226608 by PhilipME

Maybe use higher steplen and step dir?

try

setp stepgen.2.steplen 10000
setp stepgen.2.stepspace 10000



 



right now the stepgen.2.steplen =1
you mean increase it from 1 to 10,000

execuse my lack of knowledge in this area.

Philip

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

More
15 Nov 2021 23:20 #226609 by d2inventory
yes, those values are in nanoseconds. if you have your driver specs you can look it up how long these times can be at minimum (better to go above a bit especially when you're just trying to get them to run)
The following user(s) said Thank You: PhilipME

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

  • PhilipME
  • PhilipME's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
16 Nov 2021 00:24 #226612 by PhilipME
I changed the

setp stepgen.2.steplen 10
setp stepgen.2.stepspace 10

The driver immediatly give me error

I also increased the BASE PERIOD = 80000 with no luck

I think, I may use this drive with another controler

This is cloudray motor and drive.

For people who have success with closed loop steppers, what drive you are using?


Many thanks for the help

Philip

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

More
16 Nov 2021 00:29 #226613 by d2inventory
don't use 10. 10 nanoseconds is extremely low, set it to 10000 or 20000 or something high like that.

also make sure you're doing it to the right stepgen don't just copy what I wrote. you have 3 steppers so you gotta do it for all 3 of them I just picked one at random as an example.

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
16 Nov 2021 00:41 #226614 by tommylight
If those steppers are working with GRBL, they will work with LinuxCNC.
First make sure the drive/motor still works OK with GRBL, if at all possible (i am sure i read somewhere wires being moved, not sure it was this topic and no time to read again), then if that works:
Lover the velocity
lover the acceleration (if the drives are faulting this would be the first thing to lower, when everything else is OK)
set the base period to at least 100000 while testing, after everything works you can lower this to the point of LinuxCNC complaining about latency errors then go back to last value with no warnings.
step time and step space should be set in the INI file, not in hal (pretty sure they are in periods in HAL, not in nanoseconds as in INI, long time since i used this)
The following user(s) said Thank You: shpatb, PhilipME

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

Time to create page: 0.078 seconds
Powered by Kunena Forum