Programming a 'custom' button

More
24 Apr 2013 18:48 #33131 by beltramidave
You are on the right track here, but I don't understand your logic.

What I want to do is to manually move X & Y to some location, then have 1 button (called program) that would put the machine in 'program' mode. Then I will have several 'custom' buttons. When in 'program' mode, pushing one of these 'custom' buttons will record the current positions. When not in 'program' mode, pushing the 'custom' button will move X & Y to the stored location.

The part that I am struggling with is how can I tell when I am in 'program' mode. I would rather do this in Gcode than Classic Ladder. I was hoping to use the if/else statements to determine if I was in 'program' mode or not.

This all goes back to trying to make this simple positioning table easier for the operator to add custom goto locations without having to get into the software.

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

More
24 Apr 2013 18:54 #33133 by andypugh

The part that I am struggling with is how can I tell when I am in 'program' mode.

My suggestion was to only have valid numbers stored in the "program" parameters when in "program mode" and to have out-of-range numbers otherwise
However, you could equally easily use a "hidden" G-code parameter for the job. By "hidden" I just mean a parameter which is not shown on the display anywhere.

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

More
25 Apr 2013 01:50 #33159 by beltramidave
Ok, I think I am getting closer to accomplishing what I want. I have created a toggle button with an led indicator that comes on when I am in "program" mode. I have also created several subroutines that are called from buttons.

What I need now is to figure out how to use bit status from the led in my if/else instruction in my subroutine. I have verified in Hal that when I push the 'program' button this bit (toggle.0.out) comes high (and stays high until button is pushed again).

This is what my sub looks like:

o<custom1>sub
o100 if [toggle.0.out true]
#5161 = #5420
#5162 = #5421
o100 else
G0 X#5161 Y#5162
o100 endif
o<custom1>end sub

When I push the 'custom1' button (which calls the sub), I get an error message "unknown word starting with t". Which I am sure has to do with the format of my expression.

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

More
25 Apr 2013 02:38 #33163 by andypugh

o100 if [toggle.0.out true]
When I push the 'custom1' button (which calls the sub), I get an error message "unknown word starting with t".


Unfortunately, G-code can't actually "see" HAL. (Normally, but see the footnote).
The way to do this is to net toggle.0.out to motion.digital-in-00 then use a syntax like
M66 P0 L0
O100 IF [#5399 EQ 1] 
…
M66 is "digital input" and the result is transferred to #5399. This is quite a useful function, as it can be made to wait for a value to change too. You can add more digital inputs with INI file options.

<footnote> It is actually possible to see HAL from G-code in the development version of LinuxCNC.
www.linuxcnc.org/docs/devel/html/remap/s...d_sub_ini_features_a
If you set the feature mask to 12 then you get a set of #<_hal.**********> parameters to play with in G-code, along with #<_ini.**** and
The following user(s) said Thank You: eFalegname

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

More
25 Apr 2013 03:17 #33164 by beltramidave
Andy,

You are amazing! That worked perfectly....well almost. The only problem is that since I needed to use toggle.0.out for my digital input, I could not use is for my led to indicate when I was in program mode. Is there a quick fix for this?

I think that after this project is finished, I am going to go back to hard wiring control panels...this programming stuff is way too stressful for me! I cannot thank you enough for your patience with me.

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

More
25 Apr 2013 03:50 #33166 by beltramidave
Never mind... figured it out. Thanks again!

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

Time to create page: 0.137 seconds
Powered by Kunena Forum