From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-13-2020 12:45 AM
Hello LabVIEW Community,
I have a code that is plotting datapoints from a delimited file as attached below.
Whenever the data is less than "-5", I have a keyboard simulation event, inside the for loop, that presses down the keys 'j' and 'k' continuously. (ASCII Code of 'j' and 'k' are 74 and 75)
However, I only want to press down both 'j' and 'k' once whenever the value is less than "-5".
For example, in the image below, I would like to press down 'j' and 'k' four times which should result in "jkjkjkjk".
I'm not really sure how to do this and would appreciate any suggestions. Thank you in advance!
10-13-2020 01:28 AM
Hi Jack,
@jackhsu66 wrote:
However, I only want to press down both 'j' and 'k' once whenever the value is less than "-5".
So you want to output some data whenever a "value" currently is less than -5 AND was greater/equal -5 before?
What about using a shift register to access the "before value"?
What about using a boolean function (like AND) to combine several boolean values?
What about using a ready-to-use function to detect such "falling/rising edge" occurances in your "value"? Ever heard of Pt-By-Pt_BooleanCrossing?
10-13-2020 03:31 AM
Hi GerdW,
Thank you for your suggestion! Really appreciate your time.
I used the "shift register" and "AND" command and was able to count places where the value is currently less than -5 and was greater than -5 before. However, I have these noises in my signal as shown below where I only want to count once. (The image shown counted 4 times).
Any suggestions on how to eliminate these noises, or just count this signal as one? Thanks!
10-13-2020 03:55 AM
@jackhsu66 wrote:Any suggestions on how to eliminate these noises, or just count this signal as one? Thanks!
A PtByPt filter should help. Probably a low pass filter, but there are many filters that would help.
Alternatively, add a shift register and only set the 'up' state if the data is up for more then n samples. That is, if x>-5, increase counter (keep counter in a shift register). If counter>10, it's considered up.
You can probably do with one shift register, by making smart use of the counter.
10-13-2020 06:30 AM
I think you should physically clean up that signal before it ever gets to the detector.
10-13-2020 07:11 AM
@billko wrote:
I think you should physically clean up that signal before it ever gets to the detector.
All positive values seem to go to the exact same value, and so are the negative values.
It looks like a digital problem to be. Parsing maybe, or an unhandled time out or bytes that get lost during acquisition?
But I agree, fixing it is better then a bandage.
You'd probably still want some kind of mechanism to prevent triggers on noise around -5. Either a counter or a asymmetric trigger (if down, go up if >-3, if up, go down if <-5).
10-13-2020 08:13 AM
@jackhsu66 wrote:
Hi GerdW,
Thank you for your suggestion! Really appreciate your time.
I used the "shift register" and "AND" command and was able to count places where the value is currently less than -5 and was greater than -5 before. However, I have these noises in my signal as shown below where I only want to count once. (The image shown counted 4 times).
Any suggestions on how to eliminate these noises, or just count this signal as one? Thanks!
Let's learn a little bit about the HARDWARE. (oh, yes the magic 8-Ball is rolling) then we can chat about shock vibration and bouncing relays. Proper electrical engineering can really help you with these pesky software problems 😉