LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Latching a button, and loop issues

Hi guys. Appreciate the help as always. I am still a beginniner and have another question or two for you 🙂

 

So my program is pretty simple.

Using VISAs, I am able to read and write data from Xbee modems. Works well, however the main problem I have is with very slow running loops. The Xbee is only sending data such as "255" and "249" and possibly a few other numbers like that. The problem with my program is that the loop only runs once every  two seconds because of some kind of time-out issue. The VISA in the LabView program waits for a certain amount of bytes before it proceeds (I believe) so what I did in the program is add a length function so that the VISAs would only wait for the appropriate amount of data being sent and not time out. I'm wondering if anyone can help me with this/understand what I'm saying.

 

 

My second question is more simple and uses really basic logic but I can't seem to find the correct LabView function. 

Say another Xbee sends 255 or 249 to the Xbee with LabView attached. Once it receives 255, I would like it to latch my "Valve Control Button" but I cannot do that because I cannot make this button a mechanically latched button while using local variables. Does anyone know a way around this? Our Xbee devices can send "249" repeatedly, which in turn works because it willl keep the button in the correct state, but they only send "255" once.

 

I have attached pictures and the program and hope someone can help us out. Thank you!

Download All
0 Kudos
Message 1 of 25
(4,107 Views)

For you first problem does your modem send a standard end of message character?  If yes I would recommend writing a sub vi that read 1 byte at a time and looks for termination character.  If not you can change the time out property using a property node , however the only reason it would time out is if it doesn’t get the number of bytes it expects, I don’t recommend this method.  On a side note, in both of you cases you are expecting 3 bytes so I would just wire 3 directly to the visa read.

 

For you second problem I would recommend that you figure out how to do this without using local variable.  From your code it looks like you should be able to just directly wire this.  I would suggest you get rid of all the local variables in your code you don’t need them.

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 2 of 25
(4,078 Views)

Okay thanks.

 

My next question is simple logic, but I'm confused on what LabView nodes to use.

 

If the LabView VISA read receives the character "A' then I want it to activate the button (or latch it).

If the LabView VISA read receives the character "B" then I want it to deactivate the button.

 

The logic is simple but I'm just lost. Basically:

 

if (visaread = "A")

then

valveButton = 1;

else if (visaread ="B")

then

valveButton = 0;

end if

 

but in LabView form. I know I am using a case selector to OUTPUT characters to the VISA but when I am receiving data to the VISA how do I use logic to execute something based on what the VISA reads?

0 Kudos
Message 3 of 25
(4,054 Views)

Why are you trying to latch a button?  Is this also something that user might be clicking?  If not then you should either have an indicator to display the value to the user, or just use a wire to use the value in the program.

 

Just wire whatever you read from VISA to a case structure and create a case for each message.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 4 of 25
(4,046 Views)

Hi - yes. There is a seperate handheld device that also controls another device that this LabView is controlling/monitoring. We don't have time to make it foolproof so basically the handheld should have simple over ride. So I want it to be able to latch that button.

 

Like I said I understand the logic of reading the VISA but I just don't get how to set it up.

 

If you look at my screenshot, you can see the case structure I'm using to SEND data, but how do I set one up that is READING data. 

 

So if readbuffer = 255 then the case is true, and if it is 249 then the case switches to false. How do you do that exactly? I realize it is as basic as it gets.

0 Kudos
Message 5 of 25
(4,037 Views)

Send the read string to a case and have the cases 255 and 249.

 

You have a race condition with your Enable on. Just wire the enable button directly, wires can split. 😉 

 

You often need a small wait between write and read, but since you know the answer length (is it really supposed to answer with the same string?) it shouldn't be needed.

 

Latching buttons return to default state when read. If you want to set the button it cannot be latching.

 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 25
(4,027 Views)

How would you guys recommend taking multiple data coming in and splitting it up for various purposes?

 

For example, to keep it simple, when Xbee sends the strings A or B, A will turn something on, B turns something off. Easy enough.

 

But we also want to use the Xbees as pressure monitors. So if Xbee will also send values from 0-40 (tire pressure values) how can I seperate this information? I have a graph set up that currently reads from the buffer, but if it gets values like A and B it will have an error. How can I program that the numbers 0 to 40 should be plotted while A and B are just treated as the on and off values. Lots of cases? Must be a simpler way.

0 Kudos
Message 7 of 25
(4,003 Views)

If you have those 3 version you can have 3 cases, A, B and default, in which case you use string to number e.g.

3  cases ofc meaning 1 case structure with 3 cases, not 3 case structures. 🙂 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 25
(3,993 Views)

Awesome, I will try that.

 

My final question, hopefully.

 

I really really really need to tackle this problem of my loop being extremely slow, because the Xbee or VISA (not sure which controls this) is timing out due to receiving different amounts of bytes. In the VISA read there is the "byte count" input. I still have no idea how to make it read the correct amount without setting it to a constant. 1 or 3 was fine for testing, but now I will have "A" "B" and the numbers 0-40 (as string values though) coming in. How on earth do I set up this byte count so that I am not having 2 second delays per loop iteration?

 

Thanks guys again.

0 Kudos
Message 9 of 25
(3,975 Views)

If you are controlling the data coming in you should add an end of message character and use that to know when a full message has been received.

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 10 of 25
(3,971 Views)