physical start button + pause switch

More
15 Nov 2016 21:27 - 15 Nov 2016 21:28 #82849 by SenorAguas
Hi Guys, I've been messing with this a while and am stuck with some of this and2 logic (I think that's my issue).

I'm trying to set up a momentary switch to start the program. I can get this working by itself, although it wants to start the program automatically as soon as its opened. After running it once, the program restarts with the switch.

Also, I have a switch to pause the program if the operator removes the pallet that holds part (this is an automated glue machine). I can get this working by itself.

I can't get them both working at the same time. Here's the error I get: cant do that (EMC_TASK_PLAN_RUN) in auto mode with the interpreter reading. ALso, I get cant do that (EMC_TASK_PLAN_OPEN) in auto mode with the interpreter reading

Can someone help? I thought I halfway understood and2.

Here's my HAL:
loadrt and2 count=2
addf and2.0 servo-thread
addf and2.1 servo-thread

#pause button

net button_open parport.0.pin-15-in-not => and2.1.in0
net machine-running halui.program.is-running => and2.1.in1
net pause-motion and2.1.out => motion.feed-inhibit

#start button

net program-start-btn halui.mode.auto and2.0.in0 <= parport.0.pin-13-in
net program-run-ok and2.0.in1 <= halui.mode.is-auto
net remote-program-run and2.0.out => halui.program.run
Last edit: 15 Nov 2016 21:28 by SenorAguas. Reason: typo

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

More
16 Nov 2016 14:24 #82862 by SenorAguas
I scrapped my attempt at the HAL, and went with a piece of code from the thread below (Thanks BigJohnT), but it needs modified for what I'm looking for. I have no need for the step function.

Using this code, my pause switch works and my run switch starts the program, but it only runs 1 line of G code. I'd like it to run the whole program.

So far, I've tried commenting out the step portion, but that made it where I could only start the first line of code and wasn't able to step through after that.

forum.linuxcnc.org/47-hal-examples/13201...-hold-resume-buttons
loadrt and2 count=4
loadrt or2 count=1
loadrt toggle count=1
loadrt toggle2nist count=1

addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf or2.0 servo-thread
addf toggle.0 servo-thread
addf toggle2nist.0 servo-thread

# External Program Pause/Resume and Run/Step Buttons
# Pause/Resume Section
net pause-resume-btn and2.0.in0 and2.1.in0 <= parport.0.pin-15-in
net pause-on toggle2nist.0.is-on and2.0.in1 and2.3.in1 <= halui.program.is-paused
net run-on and2.1.in1 <= halui.program.is-running
net pause-sig or2.0.in0 <= and2.0.out
net resume-sig or2.0.in1 <= and2.1.out
net toggle-ok toggle.0.in <= or2.0.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off
# Run/Step Section
net run-step-btn and2.2.in0 and2.3.in0 <= parport.0.pin-13-in
net idle-on and2.2.in1 <= halui.program.is-idle
# net pause.on and 2.3.in1 <= halui.program.is-paused
# and2.3.in1 was added in the net pause-on statement in Pause/Resume Section
net run-sig halui.mode.auto halui.program.run <= and2.2.out
net step-sig halui.program.step <= and2.3.out

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

More
17 Nov 2016 12:52 #82890 by rodw
If the code is from this thread
forum.linuxcnc.org/forum/47-hal-examples...p-holdresume-buttons

It says:
Pressing Run/Step while a program is paused will single step the program.
Pressing Hold/Resume while a program is paused will return it to normal run mode.

Sounds like you need to tweak it just a little bit

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

More
17 Nov 2016 15:35 - 17 Nov 2016 15:38 #82904 by SenorAguas
Yes, I mapped out the code last night and removed all the and2.3 references thinking that would keep it from stepping. It didn't work. Now it runs 1 step and quits.

here's my map of the code and the portion that I removed:

https://drive.google.com/open?id=0B9dawSNCLhG9ZWd1aGxaQ2hKM3c

Attachments:
Last edit: 17 Nov 2016 15:38 by SenorAguas.

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

More
17 Nov 2016 15:48 #82906 by SenorAguas
When I follow the map, it seems like it should work. Maybe I screwed up the map?

It will start with the run switch, but only run 1 step. The pause switch will get it going again.

Here's the modified code:
loadrt and2 count=3
loadrt or2 count=1
loadrt toggle count=1
loadrt toggle2nist count=1

addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread

