1

Question

Is it possible to achieve reasonable real-time with RaspberryPi (ideally jitter < 50us, or in the worse case 150us )

If yes, how to achieve those values, targeting LinuxCNC?

After all the steps found bellow, I have the impression LinuxCNC is NOT running in real-time mode, because the jitter does not seem upper bound.

Purpose:

To create a linux image with LinuxCNC which could be built-in small milling CNCs.

What has been tried up to now:

  1. The first step where to get a fresh and easy to install Raspian image from the official page.

  2. After, a RT_PREEMPT kernel where cross-compiled and installed over Raspbian following this tutorial

  3. Freezing issues where solved by adding sdhci_bcm2708.enable_llm=0 dwc_otg.fiq_fsm_enable=0 dwc_otg.fiq_enable=0 dwc_otg.nak_holdoff=0 (in this precise order) to /boot/cmdline.txt

  4. LinuxCNC where compiled over the RaspberryPi using the standard procedure found here:

    1. git clone git://github.com/linuxcnc/linuxcnc.git linuxcnc-dev
    2. sudo apt-get install dpkg-dev
    3. dpkg-checkbuilddeps
    4. sudo apt-get install
    5. sudo apt-get install bwidget libtk-img tclx
    6. cd src
    7. ./configure --qith-realtime=uspace | tee ../configure.log
    8. make | tee ../make.log
    9. sudo make setuid | tee ../makesetuid.log
    10. source ../scripts/rip-environment
    11. runtests | tee ../tests.log

Running stepconf provides a Jitter test (second page) which give quite poor results:

Average servo thread jitter is around 140us

Maximum servo thread jitter is around to 0.5ms

The Raspbian version after installing the kernel patch is:

Linux raspberrypi 4.9.50-rt37-v7+ #2 SMP PREEMPT RT Wed Sep 20 21:44:16 CEST 2017 armv7l GNU/Linux

Additional data

Configure log

checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking boost/lockfree/queue.hpp usability... yes
checking boost/lockfree/queue.hpp presence... yes
checking for boost/lockfree/queue.hpp... yes
checking whether g++ supports C++11 features by default... yes
checking build toplevel... /home/pi/linuxcnc-dev
checking installation prefix... run in place
checking for grep... (cached) /bin/grep
checking for egrep... (cached) /bin/grep -E
checking for pkg-config... /usr/bin/pkg-config
checking for rtai-config... none
checking for xeno-config... none
checking for realtime API(s) to use... uspace
checking whether to enable userspace PCI access... yes
checking for libudev... yes - version 232
checking for cc version... not specified
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for usability of linux/hidraw.h... yes
checking for libmodbus3... yes - version 3.0.6
checking for libusb-1.0... yes
checking for module installation directory... configuring for run-in-place
/home/pi/linuxcnc-dev/rtlib
checking for glib... yes - 2.50.3
checking for GTK 2.4.0 or above... yes - 2.24.31
checking for libgnomeprintui-2.2... no -- printing from classicladder will not be possible
checking whether make sets $(MAKE)... yes
checking for ranlib... ranlib
checking for ar... /usr/bin/ar
checking for install... /usr/bin/install
checking for sed... /bin/sed
checking for ps... /bin/ps
checking for kill... /bin/kill
checking for whoami... /usr/bin/whoami
checking for awk... /usr/bin/awk
checking for insmod... /sbin/insmod
checking for rmmod... /sbin/rmmod
checking for lsmod... /sbin/lsmod
checking for pidof... /bin/pidof
checking for ipcs... /usr/bin/ipcs
checking for fuser... /bin/fuser
checking for mandb... /usr/bin/mandb
checking for python... /usr/bin/python
checking whether to build documentation... no
checking sys/io.h usability... yes
checking sys/io.h presence... yes
checking for sys/io.h... yes
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for semtimedop... yes
checking for sincos function... yes
checking for __sincos... no
checking for optreset... no
checking for library containing dlopen... -ldl
checking for library containing clock_nanosleep... none required
checking for tcl... /usr/lib/tcl8.6/tclConfig.sh found
checking for tk... /usr/lib/tk8.6/tkConfig.sh found
checking whether to check for runtime dependencies... yes
checking for BWidget using /usr/bin/tclsh8.6... found
checking for BLT using tclsh8.5... not found
checking for img::png using /usr/bin/tclsh8.6... found
checking for tclX using /usr/bin/tclsh8.6... found
checking for python pango and cairo modules... found
checking for X... libraries , headers 
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking X11/extensions/Xinerama.h usability... yes
checking X11/extensions/Xinerama.h presence... yes
checking for X11/extensions/Xinerama.h... yes
checking for XineramaQueryExtension in -lXinerama... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
Trying readline without -ltermcap
checking for readline in -lreadline... yes
Trying readline with -ltermcap
checking for readline in -lreadline... yes
Readline does not require -ltermcap
checking whether readline license is compatible with GPL-2... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for setlocale... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking for gettext in -lintl... no
checking for xgettext... /usr/bin/xgettext
checking for msgfmt... /usr/bin/msgfmt
checking python version... OK
checking version of python libraries... python2.7
checking match between tk and Tkinter versions... 8.6
checking location of Python header files... /usr/include/python2.7
checking for Python headers... -I/usr/include/python2.7
checking for Python libraries... -lpthread -ldl  -lutil
checking whether the Boost::Python headers are available... yes
checking for boost::python shared library... -lboost_python
checking /usr/include/python2.7/Python.h usability... yes
checking /usr/include/python2.7/Python.h presence... yes
checking for /usr/include/python2.7/Python.h... yes
checking for site-package location... /usr/lib/python2.7/dist-packages
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glBegin in -lGL... yes
checking for working GLU quadrics... yes
checking for Xmu headers... checking X11/Xmu/Xmu.h usability... yes
checking X11/Xmu/Xmu.h presence... yes
checking for X11/Xmu/Xmu.h... yes
configure: creating ./config.status
config.status: creating ../scripts/rtapi.conf
config.status: creating ../scripts/linuxcnc
config.status: creating ../scripts/halrun
config.status: creating ../scripts/rip-environment
config.status: creating ../scripts/haltcl
config.status: creating ../scripts/halcmd_twopass
config.status: creating ../scripts/realtime
config.status: creating ../scripts/linuxcnc_var
config.status: creating Makefile.inc
config.status: creating Makefile.modinc
config.status: creating ../tcl/linuxcnc.tcl
config.status: creating ../lib/python/nf.py
config.status: creating ../scripts/linuxcncmkdesktop
config.status: creating ../share/applications/linuxcnc-latency.desktop
config.status: creating ../share/applications/linuxcnc.desktop
config.status: creating ../share/desktop-directories/cnc.directory
config.status: creating ../share/menus/CNC.menu
config.status: creating config.h
config.status: config.h is unchanged


######################################################################
#                LinuxCNC - Enhanced Machine Controller              #
######################################################################
#                                                                    #
#   LinuxCNC is a software system for computer control of machine    #
#   tools such as milling machines. LinuxCNC is released under the   #
#   GPL.  Check out http://www.linuxcnc.org/ for more details.       #
#                                                                    #
#                                                                    #
#   It seems that ./configure completed successfully.                #
#   This means that RT is properly installed                         #
#   If things don't work check config.log for errors & warnings      #
#                                                                    #
#   Next compile by typing                                           #
#         make                                                       #
#         sudo make setuid                                           #
#          (if realtime behavior and hardware access are required)   #
#                                                                    #
#   Before running the software, set the environment:                #
#         . (top dir)/scripts/rip-environment                        #
#                                                                    #
#   To run the software type                                         #
#         linuxcnc                                                   #
#                                                                    #
######################################################################
  • Have you looked at machinekit.io ? might be what you are looking for prebuilt. – tobyd Oct 7 '17 at 19:03
  • Not saying it is not interesting, but I don't think it relate to my problem. Thanks in any case. – Adrian Maire Oct 7 '17 at 19:08
  • Even using their supplied prempt RT kernel? Seems they have already done a lot of what you'd be looking to do with a Pi based CNC controller and have a ready to go kernel saving you all that cross compiling and woe. machinekit.io/docs/getting-started/installing-packages part five details pi2 setup. – tobyd Oct 7 '17 at 19:16
  • Even with the real-time kernel, people are only getting 10k steps/sec with LinuxCNC on the RPi. That results in really slow motor speeds. Check out the Buildbotics CNC Controller. It's Open-Source and get's up to 250k steps/sec with no special tweaking. See buildbotics.com Disclaimer, It's my project. – jcoffland Dec 31 '18 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.