- Posts: 39
- Thank you received: 0
'clicking' checkbox on pyvcp from gcode
I have run out of input pins so I share spindle rpm sensor and probe input.
At hardware when I attach probe the spindle rpm is just broken. It's works ok.
Now In pyvcp I had the checkbox to tell when probe is attached. So when I attach probe I need to make click to inform that probe is in.
Now the quiestion? How I can simulate click in pyvcp checkbox from G code?
Ie if I attach probe and run hole center for example I want to program do the click before exec G38 and after that to unclick the box.
I can't just tied input to encoder-A and probe as I get probe tripped in non probe move...
(wan't to keep manual acess too)
Please Log in to join the conversation.
You may need to look at it another way, a checkbox is not too useful an indicator as it just has an OUT pin
Even if you added an IN pin, how would you tell which took priority to set the state?
If you had a LED and a switch for the user input, you could put the switch though a logic component and set the other pin via GCode
(halcmd setp and2.0.in1 1 for instance) , with the output to the LED
Then for instance the Gcode value setting would have to be the same as the user (for and2) , to light the LED.
I assume you have other stuff linked to the signal that would now go to the LED, that deselects probe and re-connects spindle
Just an idea
regards
Please Log in to join the conversation.
parport pin is connected to encoderA permanently.
But it's connected to motion.probe.input trought AND gate.
So if enable-probe check is clicked then motion.probe.input gets the
pin value, and same is showed in pyvcp led too.
It works nice.
Of course I can just make other led for enable-probe and change that net
with setp. But then I can't manualy switch the option. So I like to keep
signal as checkbox, but need to find a way to change it's state within
G-code program if it's possible at all.
pyvcp code...
pyvcp postgui.hal
HAL
Please Log in to join the conversation.
eslavko wrote: I have run out of input pins so I share spindle rpm sensor and probe input
You only care about the spindle speed when the spindle is on. So forget the checkbox, do it all automatically with the spindle.is-on signal
loadrt and2 count=2
loadrt not count=1
net probe-index parport.0.pin-99-in and2.0.in0 and2.1.in0
net spindle-on motion.spindle-on and2.0.in1 not.0.in
net spindle-not-on not.0.out and2.1.in1
net spindle-index and2.0.out encoder.0.index
net probe-pin and2.1.out motion.probe-in
Please Log in to join the conversation.
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.
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
Please Log in to join the conversation.
andypugh wrote:
eslavko wrote: I have run out of input pins so I share spindle rpm sensor and probe input
You only care about the spindle speed when the spindle is on. So forget the checkbox, do it all automatically with the spindle.is-on signal
loadrt and2 count=2
loadrt not count=1
net probe-index parport.0.pin-99-in and2.0.in0 and2.1.in0
net spindle-on motion.spindle-on and2.0.in1 not.0.in
net spindle-not-on not.0.out and2.1.in1
net spindle-index and2.0.out encoder.0.index
net probe-pin and2.1.out motion.probe-in
Hmm...
Automatic switchower seems nice, but I see the folowing problem:
at the end of program I have mostly like these:
M5 #spindle off
G0 Z100
G0 X0 Y0
So when program hit M5 the spindle is switched off (got signal that doesn't run)
but spindle still turns due to inertia. and when hit G0 Z100 will throw probe triggered during nonprobe move.
But I like that idea...
Probably I need to insert some monostable to be triggered with spindle pulses.
will check that...
Please Log in to join the conversation.
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...
Please Log in to join the conversation.
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
Please Log in to join the conversation.
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 to join the conversation.
Please Log in to join the conversation.
