From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reinitializing state machine loop during user interaction

Hi All,

 

I am currently working with the Shimmer bluetooth accelerometers and using their stock VI's provided. My goal is to modify their multi device stream VI so that I could:

1) Stream accelerometer data and audio when I press a start button

2) write accelerometer data and sound file when I press the stop button

3) reinitialize waveform graphs and clear data so that a new collection can occur when I press start again. This would occur maybe 4 or 5 times so I thought I could collect accelerometer/audio data for 5 separate occasions that would happen sequentially (5 trials of walking and talking repeated).

 

I have step 1 and 2 completed but step 3 I am not sure how to do or where to begin. Ideally, I would stay in the subvi and not have to re-enter each time i would like to collect since the bluetooth connection would be lost but I am not even sure if this is possible. Could someone please advise or point me in a direction? I have attached the VI but it will not be functional without the rest of the VI's or the accelerometers themselves.

 

Any help would be greatly appreciated. Thanks!

 

Anton

0 Kudos
Message 1 of 6
(2,857 Views)

You say you have a state machine.  But I don't see it in the VI you attached.

 

I do see a string value that is stored in a shift register, that is branched all over to many places to small case structures.  But that is not a state machine.

 

If you had an actual state machine, all you would need is to have an Initialized state that you could call at the beginning of the programming, and call again whenever you need to.

0 Kudos
Message 2 of 6
(2,849 Views)

Anton,

 

First, that does not look much like a state machine.  Look at the Design Patterns which come with LabVIEW to see how to implement a state machine.

 

Next, most of the action is in the missing subVIs so it is impossible to answer your question specifically.

 

The use of references rather than wiring values from control terminals is usually asking for trouble. It definitely makes it muche more difficult to see what is going on in the program.  The use of Value property nodes is orders of magnitude slower than passing the values directly via wires. It may also create race conditions.

 

Having an event structure in the same loop with a lot of other code can also lead to problems. It precludes the use of Latch when Pressed mechanical action on buttons. The progam may lock up while waiting for an event.

 

Lynn

0 Kudos
Message 3 of 6
(2,842 Views)

Does the code actually work? You seems to be dequeing the same queue in several places in parallel. Seems very unpredictable.

 

Which part of the gigantic diagram is the problem location you are talking about?

 

0 Kudos
Message 4 of 6
(2,840 Views)

Hi All,

 

Thanks for the quick response. I realized yes, this actually isn't a state machine. I was confused whether this is a modification of the QSM-PC architecture and that is why I referred to it as a state machine.

 

The VI does work - connects to the accelerometers and streams data and audio for the initial event of start and stop. From what I understand of how block diagrams should be assembled, this VI is not ideally structured but because it is a stock VI from Shimmer, I am hesititant to change the code drastically especially if I seldomly use qeues as such. The bulk of my LabVIEW programming is creating small programs for use in a human movement lab.

 

Is there a way to attach a zipped folder or post it? I have tried multiple times to attach the entire shimmer folder to this message but I can't post the message.

 

Thanks again.

 

Anton

0 Kudos
Message 5 of 6
(2,806 Views)

Here I think I am able to attach now

 

 "C:\.....\ShimmerSensing\Public\Examples\Multi Shimmer Template_stream.vi" Labview 2014

 

0 Kudos
Message 6 of 6
(2,802 Views)