LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate and vary output voltage and continuously measure input volatge

I am sure this is an easy fix, but I can't seem to wrap my head around it (yes, I am a newbie).  Please help!

I am using DAQmx with a PCI M series card (LV 8).  I am trying to output a voltage and acquire an input voltage at the same time.  The caveat is that I would like the output voltage to change after 1 hour, have a "spike" for 100 ms, and return to the intial voltage for another hour and so on while acquiring an input voltage.  I have looked at the example "gen voltage update", but I need this to be done programatically, not manually. 

The challenge I am having is both generating and aquiring voltages at the same time.  I have been able to generate the output signal using a sequence with two AO tasks and a pause in between that corresponds to the correct times at each voltage.  Unfortunately, I cannot measure the input voltage beause multiple tasks would be running at the same time (I get an error). 
I know this would be easy with a waveform, but I can't figure it out with a programatically controlled output.

Any help would be greatly appreciated.

Thanks!
0 Kudos
Message 1 of 8
(3,658 Views)
You shouldn't have any problem with running two tasks at once, as long as they're not using conflicting resources. What is the error message you are receiving? You may be able to get away with just using the same Sample Clock for the AI and the AO tasks.

0 Kudos
Message 2 of 8
(3,647 Views)
Thanks for your advice and sample vi, but I could not read it.  Could you send ti again in version 8.0 or lower?

I have attached a sample vi of what i am trying to do.  I am getting an error that comes from the sample clock on the ai side.  Is there a better way I write this program?  I am not familiar with synchronization and clock timing, so any advice would be appreciated.  I cna get the output to do what I want, but the input waveform/graph just hangs. 

Thanks again.
0 Kudos
Message 3 of 8
(3,637 Views)

@Rosencrantz wrote:
Thanks for your advice and sample vi, but I could not read it.  Could you send ti again in version 8.0 or lower?

I have attached a sample vi of what i am trying to do.  I am getting an error that comes from the sample clock on the ai side.  Is there a better way I write this program?  I am not familiar with synchronization and clock timing, so any advice would be appreciated.  I cna get the output to do what I want, but the input waveform/graph just hangs. 



An 8.0 version is attached.

It looks like you've set up DAQmx tasks in MAX, and are calling them by name? I don't get an error when I run your VI, so it may be a factor of how you've set up the task. What parameters did you use (timing, triggering, number of samples, etc.)? You don't have anything that connects your AO loop from the AI section, so even if you don't have the error, you're not going to know which started first and they won't really be synchronized. Depending on the timing of what you're measuring, that may be acceptable.

The call to Sample Clock should come before the call to Start Task in your AI section. You can't change the timing of a task once it's started. This may be the source of your error.

0 Kudos
Message 4 of 8
(3,628 Views)
Thank you for the 8.0 version.  That does what I would like- to a point.  As I have mentioned, I would like to change voltages between two different values at specified but unequal times (in other words, not a traditional waveform).  The rand number generator does not work for me since I need change between two set values and why I can't include with the input and outp;ut in one loop (although I would like to).

I am using MAX to configure tasks and I have elemnated the errors I am getting.  I have attached a vi that does what I think I want to do.  Can you see any issues with it?  The input and output are not synched in the same loop, but I think it will work.  Stopping the vi from running is a bit of a challenge since I can't get out of the sequence, but I think I can work around it.

Any advice on a program based off of this one with that does the functions described above would be appreciated.  Thanks again.
0 Kudos
Message 5 of 8
(3,596 Views)

Hi,

Instead of using a sequence structure you could use a state machine architecture to allow you to stop in the middle without having to run every step. Here is a tutorial for creating and understanding state machines in LabVIEW. You do not necessarily need the State Diagram Toolkit, though it may make it easier. There is a template built into LabVIEW that can give you a starting point for creating your own state machine. Under the File»New... menu, you can choose the state machine template under VI»From Template»Frameworks»Design Patterns»Standard State Machine template. You would have each of the actions you perform in the sequence structure be a state and normally transition from one state to the next. If the user presses stop, the code could stop after the current step completes. If you do not have a shut down state, you could have the stop button outside of the case structure and the user could stop the loop immediately after the current state. With this, you can have your shut down code outside of the while loop (and dependent on the while loop completing).

I hope this helps!

Regards,

Message Edited by MissyD on 06-13-2007 06:32 AM

Missy S.
Project Engineer
RoviSys
0 Kudos
Message 6 of 8
(3,567 Views)
Thank you for the advice on using state machines.  I will look into it and see what I can develop.  One question with it though- would I be integrating waiting times between states (high voltage/low voltage) using a sequence still or is there some other timed way using this method?

Thanks!
0 Kudos
Message 7 of 8
(3,559 Views)
Hello

Yes you would implement the timing in your state machine architecture.

Regards,
  Sandra T.

Applications Engineer | National Instruments
0 Kudos
Message 8 of 8
(3,529 Views)