Pass initial values to pyvcp via custom M100?

More
12 Jan 2015 16:09 - 12 Jan 2015 16:13 #54916 by TopperH
Hello everybody,

this forum helped me a lot regarding another question, so I hope that someone could help me with this one, too. ;)
I'm using Mesas 5i25 and 7i76 cards and have implemeted a custom HAL Component, that controls the analoq output. It is controlled via a litte pyvcp panel, including a checkbox for on/off, a scale-slider for the commanded voltage an a radiobox to choes the operation mode (manual control / automatic and linked to the velocity).

When I start the ngc file with the GCode, I want to pass the initial values for these vie a custom M Code, wich are then shown and changable via the pyvcp panel during runtime. Is this possible somehow?

I've tried with M100 and
#!/bin/sh
duty-cycle=$1
halcmd unlink mycomponent.0.duty-cycle
halcmd setp mycomponent.0.duty-cycle $duty-cycle
halcmd net pyvcp-duty-cycle-0 mycomponent.0.duty-cycle
exit 0
but I couldn't overwrite the Pins in the custom component.
It works this way, if I add another pin to the component, which is not linked to anything in advance.

Thanks very much in advance!! :)
Last edit: 12 Jan 2015 16:13 by TopperH.

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

More
12 Jan 2015 17:17 #54919 by ArcEye
Hi

I've tried with M100 and

#!/bin/sh
duty-cycle=$1
halcmd unlink mycomponent.0.duty-cycle
halcmd setp mycomponent.0.duty-cycle $duty-cycle
halcmd net pyvcp-duty-cycle-0 mycomponent.0.duty-cycle
exit 0

but I couldn't overwrite the Pins in the custom component.
It works this way, if I add another pin to the component, which is not linked to anything in advance.


If it is not a typo in your example, the reason you could not unlink, could be that the command should unlinkp

Also your net command is netting your component pin to a signal called pyvcp-duty-cycle-0, which will probably fail as the name exists.

should be net signalname pin1 (pin2..pin3..)

www.linuxcnc.org/docs/devel/html/hal/basic_hal.html

regards

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

More
12 Jan 2015 17:47 - 12 Jan 2015 17:52 #54921 by TopperH
Hi!

I've checked it and the unlink in my example here is a typo. I've used unlinkp in the real file. Thanks! ;)

the signal pyvcp-duty-cycle-0 is defined in the custom_postgui.hal and carries the value from the scale slider:
net pyvcp-duty-cycle-0 mycomponent.0.duty-cycle <= pyvcp.pyvcp-duty-cycle-0

in the gui .xml file I have a
<scale>
        <halpin>pyvcp-duty-cycle-0</halpin>
        ...
</scale>

So as I could not setp a linked pin, my thoughts were to unklinkp it, set the initial value and then relink it to the signal coming from the Gui Control.
Maybe this is wrong, because the Pin is then immediately set to the actual scale value (0)?
If so, is it possible to set the scale to the initial value from the M100 as well?
Last edit: 12 Jan 2015 17:52 by TopperH.

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

More
12 Jan 2015 18:18 #54924 by ArcEye

the signal pyvcp-duty-cycle-0 is defined in the custom_postgui.hal and carries the value from the scale slider:


OK, rather confusing having a signal which is almost the same as the pin name.

If so, is it possible to set the scale to the initial value from the M100 as well?


Have a look at usr/share/doc/linuxcnc/examples/sample-configs/pyvcp

I made quite a few changes to pyvcp some while back, including the addition of a param-pin to a lot of widget like spinboxes.
This pin enables the initialisation and remote setting of the widget using that pin.

Used with something like my parameter-saver component for example, you can initialise all the widgets at start up and then save values at shutdown
mgwareDOTcoDOTuk > Hal Components > Parameter Saver

You may even find it can be done more simply without a M code, just directly from widget to component and vice versa, depends exactly what you are trying to achieve

regards
The following user(s) said Thank You: TopperH

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

More
12 Jan 2015 19:03 #54926 by TopperH
Thank you very much, that param-pin did it! :)

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

More
12 Jan 2015 21:01 #54932 by TopperH
Next question. ;) Is there some kind of param_pin for the radiobutton, too?

The checkbutton has the changepin function, which offers enough functionality, but I couldn't figure out how to control the radiobutton...

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

More
12 Jan 2015 21:43 #54936 by ArcEye

Is there some kind of param_pin for the radiobutton, too?


Afraid not, you can just pre-select which button is active at the start up.

As you say, the checkbutton can be set remotely

regards

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

Time to create page: 0.088 seconds
Powered by Kunena Forum