Parallel port stepper control and etherCAT I/O

More
29 Oct 2022 19:30 #255399 by O.R
I made test configuration with Stepconf Wizard, modified the .HAL file and made by hand ethercat-conf.xml file. Now there is some problem when i try to start linuxcnc.

Here is error:
Error report created by /usr/lib/tcltk/linuxcnc/show_errors.tcl:

Print file information:
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/lib/linuxcnc/modules
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/lib/tcltk/linuxcnc/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.6
LINUXCNC - 2.8.4-1-gb7824717b
Machine configuration directory is '/home/sorvi/linuxcnc/configs/Lathe'
Machine configuration file is 'Lathe.ini'
INIFILE=/home/sorvi/linuxcnc/configs/Lathe/Lathe.ini
VERSION=1.1
PARAMETER_FILE=linuxcnc.var
TASK=milltask
HALUI=
DISPLAY=axis
COORDINATES=X Z
KINEMATICS=trivkins coordinates=XZ
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Found file(REL): ./Lathe.hal
Shutting down and cleaning up LinuxCNC...
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments

Debug file information:
Note: Using POSIX realtime
Failed to open /dev/EtherCAT0: Permission denied
LCEC: requesting master 0 (index 0) failed
lcec: rtapi_app_main: Invalid argument (-22)
./Lathe.hal:7: waitpid failed /usr/bin/rtapi_app lcec
./Lathe.hal:7: /usr/bin/rtapi_app exited without becoming ready
./Lathe.hal:7: insmod for lcec failed, returned -1
3358
Stopping realtime threads
Unloading hal components
Note: Using POSIX realtime



-----------------------------------------------------------------------
Info report created by linuxcnc_info:
The file:    /tmp/linuxcnc_info.txt
can be posted to a forum or a web site like:
     http://pastebin.com
in order to provide information about the linuxcnc
system and configuration.

                Date: Sat 29 Oct 22:23:43 EEST 2022
            UTC Date: Sat 29 Oct 19:23:43 UTC 2022
        this program: /usr/bin/linuxcnc_info
              uptime: 22:23:43 up 2:52, 1 user, load average: 0.68, 0.72, 0.64
     lsb_release -sa: Debian Debian GNU/Linux 10 (buster) 10 buster
      which linuxcnc: /usr/bin/linuxcnc
                 pwd: /home/sorvi/linuxcnc/configs/Lathe
                USER: sorvi
             LOGNAME: sorvi
                HOME: /home/sorvi
              EDITOR:
              VISUAL:
            LANGUAGE: en_GB:en
                TERM: dumb
           COLORTERM:
             DISPLAY: :0.0
             DESKTOP: lightdm-xsession
        display size: 1280x1024 pixels (338x270 millimeters)
                PATH: /usr/bin:/home/sorvi/linuxcnc/configs/Lathe/bin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

uname items:
         nodename -n: debian
      kernel-name -s: Linux
      kernel-vers -v: #1 SMP PREEMPT RT Debian 4.19.249-2 (2022-06-30)
          machine -m: x86_64
        processor -p: unknown
         platform -i: unknown
      oper system -o: GNU/Linux

/proc items:
             cmdline: BOOT_IMAGE=/boot/vmlinuz-4.19.0-21-rt-amd64 root=UUID=f9777791-97e7-4eba-bfb6-7699707f4799 ro initrd=/install/gtk/initrd.gz quiet
          model name: Intel(R) Atom(TM) CPU 330 @ 1.60GHz
               cores: 2
             cpu MHz: 1595.960
             parport: 0000-0000 : parport0 0000-0000 : parport0
              serial:

Versions:
                 gcc: gcc (Debian 8.3.0-6) 8.3.0
              python: Python 2.7.16
                 git: git version 2.20.1
          git commit: NA
                 tcl: 8.6
                  tk: 8.6
               glade: not_in_PATH
          glade-gtk2: not_in_PATH

linuxcnc_var all:

     LINUXCNCVERSION: 2.8.4-1-gb7824717b
LINUXCNC_AUX_GLADEVCP: /usr/share/linuxcnc/aux_gladevcp
LINUXCNC_AUX_EXAMPLES: /usr/share/linuxcnc/aux_examples
            REALTIME: /etc/init.d/realtime
                 RTS: uspace
          HALLIB_DIR: /usr/share/linuxcnc/hallib

dpkg -l '*linuxcnc*':
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version              Architecture Description
+++-===================-====================-============-=====================================================================
un  linuxcnc            <none>               <none>       (no description available)
un  linuxcnc-dev        <none>               <none>       (no description available)
un  linuxcnc-doc        <none>               <none>       (no description available)
ii  linuxcnc-doc-en     1:2.8.4.1.gb7824717b all          motion controller for CNC machines and robots (English documentation)
ii  linuxcnc-doc-es     1:2.8.4.1.gb7824717b all          controlador de movimiento para máquinas CNC y robots (Español).
ii  linuxcnc-doc-fr     1:2.8.4.1.gb7824717b all          motion controller for CNC machines and robots (French documentation)
un  linuxcnc-sim        <none>               <none>       (no description available)
un  linuxcnc-sim-dev    <none>               <none>       (no description available)
ii  linuxcnc-uspace     1:2.8.4.1.gb7824717b amd64        motion controller for CNC machines and robots
ii  linuxcnc-uspace-dev 1:2.8.4.1.gb7824717b amd64        PC based motion controller for real-time Linux

