03-09-2010 01:04 AM
Hi there, Im trying to do something that should be fairly straightforward in an ordinary programming language..
On a button press I'd like to generate a constant signal with the amplitude 2 for 2 seconds. Preferably the button should be grayed and disabled during this time period. Once the time period has elapsed the output value should be set to zero. When the button is pressed again (switched back if it is a toggle switch) the amplitude should be set to -1 for 3 seconds and after that timeperiod set to zero. The signal hold times and the amplitudes should be user configurable.
The output from this VI will be connected to drive a DAC. The DAC output in turn will be connected to a display and therefore preferably a picture of the corresponding displayimage should be seen on the button that is to be pressed.
I've tried different case structures, sequence structures, while loops and signal generators but I am not able to get it to work. If you just know how it should be a fairly simple problem to fix 🙂
Rgds,
Stefan
03-09-2010 01:09 AM
Since YOU have tried "different case structures, sequence structures, while loops and signal generators " why dont you post one of then so that we can help?
Guru
03-09-2010 02:23 AM
Certainly, but I don't think my badly written attempts is a good starting point 🙂
Sequence is the first attempt i made with a flat sequence structure. I suspect that i cannot just output a constant when i need a signal and that might be the reason why it doesn't work.
Case signal gen.vi is two different approaches in one were one is using a signal generator and the other is similar to what i tried in the sequence.vi
Defined latch time is an example i found that does output time limited signals but not in a way that is working for me.
Rgds,
Stefan
03-09-2010 03:15 AM
This is what came to my mind.....There are other combinations too
03-09-2010 04:11 AM
I like the greyed out solution (that I did not know) but my main problem is to generate a time delimited constant amplitude signal. I would think that it has benn done before and the solution should be pretty straightforward but i haven't been able to find anything that satisfies my needs.
There should be an easy way to generate a constant signal with the amplitude 2 for 2 seconds. Eventually, as an add-on to the problem, I would like to drive the output with a short pulse (amplitude 2 and 1 s) every second minute. That too should be possible to generate fairly easy? With a timed loop structure maybe?
03-09-2010 04:47 AM
03-09-2010 06:03 AM
I'd be happy if somebody just pointed me in the right direction. If I could figure out how to generate the signals I want on my own, I wouldn't be asking would I?
So I guess you don't know the answer? 🙂
03-09-2010 06:17 AM
Why doesn't something simple as this work? When the switch is toggled (or the button pushed) I set an output to a value 3000 and then I wait 1 second until I set it to 0.
03-09-2010 06:38 AM
Her's another implementation that doesn't work as intended. The output doesn't switch to an amplitude of 2 when the state is shifted and back to zero after the delay as i would like it to do.
03-09-2010 07:01 AM - edited 03-09-2010 07:04 AM
In both of your last examples, you are setting two different outputs, not one and you are using a sequence structure. The outputs do not get updated until the entire sequence finishes. If you are using analog DAQ, then just create a waveform with a proper sample rate and pass it to a DAQmx Write. If you want to use digital I/O, do a write, delay, write.
Your use of the merge and sequence structure show a lack of understanding of data flow and how LabVIEW works. Have you taken the beginning tutorials?