METRIC / SAE Indicator for pyVCP

More
9 years 11 months ago #83393 by Askjerry
Wow... I'll have to look into this.

Update of the display is not an issue... the main impetus for this was that I went to move the bit 10mm the other day during a job so I typed in G0 X10 expecting the bit to move slightly... as it continued way past where expected and scratched the surface... I realized by buddy had typed in G20 because he prefers inches.

I thought it would be good to have some obvious icon in the pyVCP panel to catch my eye... more than just the text in the little display box that is easily missed. I was hoping for a more "stock" solution... something I could just share with others like, "paste this into your pyVCP panel and you are good." But perhaps this is better... it may force me to learn new tools... new skills, and get a bit deeper into the system.

I'll give it a try sometime this week and report back.

Thanks!
Jerry

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

More
9 years 11 months ago #83398 by Todd Zuercher

cmorley wrote: Here is working sample code of a python component for metric (G20/21) status
The python component info is somewhat explained here:
www.linuxcnc.org/docs/2.7/html/hal/halmodule.html
name it metric_status , add it into an appropriate folder ($PATH in a terminal should show you)
and make it executable

One caveat, displayed Gode in a running linuxcnc program, can be wrong because of read ahead.
This one is fairly safe as not too many people change the units mid program.


Wouldn't it make more sense to pole the stat.program_units rather than trying to pick out the active g-code something like this?
Code:
#!/usr/bin/env python import linuxcnc import hal,time metric = False h = hal.component("unit_status") h.newpin("out", hal.HAL_BIT, hal.HAL_OUT) h.ready() status = linuxcnc.stat() try: while 1: # update once a second time.sleep(1) # poll current status status.poll() # check program units if status.program_units == 2: metric = True if status.program_units == 1: metric = False # Update pin h['out'] = metric except KeyboardInterrupt: raise SystemExit

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

More
9 years 11 months ago - 9 years 11 months ago #83402 by Askjerry
Ultimately, it would be nice if this were a signal standard in HAL.

For example, there is a signal I use called halui.program.is-running which lights up a red bar where the jog buttons of my panel are... at a glance, I can tell that I have some background task running, and that I have to wait. Really simple to implement.

I was hoping there would have been something like halui.units.mm and/or halui.units.inch that I could look for and react to. Generally... to share my advanced pyVCP panels with others. (Doing a YouTube series on LinuxCNC currently.)

So mostly... looking for something a neophyte could easily do. Still wondering if I can somehow hook the #<_metric> variable.
Jerry
Last edit: 9 years 11 months ago by Askjerry.

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

More
9 years 11 months ago #83416 by cmorley

Askjerry wrote: Ultimately, it would be nice if this were a signal standard in HAL.


I was hoping there would have been something like halui.units.mm and/or halui.units.inch that I could look for and react to.


I would assume that because of the read ahead problem - these type of signals were not made.
There is a branch in development that tries to fix the read ahead problem. If this gets merged in the future then pins with this kind of
info would make much more sense.

Chris M

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

More
9 years 11 months ago #83417 by Askjerry
The read-ahead shouldn't make much difference... it is more of a flag, it is more of a flag when in manual entry mode so you don't type G0 X10 expecting 10mm and get a surprise when it goes 10 inches instead.

When code is running... you are more or less just watching the show... it's when you are manually doing things... that's when it gets interesting.

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

More
9 years 11 months ago #83418 by cmorley
it can be important if you stop/abort a program and then restart in the middle.
I agree that metric/imperial settings are rarely changed in the middle of a program.

Chris M

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

Time to create page: 0.238 seconds
Powered by Kunena Forum