LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine: do I need to pass a reference for VISA session?

First of all, I'm a newbie to LabVIEW, so the question might not even make sense; my apologies if this is the case.  I'm trying to implement a very basic state machine that first initializes a COM port.  I created a VISA session constant "COM3" in an "Initialize" state.  Suppose I wish to then move on to another state and write data to COM3.  Do I need to pass the VISA session into a shift register? If so, should I create a second shift register, or is it possible to create a 'state-name-enum + VISA session' cluster?

 

Thanks for any help,

Sam 

0 Kudos
Message 1 of 9
(3,321 Views)

You can do either. If you use a second shift register then you have to make sure it gets wired through for each state.** If you use a cluster use a cluster to store state name + state data you just need to bundle/unbundle each time you need to access it.

 

** A "Wiring Tunnel Wizard" used to float around that could do this for you automatically.  Do a search and you should be able to find it.

0 Kudos
Message 2 of 9
(3,313 Views)

And you should have your error wire flowing through yet another shiftregister (it is considered good style not to mix the error wire with other data).

 

Felix

0 Kudos
Message 3 of 9
(3,300 Views)
I still contend that Error wires should not be passed through shift registers.  Unless you handle the error properly at the end of each loop iteration, an unhandled error would get passed to the next loop iteration through the shift register and cause all susequent iterations of the loop to not function properly as many LabVIEW functions will not do anything if they have an incoming error.
0 Kudos
Message 4 of 9
(3,295 Views)
Just curious is there a requirement that it bein a state machine? Do you plan on opening and closing the visa session multiple times while your program is running. Someone correct me if I'm wrong, but if it will be opened only once, and remain open, wouldn't it make more sense to just open the visa session once outside the loop, then close it when the loop exits? I know this isn't specifically answering your question but I thought I'd ask/clarify.
0 Kudos
Message 5 of 9
(3,288 Views)

To Ravens Fan:

 

I normally have a error handling state inside the SM, so I need to pass the error to that state via SR. Each iteration I check for the error and go to the error handling state if needed.

 

Felix

0 Kudos
Message 6 of 9
(3,272 Views)

for(imstuck) wrote:
Just curious is there a requirement that it bein a state machine? Do you plan on opening and closing the visa session multiple times while your program is running. Someone correct me if I'm wrong, but if it will be opened only once, and remain open(I should add...AND always communicating on COM 3) Then there is no need for shift registers for your COM port wire correct? Only error. I know this isn't specifically answering your question but I thought I'd ask/clarify.
Message Edited by for(imstuck) on 05-21-2009 04:22 AM
0 Kudos
Message 7 of 9
(3,268 Views)

F. Schubert wrote:

To Ravens Fan:

 

I normally have a error handling state inside the SM, so I need to pass the error to that state via SR. Each iteration I check for the error and go to the error handling state if needed.

 

Felix


Excellent.  It sounds like you would have no problems then.  I just see many examples where people do use the SR on the error wire, but they aren't doing anything special to handle the errors.

0 Kudos
Message 8 of 9
(3,253 Views)

You are right; I moved the initialization logic outside of the state loop.

 

Thanks everyone for all of your responses! 

0 Kudos
Message 9 of 9
(3,231 Views)