kap519071680 Posted May 27, 2014 Report Share Posted May 27, 2014 I'm trying to integrate data from one waveform graph that depends on the timestamps of another. What I have setup is digital waveform and an analog waveform and I would like to integrate over data from the analog waveform whenever the digital goes high. My idea on how to approach this was to check when the digital input goes high and then low, and at the those timestamps as my limits of integration, however, I'm not sure how to go about this. What I have tried to do was to take the digital input data and AND it with 1 to see if it is high, and then take that data and store its timestamp in an array and then input those values when integrate, but this is not the correct approach because it will not give me the right intervals for integration. I think what I am having trouble with is getting the timestamps of when the digital input goes high and then back to low. Does anyone have any idea on how to approach this problem? I would appreciate any suggestions. Thank you! Quote Link to comment
hooovahh Posted May 27, 2014 Report Share Posted May 27, 2014 Are the Analog and Digital samples driven from the same clock? Are they sampled at the same rate? Are they started at the same time? If you answer yes to any of these your life can get a little easier. Saying no to all of these questions means lots of manual code searching for times that match up and will likely take much more time but still do able. Quote Link to comment
Tim_S Posted May 27, 2014 Report Share Posted May 27, 2014 Are you having trouble finding the array index where the transition occurs or the timestamp of that index? If the array index for the transition, a search 1D array for a true/false would give you the index. You 'd need to use the results for the search for the true as the start index for the false. For finding the timestamp... If the analog and digital data acquisitions are synchronized, you don't need to find the timestamp; just use the index. If the data acquisitions are not synchonized, then the timestamp would be the (index * dt) + t0, and then (timestamp - t0) / dt on the analog side to get back to an index. Quote Link to comment
kap519071680 Posted May 27, 2014 Author Report Share Posted May 27, 2014 Currently each input has its own sample clock and the waveforms are synchronized. I am confused as to how I would go about extracting the intervals to integrate the analog input data. I thought I would first have to do some sort of check to see if the digital input is high and if it is then continue to get the timestamp, but how would I get the time at which it goes back to low? You are saying I can use an array index to get the right intervals if they are synchronized but I'm not completely understanding. I've attached an image of what I have so far along with another image of what I've tried to do to get the right timestamps.. Quote Link to comment
Tim_S Posted May 27, 2014 Report Share Posted May 27, 2014 OK, the way you've set up the data acquisition it will use the sample clock from the analog input to also acquire the digital input. In other words, a digital input sample will be taken every time and at the same time that an analog input sample is taken. You've also started the digital and analog input tasks such that the two will start together. This means the analog input and digital input are synchronized in time (e.g., the 1000th sample taken for the analog input was taken at the same time as the 1000th sample of the digital input -- this is the array index referenced). This is all good as it makes what you're looking to do easier. Looking at your code, are you looking to perform the integration on "live" data (as you collect it) or are you going to post-process the data (after you've collected all the data)? I would recommend something different for live versus post-processing. Quote Link to comment
kap519071680 Posted May 27, 2014 Author Report Share Posted May 27, 2014 I am looking to perform integration on live data. I've setup an index search to find the index for the transition to high and the transition to low as you were saying (attached image), but can I use the indices as my intervals of integration or do I have to use the time stamps? Or do you suggest something else because I want to do it live? Quote Link to comment
hooovahh Posted May 28, 2014 Report Share Posted May 28, 2014 Using the transitions output would probably be easier but for my test I created the analog and digital data. I think it works but you'll want to check my work of course. I don't have 8.0 (which your profile says you use) so I attached an image as well as the VI saved in 2011. Integrate Analog Digital Values.vi Quote Link to comment
Tim_S Posted May 28, 2014 Report Share Posted May 28, 2014 hooovahh has a good example. I think you'll need to monitor state between loop iterations as well. For example, the integration would start when the digital goes high in one read of your data and then continue into the next read until the digital goes low in a read N iterations later. You'll need a shift register to hold the state (don't forget to initialize the shift register), which might be as simple as a boolean for this. If you need more than two state (integrate/don't integrate), then my preference would be to use an enum made into a type def. Quote Link to comment
hooovahh Posted May 28, 2014 Report Share Posted May 28, 2014 Very true I was thinking this would be used in a finite sample type of situation but yes if you are doing this continuously you'll need some extra work. It was just meant as an example anyway. Quote Link to comment
kap519071680 Posted May 28, 2014 Author Report Share Posted May 28, 2014 Thanks! I will try all of the suggestions and update if it works or not. I really appreciate all of the help! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.