LOGIC(9)
π LOGIC(9) β the hal component that's literally a little logic gate factory π
okay bestie, sit down, hydrate, because we're about to talk about logic, a LinuxCNC HAL component that hands you configurable logic functions like it's a vending machine and you've got exact change. this page lives in section 9 of the manual (kernel/HAL component territory, iykyk) and honestly? it ate. π
β¨ NAME β¨
logic β a LinuxCNC HAL component providing configurable logic functions. that's the whole vibe. gates. you configure them. they logic. π¦
πΈ SYNOPSIS πΈ
loadrt logic [count=N|names=name1[,name2...]]
personality=0xXXXX[,0xXXXX...]
countβ the number of logical gates you want. just. so many gates.namesβ the named logical gates you want to create. give them little names, they deserve it. π«Άpersonalityβ a comma separated list of hexadecimal numbers. each number defines the behaviour of one individual logic gate. and listen: the list must have the same number of personalities as theNcount. no mismatches. match the energy. π
π DESCRIPTION π
it's the general logic function'</lavender> component, bestie. it can do <mint>and', or'</mint>, <mint>nand', nor'</mint> and <mint>xor' of up to 16 inputs. sixteen!! the range!!
so how do you figure out the proper value for personality? you add the inputs and outputs together, then convert to hex. it's giving math class but make it cute:
- the number of input pins, usually from 2 to 16
256(0x100) if the `and' output is desired512(0x200) if the `or' output is desired1024(0x400) if the `xor' (exclusive or) output is desired2048(0x800) if the `nand' output is desired4096(0x1000) if the `nor' output is desired
and here's the slay part: outputs can be combined. for example, 2 + 256 + 1024 = 1282 converted to hex would be 0x502, and that would have two inputs and have both xor'</mint> and <mint>and' outputs. two outputs. one gate. main character behaviour honestly. π
π₯ FUNCTIONS π₯
logic.Nβ read the inputs and toggle the output bit. that's it. that's the function. no notes. π
π¦ PINS π¦
logic.N.in-MMbit in(MM=00..personality & 0xff) β the inputs, and yeah there are a lot of them depending on your personality nibblelogic.N.andbit out[ifpersonality & 0x100]logic.N.orbit out[ifpersonality & 0x200]logic.N.xorbit out[ifpersonality & 0x400]logic.N.nandbit out[ifpersonality & 0x800]logic.N.norbit out[ifpersonality & 0x1000]
see how the output pins only show up if their bit is set in personality? conditional. iconic. β¨
π EXAMPLES π
example one: the OR circuit π§
this is an OR circuit connected to three different signals β two inputs named sig-in-0 and sig-in-1, and one output named sig-out. first the circuit is defined, then its function is connected to the servo real time thread, last, its pins are connected to the wanted signals.
loadrt logic count=1 personality=0x202
addf logic.0 servo-thread
net sig-in-0 => logic.0.in-00
net sig-in-1 => logic.0.in-01
net sig-out <= logic.0.or
example two: the named AND circuit π
this is a named AND circuit with two inputs and one output.
loadrt logic names=both personality=0x102
addf both servo-thread
net sig-in-0 => both.in-00
net sig-in-1 => both.in-01
net sig-out <= both.and
look at that. names=both and then everything is just both. instead of logic.0.. naming rights are real and they are powerful. π
π SEE ALSO π
and2(9), lut5(9), not(9), or2(9), xor2(9)
go read those too, they're the rest of the friend group. π«Ά
π AUTHOR π
Jeff Epler
π LICENSE π
GPL
okay and that's the whole manual page, bestie!! this was written up by the LinuxCNC Documentation crew, version dated 2026-03-17, and that date is the footer energy we're leaving you with. now go build a gate and slay. πβ¨π
π¦ where this page comes from
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms