jam1
Posts: 47
Joined: Tue Oct 21, 2014 5:51 pm

Re: LinuxCNC

Tue Oct 06, 2015 7:51 pm

This is my latest ini file

Code: Select all

[EMC]
MACHINE = my-micro_step-mill
DEBUG = 0

[DISPLAY]
DISPLAY = axis
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 = 2.50
MIN_LINEAR_VELOCITY = 0
MAX_LINEAR_VELOCITY = 25.00
INTRO_GRAPHIC = machinekit.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/pi/linuxcnc/nc_files
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm

[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
COMM_WAIT = 0.010
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000

[HAL]
HALFILE = my-micro_step-mill.hal
HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal

[TRAJ]
AXES = 3
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 2.50
MAX_VELOCITY = 25.00

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

[AXIS_0]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 320.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -100.0
MAX_LIMIT = 100.0
HOME_OFFSET = 0.0

[AXIS_1]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 320.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -100.0
MAX_LIMIT = 100.0
HOME_OFFSET = 0.0

[AXIS_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 750.0
STEPGEN_MAXACCEL = 937.5
SCALE = 320.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -100.0
MAX_LIMIT = 100.0
HOME_OFFSET = 0.0
This run flawlessly for the file 3DChips.ngc. I can see the motor shafts turning according to the plan. Very smooth and very fast. Very happy.

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Wed Oct 07, 2015 4:50 am

jam1 wrote: sudo cp /home/pi/linuxcnc/nc_files/examples/3D_Chips.ngc /usr/share/axis/images/axis.ngc
Here's the proper way:

Code: Select all

AXIS_OPEN_FILE=/home/pi/linuxcnc/nc_files/examples/3D_Chips.ngc machinekit -d -V my-mill.ini
42

Astro02
Posts: 20
Joined: Mon Oct 05, 2015 2:59 pm

Re: LinuxCNC

Wed Oct 07, 2015 5:23 am

ok; there is a breadboard version of picnc v2 for polulu?
if i want make a pbc i need smd resistor?
can anyome make a list of all pieces for picnc polulu, please?
edit:can i use the unl2003 to convert a five wire stepper to a 4 wire stepper

jam1
Posts: 47
Joined: Tue Oct 21, 2014 5:51 pm

Re: LinuxCNC

Wed Oct 07, 2015 8:04 pm

I increased the base period and all displays are playing nice but I still cannot load a new file in "axis". The problem is around the function emcTaskPlanOpen() . I can load and run a new file with other displays.

picadilly
Posts: 12
Joined: Tue Apr 28, 2015 1:28 am

Re: LinuxCNC

Mon Nov 09, 2015 5:43 am

Hi kinsa,

you might recall I posted some stuff about wanting to design an expanded version of the PicNC board that would support also input from an encoder wheel and buttons and that could control the power up/down process a while back. The goal is to build a small, self contained box to control a machine, that does not require a keyboard or mouse. Something more in line with a dirty shop environment.

Well, I designed the board and wrote the code to handle an encoder wheel and to process a key matrix. For convenience I used the same processor, so there are two PIC32MX150F128B's on the board.
PCB2.jpg
PicNC with power control, encoder input and key matrix scanning
PCB2.jpg (57.42 KiB) Viewed 6180 times
Then I got side tracked, which was partially due to some hardware I had hoped for not being available (the official Pi Touch screen). Anyway I got an actual touch screen in hand now and started to work on integrating machinekit and picnc in earnest. The touchscreen works beautifully, but there is a problem. Once the real time kernel is installed the screen still works, but there is no touch response. So, I guess the code to handle that is part of the kernel and thus gets removed when the kernel is replaced. Assuming you have some experience with that environment, do you have any ideas how this problem might be approached or who might be able o help?

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Mon Nov 09, 2015 7:18 am

Is the touch controller using the usb interface?
42

picadilly
Posts: 12
Joined: Tue Apr 28, 2015 1:28 am

Re: LinuxCNC

Mon Nov 09, 2015 2:08 pm

No, it's the official Raspberry Pi touch screen. It uses the special display port on the Pi (the only display to do so). That handles the display output as well as the touch screen input. Really sweet. It will only work with the latest Raspberian OS though. Even if you download the latest image, you have to run an upgrade. This was important to me, because the design target I had did not allow for a normal HDMI screen. All third party touch screens on the market for the Pi use the SPI port, but that does not work because it's needed for the stepper interface. BTW, the encoder interface uses the serial port, so the picnc implementation is not touched at all.

Sounds like you are as much at a loss as I am at the moment. I would hope there was no fundamental re-engineering going on to the OS, but just additional hardware driver work, with hopefully the possibility of the binaries being movable to the real time OS. But I wouldn't even know where to begin looking for this stuff, since I am not a Linux hot shot. There was an obvious struggle for the foundation to get this display out, so I assume their resources are quite limited. As far as I can tell there is still software work going on to get all the targeted functionality. Given that, I have little hope for support form them on an issue like this, that affects a rather small community.

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Mon Nov 09, 2015 2:46 pm

Are you using RPi 1 or 2?
42

picadilly
Posts: 12
Joined: Tue Apr 28, 2015 1:28 am

Re: LinuxCNC

Mon Nov 09, 2015 3:16 pm

I am using a Pi 2. The ribbon cable connection is designed around that GPIO header.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: LinuxCNC

Mon Nov 09, 2015 4:35 pm

picadilly wrote: The touchscreen works beautifully, but there is a problem. Once the real time kernel is installed the screen still works, but there is no touch response. So, I guess the code to handle that is part of the kernel and thus gets removed when the kernel is replaced.
I guess your real time Kernel isn't using the latest raspian kernel source, have you recompiled it from the latest updated version?

This is obviously easier to type than it is to do, I think these instructions on building your own kernel should help you to recompile.
There may be an option for the display touchscreen that you haven't selected so won't be compiled into the new kernel, if that is the case then ask in the display forum and I'm sure someone will be able to point you to the answer.
Doug.
Building Management Systems Engineer.

picadilly
Posts: 12
Joined: Tue Apr 28, 2015 1:28 am

Re: LinuxCNC

Mon Nov 09, 2015 4:59 pm

Doug,

thanks, this is good information. This is based on the xemonai kernel. I'll dig into that when I get home tonight. As I wrote, I am not that experienced with Linux and will have to fight my way through this.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: LinuxCNC

Tue Nov 10, 2015 9:02 am

picadilly wrote:Doug,

thanks, this is good information. This is based on the xemonai kernel. I'll dig into that when I get home tonight. As I wrote, I am not that experienced with Linux and will have to fight my way through this.
You are welcome, I hope I have pointed you in the right direction.

I've never built a kernel myself (it's a bit more in-depth than I've needed to go yet) but it seemed to me that if the kernel was the issue then you should probably be able to fix it by rebuilding the kernel with the correct selections.
Doug.
Building Management Systems Engineer.

topmike
Posts: 4
Joined: Thu Nov 26, 2015 1:42 am

Re: LinuxCNC

Thu Nov 26, 2015 2:56 am

Dear Kinsa,
Your work is so great.

I am a newbie with linuxcnc. I am trying to port it on my RPI1.
My 1st try with https://github.com/kinsamanka/PICnc-V2/ ... Machinekit
I built a PIC board and download the code as your github, then connected to RPI through SPI interface.
However, could you pls help me to clear these problems?
1. I don't know where the signals RDY and RQT (request) connect to RPI. I saw in the old picnc source code, it does not have this connection. I wonder that we are using DMA in PIC, so can we replace RQ signal with DMA interrupt?

2. I do not know how can I start to run the linuxcnc and test the board is working fine or not!
(such as "what command should I run at first to confirm the system running well, and the sequence of commands to run a linuxcnc machine?). Do you have any guide from the beginning?

3. Is there any way to do a simulation to test linuxcnc first before applying with real PICNC board? I saw some configuration files for parallel port, it not relates to the spi interface, that i can output and measure directly from RPI pinout by using oscilloscope.

4. I would like to port "miniEMC2 web interface", I don't know in this minimal raspbian image at http://0ptr.link/files/, you're already integrated this interface or not. If not, can you give/show me the guide to integrated it in the current image?

I am looking forward to hearing from you soon.

Thank you so much!

P/s: My email is meanoflife9 (a) g ma il. c om. Thanks!

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Fri Nov 27, 2015 12:19 am

Hi,

I think what you have is the old picnic version. There's a v2 here: https://github.com/kinsamanka/PICnc-V2/wiki

The miniEMC2 web interface is already part of machinekit. If you first run machinekit, you'll see it under the sim configuration.

You can use the minimal image hosted on 0ptr.link if you want to try the machinekit interface. You can run it without the picnc board connected.

Cheers.
42

topmike
Posts: 4
Joined: Thu Nov 26, 2015 1:42 am

Re: LinuxCNC

Sat Nov 28, 2015 4:12 am

kinsa wrote:Hi,

I think what you have is the old picnic version. There's a v2 here: https://github.com/kinsamanka/PICnc-V2/wiki

The miniEMC2 web interface is already part of machinekit. If you first run machinekit, you'll see it under the sim configuration.

You can use the minimal image hosted on 0ptr.link if you want to try the machinekit interface. You can run it without the picnc board connected.
Cheers.
Hi Kinsa,
Thank you for your guide.
I am trying the minimal image in your link ( picnc=v2). This image runs well on RPI. However, When I am trying to run linuxcnc, it seems to be failed something in rtapi:
+ If I try with console:

Code: Select all

[email protected]:/# linuxcnc usr/share/linuxcnc/examples/sample-configs/sim/emcweb.ini
----> Error's occurred like this,
MACHINEKIT - 0.1
Machine configuration directory is '//usr/share/linuxcnc/examples/sample-configs/sim'
Machine configuration file is 'emcweb.ini'
Starting Machinekit...
/usr/libexec/linuxcnc/rtapi_msgd: FATAL - will not run as root
rtapi_msgd startup failed - aborting
rtapi_app startup failed - aborting
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log
io started
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log
halcmd loadusr io started
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log
Shutting down and cleaning up Machinekit...
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log

......

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log
Cleanup done
Machinekit terminated with an error.  You can find more information in the log:
    /root/linuxcnc_debug.txt
and
    /root/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal
+ I also tried with "startx" and then run the linuxcnc from start menu, and choose emcweb in SIM list.
---> Similar error occurred

Code: Select all

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
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/share/linuxcnc/tcl/msgs
INIVAR=/usr/libexec/linuxcnc/inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.5
MACHINEKIT - 0.1
Machine configuration directory is '/usr/share/linuxcnc/examples/sample-configs/sim/axis'
Machine configuration file is 'axis.ini'
INIFILE=/usr/share/linuxcnc/examples/sample-configs/sim/axis/axis.ini
PARAMETER_FILE=sim.var
TASK=milltask
HALUI=halui
DISPLAY=axis
Starting Machinekit...
Starting Machinekit server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
rtapi_msgd startup failed - aborting
rtapi_app startup failed - aborting
Starting Machinekit IO program: io
io started
halcmd loadusr io started
Starting HAL User Interface program: halui
Shutting down and cleaning up Machinekit...
Killing task linuxcncsvr, PID=3886
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments
Cleanup done

Debug file information:
/usr/libexec/linuxcnc/rtapi_msgd: FATAL - will not run as root
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout

halcmd: the rtapi:0 RT demon is not running - please investigate /var/log/linuxcnc.log
halcmd: the msgd:0 logger demon is not running - please investigate /var/log/linuxcnc.log
halcmd: cant connect to rtapi_app: -1 (uri= uuid=a42c8c6b-4025-4f83-ba28-dad21114744a): rtapi_rpc(): reply timeout
...
Could you give me your advice?

I try to run without external hardware first, it is easily for me to check how it works. Then check SPI signals with picnc HAL. I try to find the guiding steps from internet, but it seems nothing. Can you recommend for me some links that I should start?

Thank you!

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Sat Nov 28, 2015 4:26 am

It says right there in the error messages: "FATAL - will not run as root".

Log in as mk user and not as root.
42

topmike
Posts: 4
Joined: Thu Nov 26, 2015 1:42 am

Re: LinuxCNC

Wed Dec 09, 2015 10:03 am

Hi Kinsa,
Thank you for your comment.
Linuxcnc is working now with webemc2 interface. But it seems a little lag.

Now I am debugging the PIC32 firmware. I update to a new PIC CPU PIC32MZ2048ECG064-I/PT.
According to your experience, do you think that the freq of pulses in stepgen() will be higher? I want to get more than 150KHz of output pulses. I will increase the SPI speed and CPU performance.

Please give me your opinion.

Thank you~

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Thu Dec 10, 2015 3:31 am

Machinekit user interface on RPi1 is sluggish. You should upgrade to RPi2 to get better performance.

The processor of PICnc V2 runs at 40MHz and provides 40 kHz max stepgen frequency.

So theoretically a PIC32MZ2048ECG064 running at 200 MHz should provide at most 200 kHz.

But the only way to know is to test it ;-)

Cheers
42

topmike
Posts: 4
Joined: Thu Nov 26, 2015 1:42 am

Re: LinuxCNC

Fri Dec 11, 2015 5:57 am

Hi Kinsa,
I want to test with picnc HAL code. However, I can not find it in the pre-built image
http://0ptr.link/files/rpi-machinekit-1.0.img.bz2, following your help in https://github.com/kinsamanka/PICnc-V2/ ... Machinekit

This pre-built image also does not contain a machinekit-dev. So, I can not create a HAL file and compile using "comp" command.

So, I decide to install the machine-kit as following:

Code: Select all

sudo sh -c \
 "echo 'deb http://deb.dovetail-automata.com wheezy main' > \
 /etc/apt/sources.list.d/machinekit.list; \
 apt-get update ; \
 apt-get install dovetail-automata-keyring"
 apt-get update
Then

Code: Select all

sudo apt-get install machinekit-dev
However, after install this, I can not run the linuxcnc anymore. Even I try the latency-test --> Some things are wrong, I guess.

Code: Select all

latency-test
msgd:0 stopped
rtapi:0 stopped
/usr/bin/realtime: line 174:  1873 Illegal instruction     ${rtapi_msgd} --insta        nce=$INSTANCE $NAME_CMD --rtmsglevel=$DEBUG --usrmsglevel=$DEBUG --halsize=$HAL_        SIZE $MSGD_OPTS
rtapi_msgd startup failed - aborting
/usr/bin/realtime: line 174:  1875 Illegal instruction     ${rtapi_app} --instan        ce=$INSTANCE $RTAPI_APP_OPTS
rtapi_app startup failed - aborting
/usr/bin/realtime: line 174:  1877 Illegal instruction     halcmd ping
/usr/bin/halrun: line 148:  1878 Illegal instruction     halcmd [email protected]
/usr/bin/halrun: line 152:  1879 Illegal instruction     halcmd stop
/usr/bin/halrun: line 153:  1880 Illegal instruction     halcmd unload all
I don't know what happened. Do you have anyway to compile a new HAL driver with using the pre-built image? Please give me some helps.

Thank you,

kinsa
Posts: 457
Joined: Sat Dec 01, 2012 10:16 pm

Re: LinuxCNC

Fri Dec 11, 2015 6:41 am

Use my prebuilt image and run the following :

Code: Select all

sudo apt-get update 
sudo apt-get install machinekit-dev 
42

n9wxu
Posts: 6
Joined: Fri Dec 18, 2015 4:40 am

Re: LinuxCNC

Fri Dec 18, 2015 4:51 am

I just sent a pull request to the PICnc github.
The update increases the step rate to 138khz using 50% of the CPU. I have a new hardware board available at https://oshpark.com/shared_projects/xTIz9hC0.
There is a small mistake on the board but it is easily fixed. You must add a pullup resistor on the MCLR line.
I am running a DQ542MA at 138khz. The only strange thing I see are overshoots as I test with halrun. I am new to the tuning so undoubtedly this is fixable.

I do have a few comments.

1) What are the "position" units? The code reports the current position and only steps every thousand position units or so. This is a good way to ensure the velocity behaves in a linear manner, but it also seems to contribute to the overshoot.

2) My new HW was assuming I would use the OC peripheral to do hardware step generation but that conflicts with the PWM feature. Temporarily I have disabled PWM but I am not doing hardware step generation. The PWM can be put back as more reasonable pins are selected for the step/direction functions.

