05-30-2015 12:43 AM
I am attempting to output a time code which changes every second. I want the signal to be output only every 5 seconds and not every second. To make my task even more difficult, I also simultaniously am attempting to conuously acquire the signal that is being output. The signal I am outputting only lasts for about a second, which is what I want, but when I write the signal after 5 seconds, it seems that there are multiple signals, one after the other, being output to the DAQ instead of just 1 signal. Please help!
I will attach the VI below. I will also attach the control file associated with it.
I am currently using a NI USB-6218 with DAQmx driver installed and labview 14.
If anyone needs any more information that what I have given, please just let me know and I will do what I can. Thank you!
Solved! Go to Solution.
05-30-2015
09:56 PM
- last edited on
08-20-2024
06:23 PM
by
Content Cleaner
Your code is curious, almost as though you don't understand how to sample from your device, nor how timing works with an analog device. Have you looked at the DAQ Tutorials? Do you understand how Hardware Sampling works? Do you understand the difference between 1channel-1sample and 1channel-Nsamples? If you want to do something every 5 seconds, why not set the timing for 1/5 = 0.2Hz? Why have a Timed Wait in a loop with a timed DAQ Read or Write? I recommend this White Paper.
Bob Schor
05-31-2015 10:10 AM
05-31-2015 11:26 AM - edited 05-31-2015 11:26 AM
Mike,
Maybe a little background information would help here. I probably should have explained all this in the post above.
I am a student and volunteer in a research lab which cooperates with a commercial laboratory off campus. Our lab adds data to what is normally collected during the commercial lab's experiments and both labs share our data with eachother. In order to review both data collections and match up the timing of when the readings are taken, there is an analog signal that our lab generates and passes to the other lab. this allows us to use the data they collect and the data we collect and relate the timing to the signals to eachother. The VI we currently use was made years ago and is run on a very old version of labview which is no longer compatible. It is also used on an older computer and our system has begun to act up so we needed to update it. The student who originally generated the code that we currently use left the lab about 2-3 years ago and I am trying to teach myself how to do this.
I was asked to make a VI which would generate the same signal we use to match up the timing of data acquisition between labs without any changes to what is output so we don't have to ask the other lab to change what it receives and cause them to change their methods too. The old labview VI i am supposed to imitate was able to output an analog signal every 5 seconds, which lasted for only 1 second. The signal gave a voltage measurement which corresponded with the current time. The minutes were given first, then hours and then seconds. I will attach a drawn graphic of the signal below.
Basically, the old VI would generate an anaolog signal which would output a voltage that matched the current minute, hour, then second. I was able to make a sub VI which generates the portion of the waveform which is above the beseline in the drawn signal attached. My current issue is that when I attempt to generate this signal every 5 seconds and output it, the signal seems to be generated MANY times within that 5 seconds (instead of just 1 time as I intended) and then all of the generations of the signal are written to the DAQ. I would like the DAQ to only output 1 round of the 1 second signal that I generate, and then output a baseline at zero when the signal is not being output.
I will attempt to include the subVI's used to generate my current signal below. I am not sure how many attachments I am allowed to add to one reply so it may be included in other replies.
Any further help would be appreciated.
I realize that my methods may be strange because I have absolutely no formal training in DAQ or LabVIEW. I will explain more on my methods in my reply to Bob above...
Thanks again for your help.
05-31-2015 11:27 AM
Mike,
The rest of the SubVI's
05-31-2015
11:43 AM
- last edited on
08-20-2024
06:23 PM
by
Content Cleaner
@Bob_Schor wrote:
Your code is curious, almost as though you don't understand how to sample from your device, nor how timing works with an analog device. Have you looked at the DAQ Tutorials? Do you understand how Hardware Sampling works? Do you understand the difference between 1channel-1sample and 1channel-Nsamples? If you want to do something every 5 seconds, why not set the timing for 1/5 = 0.2Hz? Why have a Timed Wait in a loop with a timed DAQ Read or Write? I recommend this White Paper.
Bob Schor
Bob,
I will be the first to admit that you are probably right. I most likely don't fully understand how the devices and timing work. I have to admit though, that I have looked at the DAQ tutorials, and I have already read the document (the white paper), that you posted in your reply. I read them again after your reply and did not find anything that helps me. I have read many other documents and have based my VI's off NI examples which have helped tremendously. I have watched the Labview Core 1 and Core 2 coursewares and videos too. Although I have done a lot of research, I am still very new at this so please bear with me and I apologize for my incomeptence.
I believe the difference between 1channel-1sample, and 1channel-Nsamples is just that it will only write/acquire 1 sample as opposed to n samples every time the write or read function runs. Is this correct?
Also, I set the timing the way I did based on the last example in the labVIEW core 2 -> timing design patterns video. I figured I would generate the signal (which would be different every second) and write it to the A0 output 1 time every 5 seconds.
I understand that I do not fully grasp at least one of the properties I have in my code, and that is why it is acting in an unexpected way for me. I am attempting to generate a code which I explained in my response to mike. If you could take a look at that response it may answer some of the questions you asked.
05-31-2015 04:12 PM
The single-most helpful attachment was the drawing -- now I understand what you are trying to do! I started looking at (and "improving") your code and realized that the Description of the Problem is still inadequate (particularly in trying to understand the Math VI).
I see, now, that you want to output an analog square-wave signal that will, in some sense, encode the current time. To do this, you want to generate a Waveform that will take on three "time-like" values. Here are some questions:
Now, the question needs to be ask why you would choose to transmit digital information (H:M:S) as an analog quantity (voltage), which leaves all sorts of possibilities for errors! A much better idea would be to transmit it digitally. For example (and this is not an ideal way to do this, but it illustrates the point), you could transmit numbers from 0 .. 59 by playing a 500Hz square wave (which has a 1 ms pulse width) and putting out one more pulse than you wish to transmit (so you could "send" 0 by outputting a single pulse). To send 16:03:24, you could output 17 pulses in the first second, 4 in the second, and 25 in the third. You could make the pulses something convenient (like from 0 to +5V), which (also conveniently) is the standard TTL level for 0 and 1, so you could do this using the Digital Output (and Input) of a multi-function DAQ peripheral instead of the (rather-more-challenging, from an accuracy and precision standpoint) Analog Output.
I did look at (and rewrote) GetHoursMinutesSeconds. Here are some ideas:
I look forward to seeing your response.
Bob Schor
06-08-2015 12:12 PM
Bob,
I appreciate your input! Sorry it has taken me so long to get back to you. I have been busy with a Maymester course (a 3 credit hour course taken in the three week break between Spring semester and Summer semester). I have also purchased the courseware manual and exercise book for the NI "Data Aquisition and Signal Conditioning" course. I have been reviewing and skimming over the chapters in that book during my free time in order to better figure out what I am doing.
I have made the changes you specified in the GetHoursMinsSeconds VI. Thank you so much for that information. I have also connected Errors wires throughout the subVI's.
In response to your inquery about why I am sending Digital data via an analog string. I can only imagine that the programer that created the original program was not very educated in Data acquisition either. I would rather change our program to do digital signaling because it seems easier, but I was asked to try to not change the time signal we share because then the other lab would have to compensate and change their programs too.
In response to your original questions about my current signal requirements, we originally had the signal output at 1000 Hz so that is what I am trying to do here. In the courseware I read something about how this will be calculated from the points per second and # of points (and # of cycles although I will only be outputting 1 cycle every 5 seconds) I output but I have not been able to figure this out competely yet either.
I was told the original program put out a 1 second time signal (meaning hours mins and seconds signals would have to be 333 and 1/3 data points long) but I don't believe this was possible so I believe it actually put out a .999 second signal with 333 points for each of the hr, min, and sec signals adding up to just under 1 second with a 1000 Hz signal.
The formulas are depicted correctly in the hoursminssecondsmath VI that I gave you earlier. Again, I did not come up with the calculations for this signal but I have been asked not to change it.
Thanks again for your help!
I will be working on this periodically until I can figure it out but if you have any other input it would be greatly appreciated!
The main problem I am still having is getting this time signal to be output only 1 time every 5 seconds and have the signal read at 0 V during the 4 second break in between time signals. For some reason, when I run my current program, it outputs with the next signal imediately after the end of the first without a break. I have also tried other ways of writing the signal with a long output of 4001 points at 0 V (to make the whole signal add up to 5 seconds) but then the output seems to be writing to a buffer and the signal does not updata every 5 seconds like I wanted!
06-08-2015 05:25 PM
By now, I've forgotten what you've done. Could you attach a ZIP file (to get around the limited number of attachments) with all of your VIs, as well as a picture of what you would like to see as an output? That would be very helpful. Also, did you say what hardware you were using? That would be very useful to know.
BS
06-08-2015 06:33 PM
Bob,
Attached should be a rar file with the Labview Files and the picture I had posted above. As I mentioned in my last post, I am still attempting to create an analog signal which changes every 5 seconds based on the current time. It will look somewhat like the picture I have in the rar file.