LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

best way to initialise serial comms in a state machine

Hi everyone, I have a motion reference unit (Microstrain 3DM-GX1) that I am trying to communicate with serially. I have used the serial example VI's to talk to it and everything works fine using the VISA configure serial port function.

Now I am trying to build an application around this using a standard state machine architecture and I wanted to know what is best practice for initialising my COM port.

1. Where should my VISA configure serial port code go, to the left of the while loop so it gets initialised once, or inside a "start" state, that will also run just once.

2. I have states that read and write to the serial port as the program runs, I am passing the VISA resource name with shift registers to the states that need it, is this OK?

3. I have a VISA close function outside the while loop on the right hand side being fed from the shift register, is this OK?

 

I have added my project so far if you need to see what I'm talking about, If there are any other glaring errors, feel free to let me know.

 

Many thanks

 

Karl

0 Kudos
Message 1 of 2
(2,776 Views)

1.  Either would be fine.  Though I would probably put it in a start or initialization state because it gives you the opportunity to call that state again during the middle of execution if you ever need to such as if there is a communication error, or the user needs to change the port that is being used.

2.  Yes.  You definitely want to use shift registers.

3.  Outside the loop is okay.  Though I would probably create a shutdown or exit state for the same reasons I said in #1.

Message 2 of 2
(2,741 Views)