Here is my HAL file:
# Generated by stepconf 1.1 at Sat Oct 29 20:03:48 2022
# 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
loadusr -W lcec_conf /home/sorvi/Desktop/Lathe/ethercat-conf.xml
loadrt lcec
loadrt hal_parport cfg="0 out"
setp parport.0.reset-time 5000
loadrt stepgen step_type=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 lcec.read-all 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 lcec.write-all servo-thread

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 xstep           => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir            => parport.0.pin-03-out
net zstep           => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net zdir            => parport.0.pin-07-out

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

Here is my .XML file
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="EK1100"/>
<slave idx="1" type="EL2004"/>    
<slave idx="2" type="EL1004"/>
<slave idx="3" type="EL1124"/>
</master>
</masters>

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

More
29 Oct 2022 21:42 #255407 by rodw
Failed to open /dev/EtherCAT0: Permission denied

You missed the last steps in the sticky. Do everything at the end where it says
To ensure the ethercat port has permissions on startup. Create a udev rule
 

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

More
30 Oct 2022 13:59 #255437 by O.R
Now there is permission for eth0 and Linuxcnc starts. Linuxcnc shows notifiaction "LCEC: Invalid appTimePeriod of 1000000 for master 0 (should be 1048000)." I tought 1000000 is more than enough, should i rise Servo period or is there some other problem?

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

More
30 Oct 2022 15:07 #255442 by tommylight

Now there is permission for eth0 and Linuxcnc starts. Linuxcnc shows notifiaction "LCEC: Invalid appTimePeriod of 1000000 for master 0 (should be 1048000)." I tought 1000000 is more than enough, should i rise Servo period or is there some other problem?

It is telling you exactly what it should be, 1048000.
Although not sure if that is regarding the LinuxCNC or the ethercat master, but it is easier to set it in the ini file for LinuxCNC and give it a try.
it is named
servo_period under the [EMCMOT] section.

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

More
30 Oct 2022 16:57 #255460 by db1981
the apptimeperiod in the ethercat_conf.xml file has to match the Servo Period from the INI file.
The following user(s) said Thank You: tommylight

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

More
30 Oct 2022 20:02 #255481 by O.R
I changed apptimeperiod and Servo Period to 1048000 and no error messages. I made simply HAL configuration led blink test with EL1004 and it seems to work. 

Is there some kind of pulse counter in LinuxCNC for encoder testing, i thought i will next test the EL1124 if it could handle my linear encoder. I thought i would compare pulse counts in different axis speeds and see if there is any pulse count difference in same movement distance.

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

More
30 Oct 2022 20:27 #255484 by db1981
oh..

counting encoders or linear scales with digital inputs will not work.
For this usecase the ec system is not designed.
You will need an counter in hardware like EL5101 or EL5152 etc..
Counting with D Inputs is to slow for this. The Ethercat cycle time is ~ 1ms/ 1 khz.
This means that you only will get new data in 1ms steps. For an encoder with an physical resolution of 0.005 , this will in best case allow an max speed of 5 per second.
But to get this, the high level has to be present at the right position in the 1ms cylce (when input data is read out) and has to be long enought to get recognized...
Additional an normal Input like el1124 etc. has no distributed clocks, caused by this them are useless for interpolation, because the readout is not at the same position in time....

Normaly an hardware counter (EL5xxx / par port) runs at >= 100 khz, to be able to count all pulses.
The following user(s) said Thank You: CORBETT

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

More
30 Oct 2022 21:14 #255490 by O.R
Ok, CORBETT mentioned that " Another user here on the forum named Dan (sqmathlete) has gotten the EL1124's to work with an encoder. " so that's why thought i could also try EL1124 for encoder.

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

More
30 Oct 2022 23:57 - 31 Oct 2022 00:02 #255522 by CORBETT
db1981
Dominik, you're the Man... Always glad to see you here    I have more questions for you in the future, just too busy tonight.

O.R
Dominik is 100% correct about the hardware encoding and using the EL5xxx terminals, but you can add the "encoder" component to LCNC in HAL for "software" encoding.

You are keeping your existing stepper setup with the base-thread.  Simply add the "Encoder" component to LCNC and tie the EL1124 pins to the "encoder" pins in LCNC.  Like I said before this is way slower than using the EL5151, as this way is "software" encoding rather than "hardware" encoding like Dominik was explaining.
I am busy working but will check back at some point.  Dominik or Tom will be able to explain the encoder component that you need to add in your HAL file if I am not back in time.
*EDIT*
I forgot to add that Dan would have had to do it this way, there is no other way than using the "encoder" component while using a EL1124 that I could think of. 


ROD WEBSTER
Rod if you see this, since last night I have built 8 complete systems without fail.  Super quick to do even compared to EC-Debianize way.  I still get tripped up not doing a "sudo update-ethercat-config".
Last edit: 31 Oct 2022 00:02 by CORBETT.

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

More
01 Nov 2022 00:54 #255628 by CORBETT
O.R
I went back and re-read Dominiks post and yeah, he is right about the speed for digital input, which that is what I had mentioned in the beginning.  I knew you would only get slow speed at best as it was my problem, and why I got the EL5151 problem worked out eventually.  You can still try the LCNC software component way to see if it will even work, but you are going to be stuck with getting a EL5151 or 5101 for each axis in the long run.

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

Time to create page: 0.277 seconds
Powered by Kunena Forum