trouble getting hal_hscale1 value in py handler

More
12 years 11 months ago #41211 by btvpimill
after searching for the answer, I turn to the experts. I am trying to get the value of hal_hscale1 in my python handler.
from what I can find, I thought it would be :
hal_hscale1.get() maybe
or just
hal_hscale1

I get the same error message -
Name error : hal_hscale1 is not defined

When I check in show HAL configuration, hal_hscale1 is there and changes as I move the slider. Can anyone help me get past this seemingly easy issue?

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

  • mhaberler
  • New Member
  • New Member
More
12 years 11 months ago #41222 by mhaberler
Replied by mhaberler on topic trouble getting hal_hscale1 value in py handler
you find that out by looking up the object hierarchy, and the pygtk manual

so: a HALscale is a GtkScale

for GtkScale we find: www.pygtk.org/docs/pygtk/class-gtkscale.html
the value is held by the parent Range widget
so we look that up and find www.pygtk.org/docs/pygtk/class-gtkrange.html

so get_value() is the right method

-m

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

More
12 years 11 months ago #41238 by btvpimill
Thank you M, the depths of my non understanding seem to be endless. But I have somehow gotten something from reading the 2 links provided.

in this :

def on_hal_hscale1_value_changed(self,obj,data=None):

I was trying to get the value like this:

hal_hscale1.get_value()

but I see I needed to use:

obj.get_value()


Now it is working. :)

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

More
12 years 11 months ago #41241 by btvpimill
now for my next question, I see how to send some spindle commands using linuxcnc.command and

spindle(SPINDLE_FORWARD) ...

but I have yet to find how to set the speed. is there a way or do I need to

halcomp[motion.spindle-speed-out] = my_speed_value

which also I have not figured out how to make work :(

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

  • mhaberler
  • New Member
  • New Member
More
12 years 11 months ago #41245 by mhaberler
Replied by mhaberler on topic trouble getting hal_hscale1 value in py handler
can I suggest this: instead of asking rather detailed questions and we have no idea about the context - why dont you first describe what it is you are trying to achieve? Depending on that, there might be different answers.

For instance, it seems you execute this script in MDI mode (right? wrong? I cannot tell.)

if you do, see the 'c.mdi("G0 X10 Y20 Z30")' example in www.linuxcnc.org/docs/devel/html/common/python-interface.html

you could just as well execute 'c.mdi("F%g" % (myfeed))'

- Michael

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

More
12 years 11 months ago #41249 by btvpimill
Michael, I have to agree, I have provided zero context. Sorry for that

I am trying to create my own spindle control with am on/off toggle and a slider for the speed. I do not need to be in MDI mode for for my purpose. Yes I can do it using

MDI("s5000 m3")

but I was trying not to have to be in MDI mode unless that is the only option. The current axis spindle button start the spindle at 1 rpm, with 100 rpm increments. My spindle will not turn on until 5000 RPM. I was thinking the easiest way would be to do my own,

BTW, I do not have any reason for not wanting to switch to MDI, turn on the spindle, then switch back to JOG. It just seems like there must be a way to do it directly.

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

Moderators: HansU
Time to create page: 0.067 seconds
Powered by Kunena Forum