1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <rss version='
2.0' xmlns:lj='http://www.livejournal.org/rss/lj/
1.0/'
>
4 <title>Petter Reinholdtsen - Entries tagged linuxcnc
</title>
5 <description>Entries tagged linuxcnc
</description>
6 <link>https://people.skolelinux.org/pere/blog/
</link>
10 <title>The
2024 LinuxCNC Norwegian developer gathering
</title>
11 <link>https://people.skolelinux.org/pere/blog/The_2024_LinuxCNC_Norwegian_developer_gathering.html
</link>
12 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/The_2024_LinuxCNC_Norwegian_developer_gathering.html
</guid>
13 <pubDate>Fri,
31 May
2024 07:
45:
00 +
0200</pubDate>
14 <description><p
><a href=
"https://linuxcnc.org/
">The LinuxCNC project
</a
> is still
15 going strong. And I believe this great software system for numerical control of
16 machines such as milling machines, lathes, plasma cutters, routers,
17 cutting machines, robots and hexapods, would do even better with more
18 in-person developer gatherings, so we plan to organise such gathering
19 this summer too.
</p
>
21 <p
>The Norwegian LinuxCNC developer gathering take place the weekend
22 Friday July
5th to
7th this year, and is open for everyone interested
23 in contributing to LinuxCNC and free software manufacturing. Up to
24 date information about the gathering can be found in
25 <a href=
"https://sourceforge.net/p/emc/mailman/emc-developers/thread/
123eaae0-f3b9-
4170-a251-b7d608f1e974%
40bofh.no/
">the
26 developer mailing list thread
</a
> where the gathering was announced.
27 Thanks to the good people at
29 <a href=
"https://www.debian.org/
">Debian
</a
> as well as leftover money
30 from last years gathering from
31 <a href=
"https://www.redpill-linpro.com/
">Redpill-Linpro
</a
> and
32 <a href=
"https://www.nuugfoundation.no/no/
">NUUG Foundation
</a
>, we
33 have enough sponsor funds to pay for food, and probably also shelter
34 for the people traveling from afar to join us. If you would like to
35 join the gathering, get in touch and add your details on
36 <a href=
"https://pad.efn.no/p/linuxcnc-
2024-norway
">the pad
</a
>.
</p
>
38 <p
>As usual, if you use Bitcoin and want to show your support of my
39 activities, please send Bitcoin donations to my address
40 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
45 <title>The
2023 LinuxCNC Norwegian developer gathering
</title>
46 <link>https://people.skolelinux.org/pere/blog/The_2023_LinuxCNC_Norwegian_developer_gathering.html
</link>
47 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/The_2023_LinuxCNC_Norwegian_developer_gathering.html
</guid>
48 <pubDate>Sun,
14 May
2023 20:
30:
00 +
0200</pubDate>
49 <description><p
>The LinuxCNC project is making headway these days. A lot of
50 patches and issues have seen activity on
51 <a href=
"https://github.com/LinuxCNC/linuxcnc/
">the project github
52 pages
</a
> recently. A few weeks ago there was a developer gathering
53 over at the
<a href=
"https://tormach.com/
">Tormach
</a
> headquarter in
54 Wisconsin, and now we are planning a new gathering in Norway. If you
55 wonder what LinuxCNC is, lets quote Wikipedia:
</p
>
58 "LinuxCNC is a software system for numerical control of
59 machines such as milling machines, lathes, plasma cutters, routers,
60 cutting machines, robots and hexapods. It can control up to
9 axes or
61 joints of a CNC machine using G-code (RS-
274NGC) as input. It has
62 several GUIs suited to specific kinds of usage (touch screen,
63 interactive development).
"
66 <p
>The Norwegian developer gathering take place the weekend June
16th
67 to
18th this year, and is open for everyone interested in contributing
68 to LinuxCNC. Up to date information about the gathering can be found
70 <a href=
"https://sourceforge.net/p/emc/mailman/emc-developers/thread/sa64jp06nob.fsf%
40hjemme.reinholdtsen.name/#msg37837251
">the
71 developer mailing list thread
</a
> where the gathering was announced.
72 Thanks to the good people at
73 <a href=
"https://www.debian.org/
">Debian
</a
>,
74 <a href=
"https://www.redpill-linpro.com/
">Redpill-Linpro
</a
> and
75 <a href=
"https://www.nuugfoundation.no/no/
">NUUG Foundation
</a
>, we
76 have enough sponsor funds to pay for food, and shelter for the people
77 traveling from afar to join us. If you would like to join the
78 gathering, get in touch.
</p
>
80 <p
>As usual, if you use Bitcoin and want to show your support of my
81 activities, please send Bitcoin donations to my address
82 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
87 <title>LinuxCNC MQTT publisher component
</title>
88 <link>https://people.skolelinux.org/pere/blog/LinuxCNC_MQTT_publisher_component.html
</link>
89 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/LinuxCNC_MQTT_publisher_component.html
</guid>
90 <pubDate>Sun,
8 Jan
2023 19:
30:
00 +
0100</pubDate>
91 <description><p
>I watched
<a href=
"https://yewtu.be/watch?v=jmKUV3aNLjk
">a
2015
92 video from Andreas Schiffler
</a
> the other day, where he set up
93 <a href=
"https://linuxcnc.org/
">LinuxCNC
</a
> to send status
94 information to the MQTT broker IBM Bluemix. As I also use MQTT for
95 graphing, it occured to me that a generic MQTT LinuxCNC component
96 would be useful and I set out to implement it. Today I got the first
97 draft limping along and submitted as
98 <a href=
"https://github.com/LinuxCNC/linuxcnc/pull/
2253">a patch to the
99 LinuxCNC project
</a
>.
</p
>
101 <p
>The simple part was setting up the MQTT publishing code in Python.
102 I already have set up other parts submitting data to my Mosquito MQTT
103 broker, so I could reuse that code. Writing a LinuxCNC component in
104 Python as new to me, but using existing examples in the code
105 repository and the extensive documentation, this was fairly straight
106 forward. The hardest part was creating a automated test for the
107 component to ensure it was working. Testing it in a simulated
108 LinuxCNC machine proved very useful, as I discovered features I needed
109 that I had not thought of yet, and adjusted the code quite a bit to
110 make it easier to test without a operational MQTT broker
113 <p
>The draft is ready and working, but I am unsure which LinuxCNC HAL
114 pins I should collect and publish by default (in other words, the
115 default set of information pieces published), and how to get the
116 machine name from the LinuxCNC INI file. The latter is a minor
117 detail, but I expect it would be useful in a setup with several
118 machines available. I am hoping for feedback from the experienced
119 LinuxCNC developers and users, to make the component even better
120 before it can go into the mainland LinuxCNC code base.
</p
>
122 <p
>Since I started on the MQTT component, I came across
123 <a href=
"https://yewtu.be/watch?v=Bqa2grG0XtA
">another video from Kent
124 VanderVelden
</a
> where he combine LinuxCNC with a set of screen glasses
125 controlled by a Raspberry Pi, and it occured to me that it would
126 be useful for such use cases if LinuxCNC also provided a REST API for
127 querying its status. I hope to start on such component once the MQTT
128 component is working well.
</p
>
130 <p
>As usual, if you use Bitcoin and want to show your support of my
131 activities, please send Bitcoin donations to my address
132 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
137 <title>Automatic LinuxCNC servo PID tuning?
</title>
138 <link>https://people.skolelinux.org/pere/blog/Automatic_LinuxCNC_servo_PID_tuning_.html
</link>
139 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Automatic_LinuxCNC_servo_PID_tuning_.html
</guid>
140 <pubDate>Sat,
16 Jul
2022 22:
30:
00 +
0200</pubDate>
141 <description><p
>While working on a CNC with servo motors controlled by the
142 <a href=
"https://en.wikipedia.org/wiki/LinuxCNC
">LinuxCNC
</a
>
143 <a href=
"https://en.wikipedia.org/wiki/PID_controller
">PID
144 controller
</a
>, I recently had to learn how to tune the collection of values
145 that control such mathematical machinery that a PID controller is. It
146 proved to be a lot harder than I hoped, and I still have not succeeded
147 in getting the Z PID controller to successfully defy gravity, nor X
148 and Y to move accurately and reliably. But while climbing up this
149 rather steep learning curve, I discovered that some motor control
150 systems are able to tune their PID controllers. I got the impression
151 from the documentation that LinuxCNC were not. This proved to be not
154 <p
>The LinuxCNC
155 <a href=
"http://linuxcnc.org/docs/html/man/man9/pid
.9.html
">pid
156 component
</a
> is the recommended PID controller to use. It uses eight
157 constants
<tt
>Pgain
</tt
>,
<tt
>Igain
</tt
>,
<tt
>Dgain
</tt
>,
158 <tt
>bias
</tt
>,
<tt
>FF0
</tt
>,
<tt
>FF1
</tt
>,
<tt
>FF2
</tt
> and
159 <tt
>FF3
</tt
> to calculate the output value based on current and wanted
160 state, and all of these need to have a sensible value for the
161 controller to behave properly. Note, there are even more values
162 involved, theser are just the most important ones. In my case I need
163 the X, Y and Z axes to follow the requested path with little error.
164 This has proved quite a challenge for someone who have never tuned a
165 PID controller before, but there is at least some help to be found.
167 <p
>I discovered that included in LinuxCNC was this old PID component
168 at_pid claiming to have auto tuning capabilities. Sadly it had been
169 neglected since
2011, and could not be used as a plug in replacement
170 for the default pid component. One would have to rewriting the
171 LinuxCNC HAL setup to test at_pid. This was rather sad, when I wanted
172 to quickly test auto tuning to see if it did a better job than me at
173 figuring out good P, I and D values to use.
</p
>
175 <p
>I decided to have a look if the situation could be improved. This
176 involved trying to understand the code and history of the pid and
177 at_pid components. Apparently they had a common ancestor, as code
178 structure, comments and variable names were quite close to each other.
179 Sadly this was not reflected in the git history, making it hard to
180 figure out what really happened. My guess is that the author of
181 <a href=
"https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/components/at_pid.c
">at_pid.c
</a
>
183 <a href=
"https://github.com/LinuxCNC/linuxcnc/blob/master/src/hal/components/pid.c
">pid.c
</a
>,
184 rewrote it to follow the structure he wished pid.c to have, then added
185 support for auto tuning and finally got it included into the LinuxCNC
186 repository. The restructuring and lack of early history made it
187 harder to figure out which part of the code were relevant to the auto
188 tuning, and which part of the code needed to be updated to work the
189 same way as the current pid.c implementation. I started by trying to
190 isolate relevant changes in pid.c, and applying them to at_pid.c. My
191 aim was to make sure the at_pid component could replace the pid
192 component with a simple change in the HAL setup loadrt line, without
193 having to
"rewire
" the rest of the HAL configuration. After a few
194 hours following this approach, I had learned quite a lot about the
195 code structure of both components, while concluding I was heading down
196 the wrong rabbit hole, and should get back to the surface and find a
197 different path.
</p
>
199 <p
>For the second attempt, I decided to throw away all the PID control
200 related part of the original at_pid.c, and instead isolate and lift
201 the auto tuning part of the code and inject it into a copy of pid.c.
202 This ensured compatibility with the current pid component, while
203 adding auto tuning as a run time option. To make it easier to identify
204 the relevant parts in the future, I wrapped all the auto tuning code
205 with
'#ifdef AUTO_TUNER
'. The end result behave just like the current
206 pid component by default, as that part of the code is identical. The
207 <a href=
"https://github.com/LinuxCNC/linuxcnc/pull/
1820">end result
208 entered the LinuxCNC master branch
</a
> a few days ago.
</p
>
210 <p
>To enable auto tuning, one need to set a few HAL pins in the PID
211 component. The most important ones are
<tt
>tune-effort
</tt
>,
212 <tt
>tune-mode
</tt
> and
<tt
>tune-start
</tt
>. But lets take a step
213 back, and see what the auto tuning code will do. I do not know the
214 mathematical foundation of the at_pid algorithm, but from observation
215 I can tell that the algorithm will, when enabled, produce a square
216 wave pattern centered around the
<tt
>bias
</tt
> value on the output pin
217 of the PID controller. This can be seen using the HAL Scope provided
218 by LinuxCNC. In my case, this is translated into voltage (+-
10V) sent
219 to the motor controller, which in turn is translated into motor speed.
220 So at_pid will ask the motor to move the axis back and forth. The
221 number of cycles in the pattern is controlled by the
222 <tt
>tune-cycles
</tt
> pin, and the extremes of the wave pattern is
223 controlled by the
<tt
>tune-effort
</tt
> pin. Of course, trying to
224 change the direction of a physical object instantly (as in going
225 directly from a positive voltage to the equivalent negative voltage)
226 do not change velocity instantly, and it take some time for the object
227 to slow down and move in the opposite direction. This result in a
228 more smooth movement wave form, as the axis in question were vibrating
229 back and forth. When the axis reached the target speed in the
230 opposing direction, the auto tuner change direction again. After
231 several of these changes, the average time delay between the
'peaks
'
232 and
'valleys
' of this movement graph is then used to calculate
233 proposed values for Pgain, Igain and Dgain, and insert them into the
234 HAL model to use by the pid controller. The auto tuned settings are
235 not great, but htye work a lot better than the values I had been able
236 to cook up on my own, at least for the horizontal X and Y axis. But I
237 had to use very small
<tt
>tune-effort
<tt
> values, as my motor
238 controllers error out if the voltage change too quickly. I
've been
239 less lucky with the Z axis, which is moving a heavy object up and
240 down, and seem to confuse the algorithm. The Z axis movement became a
241 lot better when I introduced a
<tt
>bias
</tt
> value to counter the
242 gravitational drag, but I will have to work a lot more on the Z axis
243 PID values.
</p
>
245 <p
>Armed with this knowledge, it is time to look at how to do the
246 tuning. Lets say the HAL configuration in question load the PID
247 component for X, Y and Z like this:
</p
>
249 <blockquote
><pre
>
250 loadrt pid names=pid.x,pid.y,pid.z
251 </pre
></blockquote
>
253 <p
>Armed with the new and improved at_pid component, the new line will
254 look like this:
</p
>
256 <blockquote
><pre
>
257 loadrt at_pid names=pid.x,pid.y,pid.z
258 </pre
></blockquote
>
260 <p
>The rest of the HAL setup can stay the same. This work because the
261 components are referenced by name. If the component had used count=
3
262 instead, all use of pid.# had to be changed to at_pid.#.
</p
>
264 <p
>To start tuning the X axis, move the axis to the middle of its
265 range, to make sure it do not hit anything when it start moving back
266 and forth. Next, set the
<tt
>tune-effort
</tt
> to a low number in the
267 output range. I used
0.1 as my initial value. Next, assign
1 to the
268 <tt
>tune-mode
</tt
> value. Note, this will disable the pid controlling
269 part and feed
0 to the output pin, which in my case initially caused a
270 lot of drift. In my case it proved to be a good idea with X and Y to
271 tune the motor driver to make sure
0 voltage stopped the motor
272 rotation. On the other hand, for the Z axis this proved to be a bad
273 idea, so it will depend on your setup. It might help to set the
274 <tt
>bias
</tt
> value to a output value that reduce or eliminate the
275 axis drift. Finally, after setting
<tt
>tune-mode
</tt
>, set
276 <tt
>tune-start
</tt
> to
1 to activate the auto tuning. If all go well,
277 your axis will vibrate for a few seconds and when it is done, new
278 values for Pgain, Igain and Dgain will be active. To test them,
279 change
<tt
>tune-mode
</tt
> back to
0. Note that this might cause the
280 machine to suddenly jerk as it bring the axis back to its commanded
281 position, which it might have drifted away from during tuning. To
282 summarize with some halcmd lines:
</p
>
284 <blockquote
><pre
>
285 setp pid.x.tune-effort
0.1
286 setp pid.x.tune-mode
1
287 setp pid.x.tune-start
1
288 # wait for the tuning to complete
289 setp pid.x.tune-mode
0
290 </pre
></blockquote
>
292 <p
>After doing this task quite a few times while trying to figure out
293 how to properly tune the PID controllers on the machine in, I decided
294 to figure out if this process could be automated, and wrote a script
295 to do the entire tuning process from power on. The end result will
296 ensure the machine is powered on and ready to run, home all axis if it
297 is not already done, check that the extra tuning pins are available,
298 move the axis to its mid point, run the auto tuning and re-enable the
299 pid controller when it is done. It can be run several times. Check
301 <a href=
"https://github.com/SebKuzminsky/MazakVQC1540/blob/bon-dev/scripts/run-auto-pid-tuner
">run-auto-pid-tuner
</a
>
302 script on github if you want to learn how it is done.
</p
>
304 <p
>My hope is that this little adventure can inspire someone who know
305 more about motor PID controller tuning can implement even better
306 algorithms for automatic PID tuning in LinuxCNC, making life easier
307 for both me and all the others that want to use LinuxCNC but lack the
308 in depth knowledge needed to tune PID controllers well.
</p
>
310 <p
>As usual, if you use Bitcoin and want to show your support of my
311 activities, please send Bitcoin donations to my address
312 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
317 <title>LinuxCNC translators life just got a bit easier
</title>
318 <link>https://people.skolelinux.org/pere/blog/LinuxCNC_translators_life_just_got_a_bit_easier.html
</link>
319 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/LinuxCNC_translators_life_just_got_a_bit_easier.html
</guid>
320 <pubDate>Fri,
3 Jun
2022 21:
10:
00 +
0200</pubDate>
321 <description><p
>Back in oktober last year, when I started looking at the
322 <a href=
"https://en.wikipedia.org/wiki/LinuxCNC
">LinuxCNC
</a
> system, I
323 proposed to change the documentation build system make life easier for
324 translators. The original system consisted of independently written
325 documentation files for each language, with no automated way to track
326 changes done in other translations and no help for the translators to
327 know how much was left to translated. By using
328 <a href=
"https://po4a.org/
">the po4a system
</a
> to generate POT and PO
329 files from the English documentation, this can be improved. A small
330 team of LinuxCNC contributors got together and today our labour
331 finally payed off. Since a few hours ago, it is now possible to
332 translate
<a href=
"https://hosted.weblate.org/projects/linuxcnc/
">the
333 LinuxCNC documentation on Weblate
</a
>, alongside the program itself.
</p
>
335 <p
>The effort to migrate the documentation to use po4a has been both
336 slow and frustrating. I am very happy we finally made it.
</p
>
338 <p
>As usual, if you use Bitcoin and want to show your support of my
339 activities, please send Bitcoin donations to my address
340 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
345 <title>Run your industrial metal working machine using Debian?
</title>
346 <link>https://people.skolelinux.org/pere/blog/Run_your_industrial_metal_working_machine_using_Debian_.html
</link>
347 <guid isPermaLink=
"true">https://people.skolelinux.org/pere/blog/Run_your_industrial_metal_working_machine_using_Debian_.html
</guid>
348 <pubDate>Wed,
2 Mar
2022 18:
40:
00 +
0100</pubDate>
349 <description><p
>After many months of hard work by the good people involved in
350 <a href=
"https://en.wikipedia.org/wiki/LinuxCNC
">LinuxCNC
</a
>, the
351 system was accepted Sunday
352 <a href=
"https://tracker.debian.org/pkg/linuxcnc
">into Debian
</a
>.
353 Once it was available from Debian, I was surprised to discover from
354 <a href=
"https://qa.debian.org/popcon.php?package=linuxcnc
">its
355 popularity-contest numbers
</a
> that people have been reporting its use
356 since
2012.
<a href=
"http://linuxcnc.org/
">Its project site
</a
> might
357 be a good place to check out, but sadly is not working when visiting
360 <p
>But what is LinuxCNC, you are probably wondering? Perhaps a
361 Wikipedia quote is in place?
</p
>
364 "LinuxCNC is a software system for numerical control of
365 machines such as milling machines, lathes, plasma cutters, routers,
366 cutting machines, robots and hexapods. It can control up to
9 axes or
367 joints of a CNC machine using G-code (RS-
274NGC) as input. It has
368 several GUIs suited to specific kinds of usage (touch screen,
369 interactive development).
"
372 <p
>It can even control
3D printers. And even though the Wikipedia
373 page indicate that it can only work with hard real time kernel
374 features, it can also work with the user space soft real time features
375 provided by the Debian kernel.
376 <a href=
"https://github.com/linuxcnc/linuxcnc
">The source code
</a
> is
377 available from Github. The last few months I
've been involved in the
378 translation setup for the program and documentation. Translators are
380 <a href=
"https://hosted.weblate.org/engage/linuxcnc/
">join the
381 effort
</a
> using Weblate.
</p
>
383 <p
>As usual, if you use Bitcoin and want to show your support of my
384 activities, please send Bitcoin donations to my address
385 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>