trouble getting hal_hscale1 value in py handler

More
28 Nov 2013 21:52 #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.

More
29 Nov 2013 23:06 #41222 by mhaberler
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
30 Nov 2013 10:43 #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
30 Nov 2013 11:57 #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.

More
30 Nov 2013 17:25 #41245 by mhaberler
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
30 Nov 2013 18:34 #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.

More
30 Nov 2013 19:49 #41251 by cmorley

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 :(


Not sure if your using 2.5.3 or master.
If using master you can set the RPM within linuxcnc.command

self.linuxcnc.command.spindle(direction, rpm);

direction would be 0, 1 or -1

Chris M

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

More
30 Nov 2013 19:59 #41252 by btvpimill
more stuff I forgot to tell.

I am using 2.5.3

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

More
01 Dec 2013 02:23 - 01 Dec 2013 02:24 #41269 by eszyman
Humm,
another way to look at this is our spindle is controlled directly via a hal signal linked off the spindle-cmd and spindle-enable pins.
in our hal file we have:
# spindle on / off
net spindle-enable <= motion.spindle-on => ourbox.0.pin-25-out
# spindle speed control
net conv1 conv-float-u32.0.in motion.spindle-speed-out
net c-spindle-cmd <= conv-float-u32.0.out => ourbox.0.spindle-speed-out

So our spindle-speed-out accepts values from 0 to 20000. The issue we have here is that the spindle will not start until we have a minimum value of 5000.
Now we are trying to creating our own glade spindle button much like that of Axis, because when we click the axis spindle start button we need to click the '+' button at least 50 times... haha!

It would seem a trivial task to make a python interface layer to set out spindle speed out to 5k to 20k via our slider to turn on our spindle. If we go the MDI route axis complains the machine must be in MDI mode to turn on / off the spindle and looks kinda clunky. Perhaps not.

Maybe there is an easier work around to better configure the axis buttons?
(This solution is not ideal however because we have the same issue for hot wire control, only in this case the axis button does not exist)
Last edit: 01 Dec 2013 02:24 by eszyman.

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

More
02 Dec 2013 13:03 #41291 by eszyman
Can anyone point me in a direction to see an example where a hal float style pin is set to a given vale or changed through python? is this even possible?

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

Moderators: mhaberlerHansU
Time to create page: 0.162 seconds
Powered by Kunena Forum