Autoloading Vise - custom coding and Hal help
- jimmyrig
- Offline
- Premium Member
-
Less
More
- Posts: 110
- Thank you received: 36
12 Feb 2025 17:42 #321358
by jimmyrig
Autoloading Vise - custom coding and Hal help was created by jimmyrig
Hey Everyone,
I am working on getting a cnc mill to autoload the next part.
The general idea is a motor will turn a vise until it senses it opened. Then the spindle will use a vacuum sucker on a pneumatic cylinder (connected to the spindle head so it can move (router style)) to remove the old part, drop it off, then grab the next part, close the vise, probe the new stock and resume machining.
I can code most of the movements in a gcode subroutine but am struggling with the logic for the vise (air powered) motor and pneumatics.
hal file
# Vise Outputs
net dout-01 => hm2_7i96s.0.ssr.00.out-01
net dout-02 => hm2_7i96s.0.ssr.00.out-02
#vise sensor
net din-01 <= hm2_7i96s.0.inm.00.input-09-not
made the custom mcode that can control the output but only with the signal not the pin
#!/bin/bash
halcmd sets dout-01 True
exit 0
if i try (using the hal command in the "halshow" to test)
setp dout-01 True
or
getp din-01
I get an error that that pin doesnt exist, and with no way to read the signal that i can see in halcmd that leaves me with pins only. linuxcnc.org/docs/html/man/man1/halcmd.1.html
to my understanding "pin" is the software component, ui button, hardware IO, etc. Signal is the wirename that connects pins together. Looking at halshow it seems like din and douts are signals not pins themselves.
So how would I create a pin? Now that i look at it again after typing all this...... seems like I could just use the pins "hm2_7i96s.0.ssr.00.out-01" directly and not rely on signals at all. Might get messy trying to remember what input/output is what without a signal.
Any help would be great. I'm open to other ways of doing this as well
I am working on getting a cnc mill to autoload the next part.
The general idea is a motor will turn a vise until it senses it opened. Then the spindle will use a vacuum sucker on a pneumatic cylinder (connected to the spindle head so it can move (router style)) to remove the old part, drop it off, then grab the next part, close the vise, probe the new stock and resume machining.
I can code most of the movements in a gcode subroutine but am struggling with the logic for the vise (air powered) motor and pneumatics.
hal file
# Vise Outputs
net dout-01 => hm2_7i96s.0.ssr.00.out-01
net dout-02 => hm2_7i96s.0.ssr.00.out-02
#vise sensor
net din-01 <= hm2_7i96s.0.inm.00.input-09-not
made the custom mcode that can control the output but only with the signal not the pin
#!/bin/bash
halcmd sets dout-01 True
exit 0
if i try (using the hal command in the "halshow" to test)
setp dout-01 True
or
getp din-01
I get an error that that pin doesnt exist, and with no way to read the signal that i can see in halcmd that leaves me with pins only. linuxcnc.org/docs/html/man/man1/halcmd.1.html
to my understanding "pin" is the software component, ui button, hardware IO, etc. Signal is the wirename that connects pins together. Looking at halshow it seems like din and douts are signals not pins themselves.
So how would I create a pin? Now that i look at it again after typing all this...... seems like I could just use the pins "hm2_7i96s.0.ssr.00.out-01" directly and not rely on signals at all. Might get messy trying to remember what input/output is what without a signal.
Any help would be great. I'm open to other ways of doing this as well
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4195
- Thank you received: 1844
12 Feb 2025 18:35 #321364
by Aciera
in the line above 'dout-01' is a signal name
'hm2_7i96s.0.ssr.00.out-01' is a pin name
hence you get an error using the 'setp' command on the signal name
Try using (note sets instead of setp)
Replied by Aciera on topic Autoloading Vise - custom coding and Hal help
net dout-01 => hm2_7i96s.0.ssr.00.out-01
in the line above 'dout-01' is a signal name
'hm2_7i96s.0.ssr.00.out-01' is a pin name
hence you get an error using the 'setp' command on the signal name
setp dout-01 True
Try using (note sets instead of setp)
sets dout-01 True
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4195
- Thank you received: 1844
12 Feb 2025 18:38 #321365
by Aciera
Pins are created by hal components.
Replied by Aciera on topic Autoloading Vise - custom coding and Hal help
So how would I create a pin?
Pins are created by hal components.
The following user(s) said Thank You: jimmyrig
Please Log in or Create an account to join the conversation.
- jimmyrig
- Offline
- Premium Member
-
Less
More
- Posts: 110
- Thank you received: 36
12 Feb 2025 19:05 #321370
by jimmyrig
Replied by jimmyrig on topic Autoloading Vise - custom coding and Hal help
Thanks!
I took a stab at making a hal component but was having issues getting it to compile with comp. Seems like comp isnt installed ("which comp" returns nothing) running the 2.9.3 iso. I also tried installing from git but was having the same issue. Anything special that needs to be done?
Was able to get it working by directly controlling the pins on the 7i96s with a custom M code for now but would like to get it going with a custom hal component.
I took a stab at making a hal component but was having issues getting it to compile with comp. Seems like comp isnt installed ("which comp" returns nothing) running the 2.9.3 iso. I also tried installing from git but was having the same issue. Anything special that needs to be done?
Was able to get it working by directly controlling the pins on the 7i96s with a custom M code for now but would like to get it going with a custom hal component.
#!/bin/bash
# Define HAL pins
MotorRun_PIN="hm2_7i96s.0.ssr.00.out-01"
MotorDirection_PIN="hm2_7i96s.0.ssr.00.out-02"
INPUT_PIN="hm2_7i96s.0.inm.00.input-09"
# Set the output pin high
halcmd setp $MotorDirection_PIN 1
sleep 0.5
halcmd setp $MotorRun_PIN 1
echo "Set $MotorRun_PIN On."
# Wait for the input pin to go high (true) with a timeout of 5 seconds
TIMEOUT=5
END_TIME=$((SECONDS + TIMEOUT))
while [ $SECONDS -lt $END_TIME ]; do
INPUT_VALUE=$(halcmd getp $INPUT_PIN)
if [ "$INPUT_VALUE" -eq 1 ]; then
echo "Input $INPUT_PIN is true. Returning to main program."
halcmd setp $MotorRun_PIN 0
halcmd setp $MotorDirection_PIN 0
exit 0
fi
sleep 0.05 # Small delay to avoid busy-waiting
done
# If the loop ends, the timeout was reached
halcmd setp $MotorRun_PIN 0
halcmd setp $MotorDirection_PIN 0
echo "ERROR: Input $INPUT_PIN did not go high within $TIMEOUT seconds."
exit 1 # Return non-zero to indicate an error
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4195
- Thank you received: 1844
12 Feb 2025 20:11 #321376
by Aciera
linuxcnc.org/docs/html/hal/comp.html
Replied by Aciera on topic Autoloading Vise - custom coding and Hal help
Sounds like you might want to read the docs:I took a stab at making a hal component but was having issues getting it to compile with comp. Seems like comp isnt installed ("which comp" returns nothing) running the 2.9.3 iso
linuxcnc.org/docs/html/hal/comp.html
The following user(s) said Thank You: jimmyrig
Please Log in or Create an account to join the conversation.
Time to create page: 0.052 seconds