Halui Component

More
7 years 4 months ago #136775 by stegrg
Replied by stegrg on topic Halui Component
I apologize if I'm leading everybody astray.... I'm relatively new here. Please bear with me.

I'm trying to write a hal component. I need an output signal from Axis to use in my hal component when the step function is activated in Axis (This can be from clicking on the step icon, typing "t" on the keyboard, or whatever other method there is to increment a step in G-code) .

Please Log in to join the conversation.

More
7 years 4 months ago #136776 by andypugh
Replied by andypugh on topic Halui Component
I have had a look around, and this is fairly hard to detect.

As far as I can see all you can do is look for halui.program.is-paused = true and joint.0/1/2/3.vel-cmd != 0.

Note also that motion.program-line increments by one every time the motion stops.

Please Log in to join the conversation.

More
7 years 4 months ago #136781 by stegrg
Replied by stegrg on topic Halui Component
Yes, I've tried both halui.program.is-paused as well as motion.program-line. The problem is that when stepping through a program, the program doesn't pause even though the current G-code line has been executed and it's waiting for the next command. (The status at this point is Halui.program.is-running = true.)

Motion.program-line returns the current G-code line number while running. In step mode, it returns the current G-code line number while executing. Once it's completed, it returns a 0. I could use this if there was a way to filter out certain G codes that also return a 0 such as G4. Is there some way to read the current G-code command in hal?

Please Log in to join the conversation.

More
7 years 4 months ago #136783 by andypugh
Replied by andypugh on topic Halui Component
There is motion.motion-type.

But, curiously, I see program-is-paused as true on the version of linuxCNC I am using.

program-is-paused is no help, it shows true then false and remains falseif you _start_ with single step but shows true all the time if you pause and then single-step.
motion.program-line is equally unhelpful in a similar way. It goes to zero if you start with single-step, but not if you pause and then single-step.

Please Log in to join the conversation.

More
7 years 4 months ago #136804 by stegrg
Replied by stegrg on topic Halui Component
That's interesting. I'll take a closer look when I get a second to see if there is a way of combining what you described with some other hal components to generate the "program.is-stepped" function I'm looking for.
Thanks for the suggestion.

Please Log in to join the conversation.

More
7 years 4 months ago #136805 by phillc54
Replied by phillc54 on topic Halui Component
The following code will set a HAL pin to True whenever a step is sent from the Axis GUI. You will need to work out how reset the pin either via you component or a timer...

EDIT: The code was modified after Andys suggestion and has been tested. All you need to do is set axisui.step-activated to 0 from your component.
Code:
# this will create a HAL output pin named axisui.step-activated def user_hal_pins(): comp.newpin('step-activated', hal.HAL_BIT, hal.HAL_IO) comp.ready() # this function replaces the task_step function in Axis def hijacked_step(*event): # this is the original code from the task_step function if s.task_mode != linuxcnc.MODE_AUTO or s.interp_state != linuxcnc.INTERP_IDLE: o.set_highlight_line(None) if run_warn(): return ensure_mode(linuxcnc.MODE_AUTO) c.auto(linuxcnc.AUTO_STEP) # turn the HAL pin on comp['step-activated'] = 1 # add the new function to the TclCommands TclCommands.hijacked_step = hijacked_step commands = TclCommands(root_window) # point the menu item to the new command root_window.tk.call('.menu.machine', 'entryconfigure', '5', '-command', 'hijacked_step') # point the toolbar button to the new command root_window.tk.call('.toolbar.program_step', 'configure', '-command', 'hijacked_step') # point the keyboard shortcut to the new command root_window.bind("t", commands.hijacked_step)
This code needs to be in either .axisrc or the file specified by [DISPLAY] USER_COMMAND_FILE in your ini file.

For more Axis customizing see here

Cheers, Phill.

Please Log in to join the conversation.

More
7 years 4 months ago #136825 by andypugh
Replied by andypugh on topic Halui Component

phillc54 wrote: The following code will set a HAL pin to True whenever a step is sent from the Axis GUI. You will need to work out how reset the pin either via you component or a timer.


If it was created as a bidirectional pin (hal.HAL_IO, like the encoder index) then the reading component could reset it after seeing it go high.

Please Log in to join the conversation.

More
7 years 4 months ago #136826 by phillc54
Replied by phillc54 on topic Halui Component
I didn't realise that was possible, handy to know. Thanks for pointing that out.

Cheers, Phill.

Please Log in to join the conversation.

More
7 years 4 months ago #136845 by Grotius
Replied by Grotius on topic Halui Component
Hi,

Phillip Carter and Andy Pugh have provide the best solution together for a inplementation with the current axis gui.
It's problably tested Python code, i believe it for sure.

My code was a solution more to the core. Only for upgrading examples.

The Gscreen and Gmoccapyy gui can implement the .step halui signal so far i know.
I never invested time in this item, because at that time there was a new negative adaptive-feed, so a step forward or backward was not important for me at that time. Just like Elvis.

Please Log in to join the conversation.

More
7 years 4 months ago #136858 by stegrg
Replied by stegrg on topic Halui Component
I really appreciate the feedback everybody! Hopefully in the next few days I can spend a bit of time on this and try out the recommendations. I'll keep you posted on how it works out.

Please Log in to join the conversation.

Time to create page: 0.066 seconds
Powered by Kunena Forum