Codes for external buttons
- raychar
- Offline
- Premium Member
Less
More
- Posts: 100
- Thank you received: 2
05 Oct 2020 04:32 #184923
by raychar
Codes for external buttons was created by raychar
Hello guys,
Wanting to implement the following individual hardware external buttons for:
> jogging X+, X-,Y+ ....A+ and A- axis
> jog speeds increase and decrease
> cutting feed override increase and decrease
Thinking that the 2 and 3 items need graphical sliders on the display for the indication, but I haven't yet open the Pyvcp or else on my current version is 2.8. i think i need to do so.
Are those codes available or some advice to code them available? Thanks in advance.
Wanting to implement the following individual hardware external buttons for:
> jogging X+, X-,Y+ ....A+ and A- axis
> jog speeds increase and decrease
> cutting feed override increase and decrease
Thinking that the 2 and 3 items need graphical sliders on the display for the indication, but I haven't yet open the Pyvcp or else on my current version is 2.8. i think i need to do so.
Are those codes available or some advice to code them available? Thanks in advance.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7778
- Thank you received: 2074
05 Oct 2020 05:31 #184925
by cmorley
Replied by cmorley on topic Codes for external buttons
What screen are you wanting this to display on?
Please Log in or Create an account to join the conversation.
- raychar
- Offline
- Premium Member
Less
More
- Posts: 100
- Thank you received: 2
05 Oct 2020 07:07 #184938
by raychar
Replied by raychar on topic Codes for external buttons
Axis gui.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
06 Oct 2020 11:32 #185051
by andypugh
Replied by andypugh on topic Codes for external buttons
The Axis GUI already echoes feed and speed overrides from external controls.
For example if you connect a button to halui.feed-override.decrease every time you press the button the slider in Axis will move. (by 1/halui.feed-override.scale)
If you prefer to use an MPG, use the halui.feed-override.counts pin instead, connected to the MPG counts. You also need to enable halui.feed-override.count-enable for the MPG to work. Either by an enable switch or a "setp halui.feed-override.count-enable 1" in the HAL file.
For example if you connect a button to halui.feed-override.decrease every time you press the button the slider in Axis will move. (by 1/halui.feed-override.scale)
If you prefer to use an MPG, use the halui.feed-override.counts pin instead, connected to the MPG counts. You also need to enable halui.feed-override.count-enable for the MPG to work. Either by an enable switch or a "setp halui.feed-override.count-enable 1" in the HAL file.
Please Log in or Create an account to join the conversation.
- raychar
- Offline
- Premium Member
Less
More
- Posts: 100
- Thank you received: 2
07 Oct 2020 14:21 #185254
by raychar
Replied by raychar on topic Codes for external buttons
"For example if you connect a button to halui.feed-override.decrease every time you press the button the slider in Axis will move. (by 1/halui.feed-override.scale)"
I did this, thanks. BTW, when I press the button continuously, is it possible to make the slider decrease continuously as well?. Currently, it is.. one click one step increases
I did this, thanks. BTW, when I press the button continuously, is it possible to make the slider decrease continuously as well?. Currently, it is.. one click one step increases
Please Log in or Create an account to join the conversation.
- BeagleBrainz
- Visitor
07 Oct 2020 14:56 #185256
by BeagleBrainz
Replied by BeagleBrainz on topic Codes for external buttons
I don’t think so. Could be possible with a custom Hal comp.
Actually that could be useful, if one doesn’t already exist.
Hopefully one of Devs might have an idea.
Actually that could be useful, if one doesn’t already exist.
Hopefully one of Devs might have an idea.
Please Log in or Create an account to join the conversation.
- AgentWD40
- Offline
- Platinum Member
Less
More
- Posts: 334
- Thank you received: 92
07 Oct 2020 15:06 #185258
by AgentWD40
This behavior could also be useful on some touch screen controls.
Replied by AgentWD40 on topic Codes for external buttons
I don’t think so. Could be possible with a custom Hal comp.
Actually that could be useful, if one doesn’t already exist.
Hopefully one of Devs might have an idea.
This behavior could also be useful on some touch screen controls.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
07 Oct 2020 15:16 - 12 Oct 2020 11:57 #185259
by andypugh
All things are possible. But that isn't a built-in behaviour.
A quick and dirty way to do that would be to " and2 " the button with a " siggen " clock signal. But that would be a bit wierd to use depending on when in the cycle you pressed the button.
Better would be a custom HAL component something like this (note that I am typing this in a break at work on a windows PC, so it is from memory and untested)
Replied by andypugh on topic Codes for external buttons
is it possible to make the slider decrease continuously as well?. Currently, it is.. one click one step increases
All things are possible. But that isn't a built-in behaviour.
A quick and dirty way to do that would be to " and2 " the button with a " siggen " clock signal. But that would be a bit wierd to use depending on when in the cycle you pressed the button.
Better would be a custom HAL component something like this (note that I am typing this in a break at work on a windows PC, so it is from memory and untested)
component autorepeat "auto-repeat a button press";
pin in bit in "input signal";
pin out bit out "output";
pin in float hold "hold time";
pin in float repeat "repeat time";
license "gpl2+";
author "andypugh";
;;
static int stage = 0;
static double timer;
if (in == 0){
out = 0;
stage = 0;
}
switch(stage){
case 0: // idle
out = in;
if (in) {
stage = 1;
timer = 0;
}
case 1: // timing hold
timer += fperiod;
if (timer > hold){
out = 0;
stage = 2;
timer = 0;
}
break;
case 2; // toggling
timer += fperiod;
if (timer > repeat){
out = 1;
stage = 3;
timer = 0;
}
break;
case 3; // toggling 2
timer += fperiod;
if (timer > repeat){
out = 0;
stage = 2;
timer = 0;
}
break;
}
Last edit: 12 Oct 2020 11:57 by andypugh. Reason: Moved the test for in==0 out of the state machine for simplicity
The following user(s) said Thank You: BeagleBrainz
Please Log in or Create an account to join the conversation.
- raychar
- Offline
- Premium Member
Less
More
- Posts: 100
- Thank you received: 2
12 Oct 2020 13:07 #185830
by raychar
Replied by raychar on topic Codes for external buttons
Where and how to put this C program into Linuxcnc?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
12 Oct 2020 13:12 - 12 Oct 2020 13:13 #185831
by andypugh
Replied by andypugh on topic Codes for external buttons
It isn't normal C, it is the ".comp" component definition language. (Which used C for the actual code section).
If you follow the link in the post you should find the halcompile documentation.
But, summary
Save the code in a file called "autorepeat.comp"
compile and install with "sudo halcompile --install autorepeat.comp"
(debug until it compiles cleanly)
Then load into the HAL file with "loadrt autorepeat count=4" to get 4 of them.
If you follow the link in the post you should find the halcompile documentation.
But, summary
Save the code in a file called "autorepeat.comp"
compile and install with "sudo halcompile --install autorepeat.comp"
(debug until it compiles cleanly)
Then load into the HAL file with "loadrt autorepeat count=4" to get 4 of them.
Last edit: 12 Oct 2020 13:13 by andypugh.
Please Log in or Create an account to join the conversation.
Time to create page: 0.072 seconds