10-10-2012 09:20 AM - edited 10-10-2012 09:34 AM
Good morning,
I'm attempting to create a simple signal genorator that will send an analog command signal to a device and then read the devices position feedback. (Check out the attached VI)
The program must accept the users input for DAQ Max and DAQ Min Voltage, and I/O Analog channel selection becuase any daq from 6008 to 6215 will be used.
I think the best way to set this up is with virtual DAQ channels. I found another example on the forum, but it didn't work for my setup.
I'll be very grateful with any suggestions you have!
Thanks,
Christopher
Solved! Go to Solution.
10-10-2012 09:31 AM
DO NOT DO THAT!
When posting attached code please use default settings for the windows execution options. attaching a file set to run when opened and a race condition involving a missused local variable that forces an infiate loop is just rude. (And potentially unsafe)
10-10-2012 09:34 AM
Sorry about that. I wasn't thinking.
The VI is attached.
-Christopher
10-10-2012 09:55 AM
OK that is a nice looking UI but you have some fatal flaws in the vi. (Don't try to find the "settings" control from the terminal you will crash LabVIEW)
Your code definately suffers from an overuse of local variables.
Place the terminals for latching booleans inside the event that handles them.
Look at using a queued message handeler to drive the state of the lower (consumer) loop
(Why is there logic "If listbox is 0 or 1" infront of the case selector? wire "Listbox" directly to the selector and cases 0,default and 2 would do the same thing
Do not create a DAQmx task every time you use it. DAQmx tasks need to be created only once Preferably during development and not at run time if it can be avoided. (Save them in the project and your deployment can import them onto the target)
Consider using an Action engine to encapsulate the DAQmx functions (Init Task, Config, Run, Stop, and Close Task states seem about right)
10-10-2012 10:07 AM
You also left no way to stop the program. You should exit the program with the Exit button on Value Change.
10-10-2012 10:10 AM
It looks like you want to create a waveform, but you're DAQmx Write is set for 1 channel 1 sample. Yet you are sending an array to it would only make sense for N channels/1 sample, or 1 channel/N samples.
10-10-2012 10:21 AM
Jeff,
Thanks for the reply! What do you mean by 'findkng the settings control from teh terminal'?
I'll look over the recomended changes. Will adding an action engine around the DAQmx functions allow simultanious analog read/write? That is what I'm struggling to create successfully.
Thanks,
Christopher
10-10-2012 11:20 AM
Found a solution!
Thanks everyone.
-Christopher
10-10-2012 11:52 AM
Don't just say you found a solution, then go and mark your own post as the solution.
Did someone's post help lead you to the solution? In that case, mark their message as the solution.
If it turned out to be something else, then please put some detail in your message as to what your solution was. That way if anyone in the future is searching for the same problem and finds your message thread, then your newfound knowledge would be able to help them.
10-10-2012 11:57 AM
It turns out that my error was in the method I was using to plot the data. Origionally I was trying to plot the output signal and feedback signals on the same plot. Becuase of the different data types it wasn't working. Now I've forced it to work by using two different types of plots and making one transparent.
Check out the attached vi.
-Christopher