LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Buttons and serial communication with strings

Seems easy, but isn't (for me). I want a button whose true state sends a string to the serial port, and whose false button sends a different string - BUT, I need that string sent to the serial port just ONCE. As you know, as long as the false or true condition is "current", it keeps sending that data down the pipe at a rate based on the timer in the loop. I need to use a loop to keep the program running - no setting buttons then pressing RUN, that doesn't work for us. Seems logical to use a FOR statement inside a case structure, but if it's all inside a loop, N=1 is really N=forever.

Here's what I want... Push button "in" [true], String1 is sent down the pipe ONCE and then stops sending it... push button again "releasi
ng" it [false]... P2 sent down pipe and then stops sending it.
I know this is easy to do with a PAIR of latching buttons, but the latched button gives no visual clue that it's on or off. I also don't want two butttons - one for String1 and one for String2, set to momentary - that's easy but doesn't get the point accross to the user.
Eventually, there will be eight buttons whose true values SET a bit and whose false values RESET a bit, but not in a streaming fashion. In other words, when the buttons are idle - no data is being sent down the pipe.

Two notes - on all my other hardware applications, it's no problem to keep "sending stuff" down the serial port - there's a FIFO and memort that handles it - but now I'm talking straight to a microcontroller so I have to send specific bits of data and stop. ALSO, a RING menu works FINE for my new application, but no one wants to pull down a menu and find "reset TTL 6" buried in it. So I want buttons. I for each TTL.
Richard






0 Kudos
Message 1 of 6
(4,588 Views)
It's much easier to do it in LabVIEW 6.1 and the event structure but from your previous posts I see you have an older version. I've attached a method that I think does what you want. The key is a shift register that is used to monitor changes in your boolean. Nested case statements are used. The outer case is for a change in the boolean and the inner case handles the specific strings you want to send.
Message 2 of 6
(4,588 Views)
Does this do what you want?
Message 3 of 6
(4,588 Views)
THAT WORKS GREAT. The trick was getting the TRUE and FALSE case structure inside of the TRUE ONLY condition of another case structure. I had messed with the shift registers but never quite got it to click. Thanks Dennis.
However, and on a different note, now my program will have dozens of the Serial Write VI's in it. Is this "OK". On my other programs, I generaly only have one or two Serial Writes and I concatenate strings to it. Can't concatenate with this new application. So how would I get by with just one Serial Write VI in the attached program?
THANKS AGAIN.
Richard






0 Kudos
Message 4 of 6
(4,588 Views)
That'll work too! And is much closer to what I was trying but mine didn't quite work. Dennis's code is a little more compact and also works. More than one way to skin a cat.
Thanks Parks!
Richard






0 Kudos
Message 5 of 6
(4,588 Views)
P.S. I bet it is easier with 6.1. I have 6.0.2.
From what I've read, 6.1 has those "events" which allow easier GUI development. All of my programs are very GUI intensive. I just don't think my employer will spring for the update.
Richard






0 Kudos
Message 6 of 6
(4,588 Views)