1 Input to move 2 axis

More
05 Sep 2022 20:19 #251253 by joshwuh
Hello,

I am working on a pendant and have been reading about HAL and learning a bit more about components. I've still not got a perfect grasp on signals, pins, and parameters, but I'm getting better.

I have this snippet of code:
# Jogging
sets jog-speed 1
net jog-x-pos <= matrix_kb.0.key.r3c1
net jog-x-neg <= matrix_kb.0.key.r1c1
net jog-y-pos <= matrix_kb.0.key.r2c0
net jog-y-neg <= matrix_kb.0.key.r2c2
net jog-z-pos <= matrix_kb.0.key.r0c0
net jog-z-neg <= matrix_kb.0.key.r0c1

which works great. but I've also got buttons to move diagonally:
R1C0 should move -X +Y
R1C2 should move -X -Y
R3C0 should move +X +Y
R3C2 should move +X -Y

I cannot figure out what the syntax would look like if I wanted to connect jog-y-pos and jog-x-pos both to one single key. I have tried something like this:
jog-xy-pos <= matrix_kb.0.key.r3c0
net jog-x-pos <= jog-xy-pos
net jog-y-pos <= jog-xy-pos

but then LinuxCNC will error on opening. Any tips?

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

More
05 Sep 2022 22:30 #251258 by joshwuh
Replied by joshwuh on topic 1 Input to move 2 axis
for anyone curious, I figured it out using or2....
#    Jogging
sets jog-speed 1
loadrt or2 count=8
addf or2.0 servo-thread
addf or2.1 servo-thread
addf or2.2 servo-thread
addf or2.3 servo-thread
addf or2.4 servo-thread
addf or2.5 servo-thread
addf or2.6 servo-thread
addf or2.7 servo-thread
#        X+
net xpos      or2.0.in0 <= matrix_kb.0.key.r3c1 # x+
net xypos     or2.0.in1 <= matrix_kb.0.key.r3c0 # x+ y+
net xorxypos  or2.0.out => or2.1.in0
net xposyneg  or2.1.in1 <= matrix_kb.0.key.r3c2 # x+ y-
net jog-x-pos <= or2.1.out
#        X-
net xneg      or2.2.in0 <= matrix_kb.0.key.r1c1 # x-
net xyneg     or2.2.in1 <= matrix_kb.0.key.r1c2 # x- y-
net xorxyneg  or2.2.out => or2.3.in0
net xnegypos  or2.3.in1 <= matrix_kb.0.key.r1c0 # x- y+
net jog-x-neg <= or2.3.out
#        Y+
net ypos      or2.4.in0 <= matrix_kb.0.key.r2c0 #    y+
net xypos     => or2.4.in1                      # x+ y+
net yorxypos  or2.4.out => or2.5.in0
net xnegypos  => or2.5.in1                      # x- y+
net jog-y-pos <= or2.5.out
#        Y-
net yneg      or2.6.in0 <= matrix_kb.0.key.r2c2 #    y-
net xyneg     => or2.6.in1                      # x- y-
net yorxyneg  or2.6.out => or2.7.in0
net xposyneg  => or2.7.in1                      # x+ y-
net jog-y-neg <= or2.7.out
#        Z+
net jog-z-pos <= matrix_kb.0.key.r0c0
#        Z-
net jog-z-neg <= matrix_kb.0.key.r0c1

now I just need to figure out how to build an or3 so the code isn't so ugly requiring double-or2s....

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

More
05 Sep 2022 23:14 #251259 by joshwuh
Replied by joshwuh on topic 1 Input to move 2 axis
...and now I got it looking better using a logic component
# Pendant settings
#    Keypad Matrix
loadrt matrix_kb config=4x8
addf matrix_kb.0 servo-thread
net keypad hm2_7i76e.0.7i73.0.1.keycode => matrix_kb.0.keycode
#    Jogging
sets jog-speed 1
loadrt logic count=4 personality=0x203,0x203,0x203,0x203
addf logic.0 servo-thread
addf logic.1 servo-thread
addf logic.2 servo-thread
addf logic.3 servo-thread
#        X+
net xpos      logic.0.in-00 <= matrix_kb.0.key.r3c1 # x+
net xypos     logic.0.in-01 <= matrix_kb.0.key.r3c0 # x+ y+
net xposyneg  logic.0.in-02 <= matrix_kb.0.key.r3c2 # x+ y-
net jog-x-pos <= logic.0.or
#        X-
net xneg      logic.1.in-00 <= matrix_kb.0.key.r1c1 # x-
net xyneg     logic.1.in-01 <= matrix_kb.0.key.r1c2 # x- y-
net xnegypos  logic.1.in-02 <= matrix_kb.0.key.r1c0 # x- y+
net jog-x-neg <= logic.1.or
#        Y+
net ypos      logic.2.in-00 <= matrix_kb.0.key.r2c0 #    y+
net xypos     => logic.2.in-01                      # x+ y+
net xnegypos  => logic.2.in-02                      # x- y+
net jog-y-pos <= logic.2.or
#        Y-
net yneg      logic.3.in-00 <= matrix_kb.0.key.r2c2 #    y-
net xyneg     => logic.3.in-01                      # x- y-
net xposyneg  => logic.3.in-02                      # x+ y-
net jog-y-neg <= logic.3.or
#        Z+
net jog-z-pos <= matrix_kb.0.key.r0c0
#        Z-
net jog-z-neg <= matrix_kb.0.key.r0c1
The following user(s) said Thank You: tommylight

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

More
06 Sep 2022 00:25 #251261 by tommylight
Replied by tommylight on topic 1 Input to move 2 axis
Thank you for posting the details.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum