Custom user Button Touchoff in Axis

More
6 years 1 month ago #181139 by snowgoer540

phillc54 wrote:

snowgoer540 wrote: Give me one quick nudge here please... where is the proper place to establish the "axisui.refresh" HAL pin? Hal connections file?

All the code for this needs to be in plasmac_axis.py, you should be able to find in there where HAL pins are created and also the function that runs every cycle.


so I am guessing axis_remote --reload is not the proper way to send this command inside of the plasmax_axis? commands.reload doesnt appear to work either lol

Please Log in to join the conversation.

More
6 years 1 month ago #181140 by phillc54
Close, commands.reload_file() does the trick. You can look in axis.py for all those commands.

Please Log in to join the conversation.

More
6 years 1 month ago #181144 by snowgoer540

phillc54 wrote: Close, commands.reload_file() does the trick. You can look in axis.py for all those commands.


I must be doing something wrong.

I'm trying to take this in baby steps so I don't have too much go wrong at once.
Code:
if hal.get_value('axisui.refresh') == '1': commands.reload_file()

doesn't seem to do anything. Edit: my ini file is setting that pin to 1, I confirmed that.

I did figure out that the rest of the needed commands are:
Code:
commands.clear_live_plot() commands.set_view_z()

Then I just need to figure out how to increment...something...so that it does each every cycle.

Please Log in to join the conversation.

More
6 years 1 month ago #181146 by phillc54
After the == remove the both the ' from the 1, that denotes text and it is an integer.

Yep, they are the correct commands

hal.set_p will set a HAL pin

Please Log in to join the conversation.

More
6 years 1 month ago #181148 by snowgoer540

phillc54 wrote: After the == remove the both the ' from the 1, that denotes text and it is an integer.

Yep, they are the correct commands

hal.set_p will set a HAL pin


I cant get it to do any one of these things... I think the snakes must be feeling particularly lazy today. I thought I had to use S32 pin to be able to use values other than 0 and 1. But when I do that, it doesnt change the value to 1. This must be like watching a toddler learn to crawl :laugh:
Code:
if hal.get_value('axisui.refresh') == 1: commands.reload_file() hal.set_p('axisui.refresh', '2') if hal.get_value('axisui.refresh') == 2: commands.clear_live_plot() hal.set_p('axisui.refresh', '3') if hal.get_value('axisui.refresh') == 3: hal.set_p('axisui.refresh', '0') commands.set_view_z()

Please Log in to join the conversation.

More
6 years 1 month ago #181149 by phillc54
Change the second two from if to elif so it doesn't run them one after the other in the same cycle.
Do the hal.set_p lines before the commands lines.

You do need to start LinuxCNC each time you change this file.

That's all I can help with tonight, see ya tomorrow.

Please Log in to join the conversation.

More
6 years 1 month ago #181153 by snowgoer540
Got it working! I've been sitting here for a few hours, but I learned a lot, and good news is I can move on with the day now :lol: For instance, I learned that you cant use tabs, after beating my head against the wall for nearly an hour... tab does not equal 4 spaces lol

I would imagine Phill will push this (if he hasnt already), but to do this, you need to add the following code after line 816 (not 100% sure this is the best place to add it):
Code:
if hal.get_value('axisui.refresh') == 1: hal.set_p('axisui.refresh', '2') commands.reload_file() elif hal.get_value('axisui.refresh') == 2: hal.set_p('axisui.refresh', '3') commands.clear_live_plot() elif hal.get_value('axisui.refresh') == 3: commands.set_view_z() hal.set_p('axisui.refresh', '0')

Then you need to add a pin in the add a pin area (before comp.ready()):
Code:
comp.newpin('refresh', hal.HAL_S32, hal.HAL_IO)

Lastly, your button code in your ini file becomes:
Code:
G10 L20 P0 X0 Y0 \ %halcmd setp axisui.refresh 1

well, I can crawl a little further now than before...

Please Log in to join the conversation.

More
6 years 1 month ago #181194 by phillc54

snowgoer540 wrote: Got it working! I've been sitting here for a few hours, but I learned a lot, and good news is I can move on with the day now :lol: For instance, I learned that you cant use tabs, after beating my head against the wall for nearly an hour... tab does not equal 4 spaces lol

Great work, now all you need to do is add it into the user guide, create a new branch and submit a PR.

Can you set up whatever IDE/editor you are using to use spaces instead of tabs?

Edit: HAL_IN for the pin would be ok.

Please Log in to join the conversation.

More
6 years 1 month ago #181200 by snowgoer540

phillc54 wrote:

snowgoer540 wrote: Got it working! I've been sitting here for a few hours, but I learned a lot, and good news is I can move on with the day now :lol: For instance, I learned that you cant use tabs, after beating my head against the wall for nearly an hour... tab does not equal 4 spaces lol

Great work, now all you need to do is add it into the user guide, create a new branch and submit a PR.

Can you set up whatever IDE/editor you are using to use spaces instead of tabs?

Edit: HAL_IN for the pin would be ok.


Thanks, it is exciting when you get it to work finally...

I'm not sure, I will have to check, I was using Geany.

I wondered about IN vs IO, I looked it up and misread Table 1 here: linuxcnc.org/docs/html/hal/halmodule.html I thought the columns were related, I see now it's 3 rows...

I would actually be happy to add it to the user manual while I am editing. I'be made it down to line 258 haha, got a little bit to go.

I would need a noob guide to github to create a branch and make a pull request. This seems best done from Linux on the machine, but the last time I tried I couldnt figure it out.

Please Log in to join the conversation.

More
6 years 1 month ago #181204 by phillc54
You did well. If you want to do it the git way I can try to help you through.

The recent doc changes I made are below, pink are deletions and green are additions:

For the compressed backup:
github.com/LinuxCNC/linuxcnc/commit/9bb4...d5fdf0bb042ffa3ed7e1

For the final probe speed:
github.com/LinuxCNC/linuxcnc/commit/4dc4...d5fdf0bb042ffa3ed7e1

For the 2.8 release:
github.com/LinuxCNC/linuxcnc/commit/4db0...d5fdf0bb042ffa3ed7e1

Edit: these are the changes I ended up with.
Warning: Spoiler!

Please Log in to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum