05-20-2009 06:01 PM
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
05-20-2009 06:38 PM
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.
05-20-2009 09:20 PM
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
05-20-2009 09:58 PM
05-21-2009 12:47 AM
05-21-2009 03:56 AM
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
05-21-2009 04:19 AM - edited 05-21-2009 04:22 AM
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.
05-21-2009 08:17 AM
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.
05-21-2009 10:48 AM
You are right; I moved the initialization logic outside of the state loop.
Thanks everyone for all of your responses!