07-19-2010 11:19 AM
Hello,
Just to give a bit of background information, I am a complete beginner to LabVIEW having only started teaching myself to use it 2 weeks ago. I am using the full development system of version 7.0. I am designing a control panel to monitor the data acquisition of up to 20 UV detectors that our company manufactures for calibration before they are shipped to the customer. We purchased a PCI-6225 and I am now in the stage of writing code to properly record the data of single detector in the required time frame. In the code attached below, I am using simulated DC signals to simplify while coding. Eventually the simulated signals will become differential input channels from each detector (one for UV and one for temperature). I plan on creating one subVI to monitor and record the data outputted by each detector, then placing 20 of those subVI's in a main control VI that runs 24/7 that the user can interface with: (setting scales and offset, turning channels on/off, etc...).
I am going to be asking many questions in this semail, so I will do my best to highlight them all at the end of the message
First I will describe what I want the individual VI for each detector to do:
I want to record the UV data and temperature data outputted by the detector at a rate of 1Hz. Using that recorded data, I want to perform further operations. First, I wish to integrate the UV data into half-hour (1800s) dosages, calculating how much UV energy the detector sees in a half hour, (resetting the dosage to zero at the end of the time period). It would also be helpful to calculate a daily dosage interval as well (midnight to midnight). As far as with the temperature signal goes, I want to calculate average, max and minimum temperature over each half-hour interval. I want to output all of this data to an excel file for each detector once every half hour with specified columns:
When reporting the data into the excel file, I need the time units to read by Real Time, HH:MM:SS, rather than by seconds elapsed since the beginning of the program's execution. Ideally, I want the timing of the integration to occur at Fixed half Hour intervals (08:00:00, 08:30:00, 09:00:00, ..., 14:30:00, etc...). This way I can generate an excel file for each detector and have it named by its serial number. The excel sheet for each detector would ideally have the following columns:
(Date, Time, Detector Serial Number (User Inputted), Half-Hour Dose, Total Daily Dose, Avg Temp, Max Temp, Min Temp)
Here is my reasoning behind the coding I have already done:
Attached below is the code I have began writing. I simulate the two Temperature and UV signals and convert their units out of Volts with the subsequent math. A temperature correction algorithm is applied based on which type of detector is attached (UVA or UVB). Then, I integrate the UV data that comes out into half hour dosages *(I use 5 second dosages just to test that the code works, but I would use 1800s intervals in the final code). I asked a question how to do this on the forums, and someone suggested by using shift registers for timing, as I implemented in my code.
There are several problems with my code as it is written:
A) First off, The time values reported in the .xls file are in seconds, rather than real-time (HH:MM:SS), as I would prefer
1) I have examined the 'real time chart' VI from the examples, but I couldn't figure out how to write the data to real time rather than plot it.
2) I also need to have data recorded at specific intervals, rather than the time after I push run.
3) In the .xls file, the data reports a time value for each data stream (UV, Integrated UV, and Temp). How to I remove the redundant ones?
B) The integrated UV data does not reset to zero after recording the value. How do I get the data to reset to zero after each dose?
1) Would using an array fix this problem?
C)I have not been able to find a way to get Average, Min and Max temperature recorded without giving me errors.
1) I've tried the 'Amp & Level Measurements' VI, but that doesn't seem to work.
Having looked at some example programs, I have a good idea what I need to do, I'm just having difficulty implementing them to my own code.
Here are some of the ideas I'm mulling around:
A) Would it be beneficial to collect the UV and temperature data into an array?
I imagine collecting the data for each interval in a loop into the array, simultaneously performing the desired calculations (integration, Average, Min Max...) for each interval. At the end of each interval, the program would overwrite the array with zeroes, then record data and interpret it? I tried reading the data into arrays with the initialize array VI, but I kept getting errors of incompatible data streams.
B) I know that I am not using enough loops in my code to generate the data as I want it. How should I nest my loops to generate data for the specific timing constraints that I have?
I know that this is quite a loaded question, but any input you can give me on how to better develop my code would be greatly beneficial.
Thanks,
Ben
07-19-2010 02:56 PM - edited 07-19-2010 02:57 PM
Hey Zoil,
It seems that you have a fairly straight-forward data acquisition program that you need to write. Since you are relatively new to LV, you might want to check out the following link for a discussion of Application Design Patterns. This may answer some of your questions concerning how you ultimately arrange everything (the architecture of the program). What you want to with the data acquisition is fairly straight forward and I would encourage you to look through the examples in the NI Example Finder (found under help). Regarding your program specifically:
07-20-2010 02:30 PM
Matt,
Thank you very much for your help. I was having a big dificullty understanding the array structure in LabVIEW until you elucidated it for me. I think I have gotten the program to behave how I want it, even without using shift registers! There is one last part that I cannot figure out: Converting the x axis from 'seconds since measurement start' to a 'Date/time stamp' when writing to file.
I've looked at the 'Real-Time Chart' in the example finder, but can't see how to apply it to my program. Do you know how I can do this?
07-20-2010 03:28 PM
Zoil,
What x-axis are you referring to? You have no chart in your program.
Matt