addf or2.0 servo-thread
addf toggle.0 servo-thread
addf toggle2nist.0 servo-thread

# External Program Pause/Resume and Run/Step Buttons
# Pause/Resume Section
net pause-resume-btn and2.0.in0 and2.1.in0 <= parport.0.pin-15-in
net pause-on toggle2nist.0.is-on and2.0.in1 <= halui.program.is-paused
net run-on and2.1.in1 <= halui.program.is-running
net pause-sig or2.0.in0 <= and2.0.out
net resume-sig or2.0.in1 <= and2.1.out
net toggle-ok toggle.0.in <= or2.0.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off
# Run/Step Section
net run-step-btn and2.2.in0 <= parport.0.pin-13-in
net idle-on and2.2.in1 <= halui.program.is-idle
net run-sig halui.mode.auto halui.program.run <= and2.2.out

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

More
17 Nov 2016 20:42 - 17 Nov 2016 20:48 #82926 by SenorAguas
OK, I have it 95% working with the following code, which has gone through about 15 iterations now and is much much different than where I started. The machine is physically doing what I want with the two buttons, but I'm getting error messages whenever hitting the stop switch (which used to be a pause switch). I'm really not sure the difference between pause and stop, but changing it to stop allowed me to restart using the start button.

This is the error: can't do that (EMC_TRAJ_SET_TELEOP_ENABLE) in auto mode with the interpreter idle.

Can someone help me get rid of this error?

Here's the code:
loadrt and2 count=2
loadrt or2 count=1

addf and2.0 servo-thread
addf and2.1 servo-thread
addf or2.0 servo-thread


# External Program Pause and Run Buttons

# Run Section

net run-btn or2.0.in0 and2.1.in0 <= parport.0.pin-13-in
net pause-on and2.1.in1 <= halui.program.is-paused
net my-or1 or2.0.in1 <= and2.1.out
net run-sig halui.mode.auto halui.program.run <= or2.0.out

# Stop Section

net stop-btn and2.0.in0 <= parport.0.pin-15-in-not
net run-on and2.0.in1 <= halui.program.is-running
net stop-sig halui.program.stop <= and2.0.out


Attachments:
Last edit: 17 Nov 2016 20:48 by SenorAguas.

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

More
17 Nov 2016 20:57 - 17 Nov 2016 21:02 #82929 by Todd Zuercher
I haven't been following this really closely, but perhaps you are making this more complicated than it needs to be. What happens if you follow the kiss method and do this?
net run-btn <= parport.0.pin-13-in => halui.mode.auto => halui.program.run

net stop-btn <= parport.0.pin-15-in => halui.program.stop
You may also want to try it with and with out the halui.mode.auto connection.
Last edit: 17 Nov 2016 21:02 by Todd Zuercher.

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

More
17 Nov 2016 22:45 #82935 by SenorAguas
Just tried it with and without the auto part of it. It basically worked the same as what I've already got, i.e. it basically did what I wanted it to do, but with an error on the screen:

can't do that (EMC_TRAJ_SET_TELEOP_ENABLE) in auto mode with the interpreter idle

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

More
18 Nov 2016 03:30 #82945 by Todd Zuercher
This is a longshot, but you could try this
net run-btn <= parport.0.pin-13-in => halui.mode.teleop => halui.mode.auto => halui.program.run 

net stop-btn <= parport.0.pin-15-in => halui.program.stop

But I'm not sure this is the real source of the problem. I'll try a few things in a simulation tomorrow.

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

More
18 Nov 2016 15:51 - 18 Nov 2016 16:04 #82964 by Todd Zuercher
This doesn't give the alarm, but I don't think it should be necessary on a Cartesian machine that doesn't have a joint mode. (seems a little bug like to me.)
setp halui.mode.teleop 1
net run-btn <= parport.0.pin-13-in => halui.mode.auto => halui.program.run
net stop-btn <= parport.0.pin-15-in => halui.program.stop

The more complecated examples you were grabbing code from (with all the ands, ors...) I believe were trying to make one button do multiple tasks. Such as one button that pressing it when the machine is idle starts a file, press again pauses it, and press again resumes. Which is perfectly fine, just a little harder to configure, getting all the logic and hal commands right. At least this might get you started with something that works.
Last edit: 18 Nov 2016 16:04 by Todd Zuercher.
The following user(s) said Thank You: SenorAguas

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

Time to create page: 0.115 seconds
Powered by Kunena Forum