mwheen Posted October 28, 2008 Share Posted October 28, 2008 I am currently streaming 60Hz AC voltage from a current transformer into a labjack U3 and would love some tips on how to grab a portion of the streamed data, say a couple of cycles, possibly over 0.1seconds and find the max value (rms conversion). Then repeat this say every minute and graph this max or rms(conversion), with respect to time. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 28, 2008 Share Posted October 28, 2008 Well, you could do this a number of ways, but I'd probably let the stream run continuously and then use DAQFactory's ability to subset by time to pull out a chunk of the channel history. First, make sure your history is long enough to hold a large chunk of data. The default of 3600 will go real quick even at 1khz. Something like 100,000 might be good. If you go bigger, you might think about using the Persist instead. Now, lets say your input channel is called Volts. Here's some approximate script for grabbing 0.1 seconds of data at random every minute and calcing the max and stuffing it in a channel called VoltMax (which would have a timing of 0, but then so would Volts). I'll assume you are starting the stream from elsewhere, so this sequence would run concurrently: private chunk private themax while(1) // loop forever // grab a chunk of data, the last 0.1 seconds worth chunk = Volts[systime(),systime()-0.1] // calc the max themax = max(chunk) // assign a time themax.time = systime() // stick it into the other channel VoltMax.AddValue(theMax) // wait a minute delay(60) // and repeat endwhile You can add more calcs on chunk too to determine your rms and stick it in another channel. You'll notice that I explicitly assign a time to themax. When you do max(chunk), not only will it return the max, but it will assign the time of that max point to themax. I don't know if you want this, but it will result in your VoltMax data stream having rather jumpy times (but within 0.1 seconds) depending on when the max occurred. Its really up to you and you might try eliminating the themax.time line and see if you like the result better. Finally, just graph VoltMax vs time to get your graph. Link to comment Share on other sites More sharing options...
mwheen Posted February 5, 2009 Author Share Posted February 5, 2009 Thanks for the help and I am getting rms values. For some reason however the voltmax channel ( which was converted to power) starts reading a constant value after a couple of hours. The streamed channels seem OK and the max values of the incoming ac voltage appear to change over time as they should. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 5, 2009 Share Posted February 5, 2009 I'd need to see more detail (screenshots?) to see what you are talking about. Link to comment Share on other sites More sharing options...
mwheen Posted February 6, 2009 Author Share Posted February 6, 2009 sorry , I am having troubles uploading a JPEG Link to comment Share on other sites More sharing options...
AzeoTech Posted February 7, 2009 Share Posted February 7, 2009 Sorry for the troubles. Can you just email it to us (from our contact form)? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.