AzeoTech Posted February 24, 2012 Share Posted February 24, 2012 You'll get that error until you initialize int_v2 to 0 as I described. I'd just do it in an auto-start sequence to ensure it gets done at least once. Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 24, 2012 Author Share Posted February 24, 2012 In the sequences tab, what should the thread priority be set to? 5-Aquisition? Then I should just enter int_v2.addvalue(0) and select auto-start? Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted February 24, 2012 Share Posted February 24, 2012 Priority doesn't really matter for such a short sequence. As for the rest you are correct. I've moved your other post to the other topic since it directly relates to that. Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 24, 2012 Author Share Posted February 24, 2012 I keep getting the following attached Alerts. I have attached my .ctl file too. The plot I am concerned with is the plot on the bottom left corner. Thanks so much for your help. Setup4.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted February 27, 2012 Share Posted February 27, 2012 Its lucky you didn't crash DAQFactory. You put the script that calcs the integral into the event for the channel that is to contain the result. You thus have Int_v2.addValue() inside of the event for Int_v2. This creates an infinite loop as the addValue() will trigger the event again, which will call addValue(), etc. etc. Also, you never mentioned you were streaming, which makes it so Events won't work the way you want. (see: http://www.azeotech.com/board/index.php?showtopic=4728. Also, you are averaging in the channel which creates other sync problems as well. However, you might be able to get it to work by putting the event code you have in the Int_v2 channel into the event for Voltage2. You still have to initialize Int_v2 to 0 somewhere. I'd put it in the startStream sequence probably. Right at the top: Int_v2.addValue(0) Another way to do this though is to simply do the integration in the graph. If you want to log the integration too, use an export set and put the same function there. Better yet, use a V channel and put the expression in the V. channel, then reference the V channel from the graph and the export set. You won't be able to use the logging set. I've attached a sample showing the Event method. integral.ctl Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 27, 2012 Author Share Posted February 27, 2012 How do you "simply do the integration in the graph"? Sorry for all the questions. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 27, 2012 Share Posted February 27, 2012 By putting the expression I indicated earlier directly in the expression for the graph: (Voltage2[0,100000] + Voltage2[1,100000] / 2) * (Voltage2.time[0,100000] - Voltage2.time[1,100000]) That gives you instant integral though. For cumulative you'll probably need to use the Event method. Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 27, 2012 Author Share Posted February 27, 2012 Ok thanks. Do you guys offer a class on coding in DAQFactory Express? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 27, 2012 Share Posted February 27, 2012 Only direct 1 on 1 training billed hourly. You can contact us directly at support@ if you are interested. Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 28, 2012 Author Share Posted February 28, 2012 I tried opening the integral.ctl file you attached but was unable. The error states that it was created in a newer version of DAQFactory. Any thoughts. Link to comment Share on other sites More sharing options...
goldfronts1 Posted February 28, 2012 Author Share Posted February 28, 2012 I am attaching my updated .ctl. Can you please check this out if this is what you were getting at. From your post #30? Thanks so much for your help. Setup4_1_.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted February 28, 2012 Share Posted February 28, 2012 Re #35: you should update to DAQFactory 5.86 Re #36: that is about right. Does it work for you? If not, I'd recommend trying the system without streaming first, (by settting the Timing of Voltage2 to 0.05 or so) and see how it goes. Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 6, 2012 Author Share Posted March 6, 2012 This is not working either. I tried doing it without streaming as well. I have attached images of the data from the plot. Also images of the plots. The integral plot is the bottom left plot. The plot on the top right is the plot I am trying to take the integral of. Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted March 6, 2012 Share Posted March 6, 2012 Please post your latest .ctl Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 6, 2012 Author Share Posted March 6, 2012 Here is my lastest .ctl Thanks Setup4_2_.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted March 6, 2012 Share Posted March 6, 2012 OK, several problems: 1) int_v2 and Voltage are the exact same channel (LabJack channel 0) and since you are streaming channel 0, the result is getting put into Int_v2 along with your calculation 2) your plot scaling is only 0 to 3, while new_time in your screen shot shows 82, way out of range 3) It's important for you to actually understand the math behind calculating an integral when taking discrete measurements. Its math that applies no matter what hardware or software you are using. I'd like to be perfect all the time, but as you would expect, I reply to a lot of different forum threads, direct emails and telephone calls so don't necessarily proof everything I type and have typos, but I expect the person I'm talking with to take time to understand the concept, not simply cut/paste. As indicated in post #12, I had a typo in my formula in earlier posts, which was then corrected. However, it appears that you have not understood the math and reintroduced the typo into your expression. The /2 needs to be outside the sum of the voltage because the formula is the average of the two readings times the difference in time. Think of it like the area of a trapazoid where the bottom is square. Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 7, 2012 Author Share Posted March 7, 2012 OK, several problems: 1) int_v2 and Voltage are the exact same channel (LabJack channel 0) and since you are streaming channel 0, the result is getting put into Int_v2 along with your calculation Since int_v2 is actually the the integral values, what would giving it an empty LabJack channel do? I have the code for doing the integral in my Voltage_2 channel event. 2) your plot scaling is only 0 to 3, while new_time in your screen shot shows 82, way out of range The plot scaling is in minutes and I'm not sure what the new_time is in because 82 makes no sense. 3) It's important for you to actually understand the math behind calculating an integral when taking discrete measurements. Its math that applies no matter what hardware or software you are using. I'd like to be perfect all the time, but as you would expect, I reply to a lot of different forum threads, direct emails and telephone calls so don't necessarily proof everything I type and have typos, but I expect the person I'm talking with to take time to understand the concept, not simply cut/paste. As indicated in post #12, I had a typo in my formula in earlier posts, which was then corrected. However, it appears that you have not understood the math and reintroduced the typo into your expression. The /2 needs to be outside the sum of the voltage because the formula is the average of the two readings times the difference in time. Think of it like the area of a trapazoid where the bottom is square. This was an error on my part not just a copy paste. I am new to this and really appreciate your help with this issue. Thanks Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 7, 2012 Author Share Posted March 7, 2012 Would something like this work for #2: Putting this in my plot for the x axis? (new_time.time - startTime) / 60 Link to comment Share on other sites More sharing options...
AzeoTech Posted March 7, 2012 Share Posted March 7, 2012 1) you can't use a real channel because you are getting real data into that channel. You have to use a channel that isn't wired to anything real (or that you've instructed to stream). Int_v2 isn't a real channel, its a calculated one 2) new_time, like all DAQFactory time is in seconds. 3) sorry to get on your case. I just want to encourage you to take the time to understand the concepts. 4) yes, doing /60 will convert seconds to minutes, your desired units. Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 7, 2012 Author Share Posted March 7, 2012 I assigned int_v2 to an empty channel and new_time is assigned to an empty channel For some reason the integration values are not correct. I have attached my .ctl Would putting the integration code in the int_v2 event help? Thanks Setup4_2_.ctl Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 7, 2012 Author Share Posted March 7, 2012 Also the integration plot is not static. The data is floating and disappearing as its recording. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 7, 2012 Share Posted March 7, 2012 Channels 2 and 3 aren't empty channels. Look at your StartStream sequence. You are streaming channels 0 through 3. Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 7, 2012 Author Share Posted March 7, 2012 Ok. There is data now in my int_v2 channel. However I get an error with the new_time channel. I have attached the screen shot. Thanks for your help Link to comment Share on other sites More sharing options...
AzeoTech Posted March 7, 2012 Share Posted March 7, 2012 I don't see anywhere where you are populating the new_time channel. Are you trying to do elapsed time from the start of streaming? If so, add this line to your startStream Sequence: global starttime = systime() and change "new_time" your y expression to int_v2: (int_v2.time - starttime) / 60 You can delete the new_time channel. Link to comment Share on other sites More sharing options...
goldfronts1 Posted March 8, 2012 Author Share Posted March 8, 2012 I'm trying to plot the time range of the integral itself. So from the other graph I have voltage2 plotted against the elapsed time. So whatever this time range is then I am taking the integral of the data over that time range. Hope this is not too confusing. Thanks for your help Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.