In order to generate a square wave signal, I have used the " cont gen voltage wfm-int clk-non regeneration.vi " ( see attached file ) ,available in the 7.1 labview software. I have set 2 connectors to change the "amplitude" and to read the "signal" for when I call it. I have then created another very very simple programm to call this VI ( see attached file) and changed the amplitude and watch the signal change on the graph. The output signal changes fine on the DAC0 out channel ( measured with a voltmeter )but I can neither change the amplitude nor see the signal on the graf ( I can only do it, when I am using directly the example ). That's my problem and I supose it comes from the "while loop" in the example I but don't seem to be able to solve it.
I am only starting to use labview so if anybody could help me it would be really great.
Because of the loop in the subvi, you never get an updated value from your main vi. I would just run the subvi as your main vi and modify it by moving the amplitude control inside the while loop so its value is updated every time through the loop.
Thanks a lot for your answer. I wanted to put that square signal generator in a subvi because my main VI is already quite big. Since the main VI should be as small as possible,I have already made up some sub VI to acquire pressure and temperature signals and it works out fine. So I supose the tensions( other than pressure and temperature ) I want to generate and read are to be put in the main VI ( because of that while loop problem). Is that what you recommand me to do ?
It sounds like you only posted a portion of your overall program, so I have posted a possible solution. You may have to change it to fit in your overall program.
Essentially, I created a global variable to pass your changes in the main.vi into the subvi after the subvi begins executing. This required adding a while loop to the main.vi to continuously update the amplitude variable. This is the part you will have to figure out how to integrate into your overall program.
Thanks for your help about the last VI you sent me. I have got a more general question to ask you. I nead to : -generate one analogical square signal -read 7 analogical signals -read a temperature and a pressure information
I need to write each value every second in a file. I would like to know if what I am doing is right : In my main VI :
1)I have a big while loop where I read the 8 analogical signals + temperature + pressure. I read the 8 analogical signals with just the DAQ assistant ( contrary to my VI that generates the square signal where I use the Daqmx writing, cloking,..) ( is that ok? )
2) Still in the main VI but outside that big while loop, I generate that square signal.
If you do continuous acquisition, I ll advise you to use DAQmx functions instead of DAQ Assistant. DAQ Assistant includes configuration, read, stop task ... But if your sample rate is no too fast, you can use DAQ Assistant, which is simpler of use than DAQmx functions.
Otherwise, it sounds good to me.
Regards,
Isabelle Jean NIF
Isabelle Ingénieur d'applications National Instruments France
It sounds like it should work. What do you use the square wave signal for? Being outside your main while loop it is free-running while all of your analog acquisitions are timed by the while loop unless they are externally triggered.
I am using the square wave voltage signal to create a square wave current signal that goes trougha 7 resistances. I then have to follow the change of voltage of the 7 resistances according to pressure and temperature.
I have finished that sub VI generating an analogical square signal ( adding a global variable stop in order to be able to stop the signal generation from my main VI where I have to acquire the 7 voltages, the pressure and the temperature which are all in the same while loop).
The spe of the square signal is about : high for 15 secs and low for 10 secs. I need to acquire the 7 voltages, the pressure and the temperature every secs or half a secs.
Do you have an idee which DAQ or DAQmx example could be appropriate to to read the 7 voltages? I am not sure which one to use. Up to know I have used the DAQ assistant but I'd rather use an already made one in the examples...
PS : my temperature and pressure acquisition is already working fine.
Thanks for your answer. I have got another question to ask you. I would like that when " STOP " is pressed, my analogical output sends " O volts ". I have used a global variable to go from the main VI ( where STOP is pressed ) to the sub VI that generates the analogical output.
When I run the program and then press "STOP", the main program stops fine, the second too ( because the square signal isn't generated anymore ) but the voltage stays at either the high or the low level of the square signal depending on when I press.
I think the problem is that it hasn't got the time to send the " 0 Volts " command when " stop " is pressed, and it stops immediatly. Do you think this could be the reason? If so, is there an element I could put in serie between the STOP button and the "round red" one ( that appears in a while loop )that could impose a 500ms wait before stoping the program?
If you are not looking at the data in real time then there isn't any example that will work for you.
But the example in DAQmx called Acq&Graph Voltage-Int Clk.vi will work if you set the acquisition rate (1 Hz) and the number of points you want to acquire per channel (30 seconds of data = 30 points at 1 Hz).