09-12-2017 06:14 PM
@sunson29 wrote:
I just abstract the question into this simple version.
We already gave you plenty of abstracted simple answers. Please point out what's not clear to you. Here's what I would do:
Feedback node to get previous value.
Subtract old from new and wire result to sign function
Wire to case structure with three cases (-1,0,1).
One case for A, one for B, one empty for when nothing changed.
See how far you get.
09-12-2017 08:00 PM - edited 09-12-2017 08:06 PM
1. The "input" will give the 0 or 1 to the upper loop.
2. Now, I want to know how to see this before and current value. I don't know how to do this with feedback or shift register. right now, the current will be always the same as before. Could you please help me modify this vi, and load? Thank you.
09-12-2017 08:10 PM
Dear friends.
I need some help here. Thank you so much in advance. VI attached.
1. The "input" will give the 0 or 1 to the upper loop. In other words, in top while loop, "input" will keep change between 0 or 1 for each iteration.
2. Now, I want to know how to see this "before" and "current" value in top while loop. I don't know how to do this with feedback or shift register. right now, the current will be always the same as before. Could you please help me modify this vi, and load? Please do keep those 2 while loop. Thank you.
09-12-2017 10:13 PM - edited 09-13-2017 02:55 PM
One problem is that your upper loop runs millions of times per second, so the (current vs previous) reading will only be different for a nanosecond and you'll never see it. Your feedback node before the loop makes absolutely no sense at all. I really recommend you do a few more tutorials.
Here's what I would do (you can put it back in a separate loop, of course, but make sure to include a reasonable wait). As I said, if you need to execute different code parts depending on the state, wire to a case structure.
09-13-2017 01:14 AM
Why did you open a new thread and post your question twice?
09-13-2017 04:25 AM
You really should learn about and understand the dataflow concept of LabVIEW. There are some good introductory online courses on ni.com.
You should also think about another mechanism to transfer your data from your producer loop to your consumer loop (btw, that pattern is called a producer-consumer pattern and can be found under File -> New... -> From templates).
Here's a version with that pattern.
Regards, Jens
09-13-2017 10:29 AM
Thanks, Jens. Let me check this vi carefully.
09-13-2017 12:23 PM
This is slightly different from Altenbach's option. It allows for an array input.
09-13-2017 12:34 PM
Oh, thanks. could you upload the vi for me? Thank you again.
09-13-2017 12:37 PM
@Minions wrote:
This is slightly different from Altenbach's option. It allows for an array input.
Your array input is on the FOR loop, not on the change detector and thus irrelevant for the change detector code. 🙂