LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A multifunction DAQ state-machine

Hello.

 

I am trying to build a state-machine that shifts between different read and write modes. I want to be able to switch between read only and writing different signals. It should be fairly easy to see from the code I hope.

 

The problem is that for some reason I cannot switch between signals without getting errors. First I got an error saying that i was trying to write beyond the final sample generated, and when trying to adress this it switched to error 200479.

 

I have tried several different setups and moved the start and stop task vi's around but nothing seems to work. I would really appreciate getting some help with this.

 

Best regards,

Felix Turner

Download All
Message 1 of 15
(5,144 Views)

Some VI's are missing and I don't have a DAQ connected so I can't test your code, but it seems to me like the "first call" functions are creating problems for you...

 

Take a look at this: 

 

DAQ measurement.png

 

 

Message 2 of 15
(5,132 Views)

Try to insert a DAQmx Stop Task.vi before starting it again or clearing it.

 

Stefan

Message 3 of 15
(5,129 Views)

Jan_HeG: I can't really do that, since write has to stand before run task. What I can do is that I set autostart to true for the write function. This does however not solve the problem.

 

Stefan: I have added a stop function now, but this results in a error saying:

 

"Attempted to write a sample beyond the final sample generated. The generation has stopped, therefore the sample specified by the combination of position and offset will never be available."

 

The program starts and comlpletes the first state, which is to generate white noise for 200 iterations. Then it is supposed to generate a sine wave for 200 iterations before it moves on to the next state, and this is where the error occurs.

 

Sorry about not attaching all of the vi's. I've added them in this message. Running the program with a simulated PCI-4461 as dev2 should produce the same error as mine.

 

Thank you both for taking the time to help me.

 

/Felix

0 Kudos
Message 4 of 15
(5,109 Views)
Look at what I did with what you are trying to accomplish. It is much easier to get the same thing done and more efficient.
Tim
GHSP
Message 5 of 15
(5,105 Views)

Pretty cool stuff! But it doesn't work on my computer for some reason. It just keeps on going through the initiation loop over and over.

 

I think it's a bit out of my league as well, and if anyone has any tips on how to make mine work instead I would appreciate it a lot.

 

Thanks a lot though. It gave me a lot of ideas to see how it's supposed to be done !:smileywink:

0 Kudos
Message 6 of 15
(5,082 Views)
sorry try this
Tim
GHSP
Message 7 of 15
(5,078 Views)
I can explain things if you want to learn. Just ask questions and I would be happy to explain anything that I did. This currently will only do the do output we will have to add the do input later if yuo like what is going on..
Tim
GHSP
Message 8 of 15
(5,076 Views)
I noticed one more thing here is the latest version.
Tim
GHSP
Message 9 of 15
(5,068 Views)
Here is a version with the AI and AO. I put them into different loops.
Tim
GHSP
Message 10 of 15
(5,058 Views)