The PROBE
-
Bouncing is bad.
I started to use the probe... which for now is a piece of wire sticking down... hey, it's just for testing.
I have a switch on the desk in my office to test my routine... and it works great. But then I take the same code and put it on the big machine in the garage... and it is not too happy. I start getting an error something like "
Probe tripped during a non-MDI command" Or basically... it is getting a noisy signal and counting multiple hits instead of a single contact. The fix is to tell it after the initial reading... ignore it for a period of time. That's called
DEBOUNCE.
I pulled up the HAL Manual, section
9.6 Debounce and started reading... I was only getting about 30% of what it said... very confusing. Then I read other threads and started to piece it together. The manual has...
halcmd: loadrt debounce cfg=<config-string>
Which means... load debounce, configure it for some number of filters.... in my case... I only need one.
Code:
loadrt debounce cfg=1
Okay... that loads it... but next I need to configure it, then assign it to a pin or signal... that gets a bit interesting. And the manual... well... not very friendly...
(s32) debounce.
.delay
I had to kludge it together from different posts... but here is what I got...
I was connecting my probe to
pin #15 of the parallel port... and I wanted it inverted... so internally that is called
parport.0.pin-15-in-not by the system. I needed to filter that signal... point it to the input of the debounce routine. Then... the actual probe signal (
now debounced) gets sent to
motion.probe-input.
Um... yeah... ok... here is the
original code in my
custom_postgui.hal file...
Code:
#-----------------------------------------------------------------------------------
# connect the REAL probe to the parallel port inverted pin.
net real-probe parport.0.pin-15-in-not => motion.probe-input
# Connect the probe image bit
net probe-image parport.0.pin-15-in => pyvcp.probe-image
#-----------------------------------------------------------------------------------
And this is the
code after modification... with a filter of
100 threads... there is a bunch of math to calculate actual time... but 100 is a nice round number... so I'm gonna try it.
Code:
#-----------------------------------------------------------------------------------
# Install a DEBOUNCE filter for the probe
loadrt debounce cfg=1
addf debounce.0 base-thread
setp debounce.0.delay 100
net probe-raw parport.0.pin-15-in-not debounce.0.0.in
# connect the REAL probe to the parallel port inverted pin after debounce.
net real-probe debounce.0.0.out => motion.probe-input
# Connect the probe image bit
net probe-image parport.0.pin-15-in => pyvcp.probe-image
#-----------------------------------------------------------------------------------
It works on my bench... and at
5:09 AM... I'm going to wait until daylight to try it on the actual machine.
So fingers crossed... and hoping to have
MONSTER V7 to upload shortly.