'clicking' checkbox on pyvcp from gcode

More
12 years 9 months ago #42963 by eslavko
Hello...

There is tested automatic switch for probe.
It's quite complex but I think I managed all event's properly.

it have two input pins:
spindle-phase-a is spindle encoder signal (I gave only phase A but quadrature should work too)
spindle-on is actualy motion.spindle-on - the signal for spindle on

and two output pins:
myprobe is filtered probe signal connected to motion.probe-input
probe-dissable when probe isn't monitored (I use this to greyout led in pyvcp)


What/how it works?

When spindle is started (spindle-on goes high) the probe-dissable is set, and myprobe keep unactive.
And this state is held until spindle-on goes false AND at least one second pass from last spindle-phase-a AND index signal is false.
Why?
Just for reason to not trigger 'probe tripped during nonprobe event' error.
As when program ends I turnoff the spindle and start jogging (or put that in code already) machine to 0.0 the spindle itself can still rotate as have high inertia. And when spindle stop it may be with phase A left in true or false. So if it's in true (aka probe hit something) the signal is not pass as it's triger error. But when I switch probe in the signal goes to false (probe not touching) and this reenable probe.

and there is program itself...
Code:
#loadrt or2 count=4 #already done elsewhere in HAL (gate 0 and 1 used) loadrt and2 count=2 loadrt edge count=1 loadrt flipflop count=1 loadrt not count=2 addf or2.2 servo-thread addf or2.3 servo-thread addf and2.0 servo-thread addf and2.1 servo-thread addf edge.0 servo-thread addf flipflop.0 servo-thread addf not.0 servo-thread addf not.1 servo-thread setp edge.0.out-width-ns 1000000000 #spindle rpm timeout setp edge.0.in-edge false #rising edge setp flipflop.0.data false net spindle-phase-a => and2.0.in0 net probe-disable <= and2.0.in1 <= not.0.out net probe-enable <= not.0.in <= flipflop.0.out net edge-in <= edge.0.in <= and2.0.out net edge-out <= or2.2.in0 <= edge.0.out net spindle-on => or2.2.in1 net ff-rst <= flipflop.0.reset <= or2.2.out net spindle-on => flipflop.0.clk net ff-set <= flipflop.0.set <= not.1.out net spindle-on => or2.3.in0 net spindle-phase-a => or2.3.in1 net inv-in <= not.1.in <= or2.3.out net probe-enable => and2.1.in0 net spindle-phase-a => and2.1.in1 net myprobe <= and2.1.out => motion.probe-input

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

More
12 years 8 months ago - 12 years 8 months ago #43542 by tomws

ArcEye wrote: Hi

If you want to use the checkbox, then you could change the way it works

The below code, substituted in pyvcp_widgets.py, will create an extra IN pin called pyvcp.{whateveryounamedcheckbox}.changepin

It toggles the state of the checkbox, when set TRUE.
(it will not toggle again until pin goes FALSE to prevent a race condition)

Activating will either check or uncheck the checkbox, depending upon its current state, user click on the checkbox will revert the state.

Code:
...code snipped...

As with all parsel-tongue, be very careful of indentation if you cut and paste this

You can amend to suit.
For instance: if you will only ever want to uncheck the box, just change the conditional test in update()
so that it only toggles the value in self.v if that value is true.

regards

EDIT added another reset of IN pin to ensure it is done, whatever the result of the conditional test


Thank you for providing this! This is just what I was looking for. I need a checkbox that I can reset after a particular operation so that the user always has to click it, if needed, before starting the operation again. I like it!

[strike]One newbie question, however. I see in the lib directory that there is a pyvcp_widgets.py file and a pyvcp_widgets.pyc file. If this change is made to the .py file, is there some kind of compile step required to make the .pyc file before it can be used?[/strike] Update: Ignore this question, I found the answer in your other posts.

Another question, however, is if, instead of 'changepin', I could simply have a 'statepin' where you can actually set the state to 0 or 1? I would think this would be straightforward, but I'm confused by the role of the 'reset' attribute... Perhaps it's to address the fact that this is toggling, rather than setting the value?


Tom
Last edit: 12 years 8 months ago by tomws. Reason: removed question answered elsewhere.

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

More
12 years 8 months ago #43546 by ArcEye
Hi

One newbie question, however. I see in the lib directory that there is a pyvcp_widgets.py file and a pyvcp_widgets.pyc file. If this change is made to the .py file, is there some kind of compile step required to make the .pyc file before it can be used?


No, just delete the old .pyc file, edit the .py file and the next time you run a new .pyc will be generated

regards

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

More
9 years 3 months ago #95909 by MadGuest
Hi, all. I use linuxcnc 2.7.0, and when I add checkbutton to my pyvcp panel, pyvcp.my-checkbutton.changepin is created, but it is always in "False" state. I tried to toggle it with MDI command like #<_hal[pyvcp.my-checkbutton.changepin]> = 1 and got an error message: "Internal error: could not assign #<_hal[pyvcp.my-checkbutton.changepin]>. Please, could someone help me to fix this issue?

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

More
9 years 3 months ago #95910 by andypugh
A checkbox is a control. Do you want a control, or an indicator? It sounds like you want an indicator.

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

More
9 years 3 months ago #95920 by MadGuest
For indicator I can use LED ))) Checkbutton will be used as control. I want to skip some part of gcode if checkbutton is checked, but also I want to toggle it off when I run code first time.

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

Time to create page: 0.400 seconds
Powered by Kunena Forum