3) I provided pins for the driver enables. Currently, my stepper motors are at max holding current and are somewhere around 80C. I would like to disable the driver when the system is NOT in use. I have three ideas for this feature : A) use the SPI timeout to disable the drivers when SPI communications stops. B) use an explicit command (??) from machinekit to disable the drivers. C) disable the drivers when the position has not changed in a while. Suggestions please?

I have some PIC32MX470's that operate at 120Mhz so there is still room to increase the step rate.

Thanks for the good starting point. There is still lots of room for more features.

Wire
Posts: 78
Joined: Tue Sep 11, 2012 6:46 pm

Re: LinuxCNC

Fri Dec 18, 2015 1:59 pm

which processor and clock rate did you use on the 128kHz version?

n9wxu
Posts: 6
Joined: Fri Dec 18, 2015 4:40 am

Re: LinuxCNC

Fri Dec 18, 2015 2:48 pm

I used a PIC32MX440F512H at 80Mhz.
Any of the 80MHz MCU's would work as there are no dependencies upon special features. I simply refactored the stepgen code to improve performance and increased the stepgen frequency to maintain 50% CPU time for stepgen.

Wire
Posts: 78
Joined: Tue Sep 11, 2012 6:46 pm

Re: LinuxCNC

Fri Dec 18, 2015 3:27 pm

So with the new code a PIC32MX150F128D running at 40MHz should get about 69kHz max correct? Looks like yours is set up for 5 axis. If that is dropped to 3 or 4 can the step gen be speed up any more?

Will have to pick up your code and merge my changes in for my laser cutter boards. Unfortunately laid the cards out for the 44TQFP so cannot move past 50MHz since that is the fastest part in that package.

Still seems a little slow at ~580 clock cycles (145 instructions) per step. But guessing most of that is overhead taking care of the SPI interface?

n9wxu
Posts: 6
Joined: Fri Dec 18, 2015 4:40 am

Re: LinuxCNC

Fri Dec 18, 2015 5:57 pm

The SPI communications is all DMA driven. The DMA is managed in a DMA interrupt. The STEPGEN is in the core timer interrupt at a higher priority than the DMA interrupt.

I have not started modifying the channels because that will affect the HAL code and I have not started looking into that yet. This code is still operating with 4 channels.

Here is a screen capture from my logic analyzer.
picnc.png
Step generator timing at 80Mhz
picnc.png (58.08 KiB) Viewed 5034 times

At 80Mhz the total time for 4 step/dir generators is 3.5uS. I am still hopeful there are additional speedups.

Return to “Automation, sensing and robotics”