LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a state machine

Solved!
Go to solution

Hello all,

 

I have attached my project. I am trying to create a state machine that will Begin at 1 Volt, wait 1 second, then transition to 2 Volts, then transition to 3 volts................. . I can only get it to go through the first iteration without problems. When it gets to the second it keeps alarming on me and giving me error -200088. I have this connected to a USB-6002 DaQ device. If I take what I have in the "initialize" case except without the case structures, I am able to enter a value into the DAQmx and each time I change that constant, it changes the output of AO0. Putting it on this state machine, I can't get it to work. Any help would be greatly appreciated.

 

Thank you

0 Kudos
Message 1 of 9
(3,005 Views)

You are stopping and clearing your task before you're done with it. Move your DAQ Stop and DAQ Clear to the End State.

You probably want to put your Task Creation into your Initialize state.

 

Also it looks like you're using NChan NSamp to do your DAQmx write when it seems more appropriate to use a single channel single sample DBL.

0 Kudos
Message 2 of 9
(2,984 Views)

Thank you for your reply. I am trying to change my Vi to the way you recommended but I am having trouble with The DAQmx Write in the other case structures. I need to change the "data" for each case with a constant written to the DAQmx in each structure but do not know how. I tried creating tunnels but it didn't work for me. Since those terminals must be wired and they aren't, I am getting the broken run arrow.

0 Kudos
Message 3 of 9
(2,965 Views)

Click on the polymorphic selector for the DAQmx Write and Change it to Single Channel Single Sample. Then instead of wiring in a 2-D array of double, create a scalar double constant and wire that into the DAQmx Write.

 

I'd recommend going through the LabVIEW tutorials if you haven't already done so.

 

Also feel free to post your vi as you progress through the changes.

Message 4 of 9
(2,955 Views)

I took the Core 1 and Core 2 classes and found a site on youtube that has over 30 different video threads that I have watched, but I lack the experience which, unfortunately, is the only way I am able to learn. I have been referencing my training as I write.

I changed them to single channel-Single Sample-DBL, and changed the constants, as you recommended. When I click on my broken arrow now, it all has to do with the polymorphic not being wired as needed. I don't know how to tell what is required for a Vi to work, just looking at its terminals. Attached is where I am at now.

 

Thank you

0 Kudos
Message 5 of 9
(2,946 Views)

Ah. Now you need to reread the section on Shift registers and pass your DAQmx Task around in that shift register. Create the task in your initialize and wire it to the right side shift register. Each case in your state machine will pull the Task from the left side shift register and pass the output task to the right side shift register.

Message 6 of 9
(2,939 Views)

Nuts! I was going to try that but thought sure I was wrong. I will try it.

0 Kudos
Message 7 of 9
(2,936 Views)

It's running! I still have a couple of errors I can't interpret but it goes through each of the cases. When I try to "re-run" I get an alarm and when I select "cancel" at the end of the program I get a couple of errors. You will probably know immediately what they are. Me, not having such luck. 🙂

0 Kudos
Message 8 of 9
(2,922 Views)
Solution
Accepted by ceilingwalker

What errors are you getting that you can't interpret?

You've got a bunch of stop buttons which you don't need.

If one gets to the Rerun state and decides to Rerun, you don't need to reinitialize. If you want to reinitialize, you should close and clear the current task before doing so.

Typically on an End State, I'd pass an empty task constant to the shift register.

Message 9 of 9
(2,845 Views)