Parameters to classicladder possible?
14 Feb 2020 19:30 #157369
by 3D-Master
Parameters to classicladder possible? was created by 3D-Master
Hello,
i want to switch a "image bit" with the parameter for the rotation around the z axis in the current coordinate system but neither do i find this parameter nor do i think it is possible because these parameters have a rhombus (#) so linuxcnc would not read this line.
is there any hal pin for rotation around z in the current coordinate system?
how could this be done?
i thought about comparing the value of this parameter in classicladder and if it is 0 then it should not output a signal.
i want to switch a "image bit" with the parameter for the rotation around the z axis in the current coordinate system but neither do i find this parameter nor do i think it is possible because these parameters have a rhombus (#) so linuxcnc would not read this line.
is there any hal pin for rotation around z in the current coordinate system?
how could this be done?
i thought about comparing the value of this parameter in classicladder and if it is 0 then it should not output a signal.
Please Log in or Create an account to join the conversation.
14 Feb 2020 19:34 #157371
by cmorley
Replied by cmorley on topic Parameters to classicladder possible?
Can you restate what you want to do - assuming I don't know what you are talking of.
You need to know if the coordinate system is rotated via a HAL pin?
Chris
You need to know if the coordinate system is rotated via a HAL pin?
Chris
Please Log in or Create an account to join the conversation.
14 Feb 2020 20:53 #157376
by 3D-Master
Replied by 3D-Master on topic Parameters to classicladder possible?
at work we use Heidenhain controllers which lets you know if there is a rotation around the z axis by showing you a small icon. I want to create something similar for my machine. I have already implemented the "image bit" and can switch the images using halshow and setp.
for that to work automatically i need to use a pin which has the rotation value for the active coordinate system, which i can feed into classicladder.
it is just a small gimmicky bit i want to have but if it is not possible then it is okay (meaning it is not neccesary)
for that to work automatically i need to use a pin which has the rotation value for the active coordinate system, which i can feed into classicladder.
it is just a small gimmicky bit i want to have but if it is not possible then it is okay (meaning it is not neccesary)
Please Log in or Create an account to join the conversation.
15 Feb 2020 00:34 #157392
by cmorley
Replied by cmorley on topic Parameters to classicladder possible?
Thanks for explaining again.
You can do this by building a python component that monitors linuxcnc's status of rotation_xy and then outputs the status on a HAL pin.
or if you already are using a gladevcp panel with a python handler file you could add the same idea there.
linuxcnc.org/docs/2.8/html/config/python...xcnc_stat_attributes
linuxcnc.org/docs/2.8/html/hal/halmodule.html
Chris
You can do this by building a python component that monitors linuxcnc's status of rotation_xy and then outputs the status on a HAL pin.
or if you already are using a gladevcp panel with a python handler file you could add the same idea there.
linuxcnc.org/docs/2.8/html/config/python...xcnc_stat_attributes
linuxcnc.org/docs/2.8/html/hal/halmodule.html
Chris
The following user(s) said Thank You: 3D-Master
Please Log in or Create an account to join the conversation.
15 Feb 2020 00:38 - 15 Feb 2020 00:38 #157393
by cmorley
Replied by cmorley on topic Parameters to classicladder possible?
If you are using 2.8+ Gstat has a 'current-z-rotation' message which may be somewhat easier to use.
you could probably adapt this sample:
linuxcnc.org/docs/2.8/html/gui/GStat.htm...mponent_code_pattern
you could probably adapt this sample:
linuxcnc.org/docs/2.8/html/gui/GStat.htm...mponent_code_pattern
Last edit: 15 Feb 2020 00:38 by cmorley.
The following user(s) said Thank You: 3D-Master
Please Log in or Create an account to join the conversation.
15 Feb 2020 12:04 #157426
by 3D-Master
Replied by 3D-Master on topic Parameters to classicladder possible?
thank you, i will have a look at it
Please Log in or Create an account to join the conversation.
15 Feb 2020 13:52 - 15 Feb 2020 13:53 #157437
by 3D-Master
Replied by 3D-Master on topic Parameters to classicladder possible?
i have edited the example and i am 99% sure there is something wrong because i am a python noob:
do i need to "compile" the python file or can i just put it somewhere and call it via a M code? Then how is the newly created pin called? h.rotation_z.out?
btw i am using pyvcp, not gladevcp
#!/usr/bin/env python
import hal
from hal_glib import GStat
import gobject
GSTAT = GStat()
# callback to change HAL pin state
def mode_changed(obj, data):
h['rotation_xy'] = data
# Make a component and pins
h = hal.component("metric_status")
h.newpin("rotation_xy", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
# connect a GSTAT message to a callback function
GSTAT.connect("metric-mode-changed",mode_changed)
# force GSTAT to initialize states
GSTAT.forced_update()
# loop till exit
try:
gobject.MainLoop().run()
except KeyboardInterrupt:
raise SystemExit
do i need to "compile" the python file or can i just put it somewhere and call it via a M code? Then how is the newly created pin called? h.rotation_z.out?
btw i am using pyvcp, not gladevcp
Last edit: 15 Feb 2020 13:53 by 3D-Master.
Please Log in or Create an account to join the conversation.
15 Feb 2020 14:23 - 15 Feb 2020 15:02 #157441
by cmorley
There are two pins; one for the angle, one for 'is-rotated' (bool pin)
The component will be called 'z_rotation'
Save the program as z_rotation.py in your config folder
load the component with 'loadusr python z_rotation.py'
Chris
Replied by cmorley on topic Parameters to classicladder possible?
#!/usr/bin/env python
import hal
from hal_glib import GStat
import gobject
GSTAT = GStat()
# callback to change HAL pin state
# there is a current angle status pin and an is-rotated bool pin
def angle_changed(obj, data):
h['z-rotated-angle'] = data
if data == 0:
h['z-is-rotated'] = False
else:
h['z-is-rotated'] = True
# Make a component and pins
h = hal.component("z_rotation")
h.newpin("z-rotated-angle", hal.HAL_FLOAT, hal.HAL_OUT)
h.newpin("z-is-rotated", hal.HAL_BIT, hal.HAL_OUT)
h.ready()
# connect a Z rotation message to the callback function
GSTAT.connect("current-z-rotation", angle_changed)
# force GSTAT to initialize states
GSTAT.forced_update()
# loop till exit
try:
gobject.MainLoop().run()
except KeyboardInterrupt:
raise SystemExit
There are two pins; one for the angle, one for 'is-rotated' (bool pin)
The component will be called 'z_rotation'
Save the program as z_rotation.py in your config folder
load the component with 'loadusr python z_rotation.py'
Chris
Last edit: 15 Feb 2020 15:02 by cmorley.
The following user(s) said Thank You: 3D-Master
Please Log in or Create an account to join the conversation.
15 Feb 2020 15:01 #157443
by 3D-Master
Replied by 3D-Master on topic Parameters to classicladder possible?
Thank you,
the component works like expected but when i want to connect the pin (halshow says the pin is named: z_rotation.z-rotated-angle)
i get an error saying the pin "z_rotation.z-rotated-angle" does not exist. i tried using ".out" and ".h" but it didnt work.
The component is loaded first and then the pin is being searched.
the component works like expected but when i want to connect the pin (halshow says the pin is named: z_rotation.z-rotated-angle)
i get an error saying the pin "z_rotation.z-rotated-angle" does not exist. i tried using ".out" and ".h" but it didnt work.
The component is loaded first and then the pin is being searched.
Please Log in or Create an account to join the conversation.
15 Feb 2020 15:10 #157446
by cmorley
Replied by cmorley on topic Parameters to classicladder possible?
sounds like a race condition.
How did you load the program and connect the pins - what file - you may need to use the -wn option to make HAL wait till the pins are made.
loadusr -Wn z_rotation python rotation.py
Chris
How did you load the program and connect the pins - what file - you may need to use the -wn option to make HAL wait till the pins are made.
loadusr -Wn z_rotation python rotation.py
Chris
Please Log in or Create an account to join the conversation.
Time to create page: 0.077 seconds