From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Problem updating my state machine, using emg signal

Solved!
Go to solution

Hi

I'm having trouble with my code. My input is an EMG signal that I gather from three different electrodes using usb 6008. In the program I devide the signals and display them in a graph of their own. What I now want to do is to read the signal, and if a signal passes a threshold I would like a LED to come on. This should stay lit until there is another signal that passes the threshold.

 

 

To put it simply: "big enough signal-->lamp on-->stay lit-->big enough signal-->lamp off-->stay off, and then start over.

 

I've tried some different approaches, but I decided on using a state machine. The problem now is that when the signal enter the state machine the program freezes. I believe this is because the array I am using to convert the waveform won't update when I enter my state machine, thus the signal stops coming. But how do I get around this problem? Is it even possible to code what I want? 

 

I've attached the code. All tips are welcome, I've been struggling with this for quite some time now.

 

thanks

jenmich

0 Kudos
Message 1 of 4
(2,420 Views)
Solution
Accepted by topic author Chrisi76

The problem is the inner while loop wants to run until a the stop condition is true, but it never gets a new boolean input. So it stays in the same state forever. Remove the inner loop, and put the shift reigster on the outer loop instead. 

 

You should also use a daqmx configure element, and set the daq properties. The read.vi can be set to read a certain number of samples each iteration.

 

Also: you can expand the index array to output more than one element. if you want element number 0, 1 and 2, you don't even have to wire the index inputs 🙂

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 2 of 4
(2,412 Views)

Thank you so much for your quick reply. The inner loop was removed (I tried doing that earlier, but I must have done something wrong cause it didn't work then,) Now with only one while loop and the case structure the program will run once. The lamp will switch on just as it's supposed to, and then switch off when it's supposed to. But it will only happen once. 

I'm sure I've made some simple mistake, but I am very new to labview.

 

thanks again.

0 Kudos
Message 3 of 4
(2,408 Views)

oh, I figured it out.:)

0 Kudos
Message 4 of 4
(2,407 Views)