10-04-2012 03:55 AM - edited 10-04-2012 03:56 AM
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
Solved! Go to Solution.
10-04-2012 05:00 AM
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 🙂
10-04-2012 05:38 AM
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.
10-04-2012 05:40 AM
oh, I figured it out.:)