caljones Posted May 8, 2017 Share Posted May 8, 2017 Hello, First time user of Daqfactory, utulising a Labjack U6. I am creating a simple control system to switch 8 relays based on pressure inputs and time. It is used for creating a test certificate for quality assurance purposes. I have successfully written the control/relay code, however I am having issues with displaying the results of the test. Currently, the code starts graphing the pressure value upon starting the sequence. First question: Can you freeze the graph at a certain time? IE after 120 seconds? Is there a way i can display the value of a channel at a certain time? IE Initial pressure, and final pressure (then finally calculate the pressure drop, and the test result?) I tried setting the value expression to: Mychannel[StartTime] I also thought to create a variable called initial_value = mychannel(startTime) however i cant seem to 'display' a variable. Must the value be associated with a channel? Any help would be greatly appreciated. Regards, Callum Link to comment Share on other sites More sharing options...
AzeoTech Posted May 8, 2017 Share Posted May 8, 2017 -Can you freeze the graph at a certain time? IE after 120 seconds? There are a couple ways. 1) you can just stop taking data, 2) you can subset the Y Expression on time. So, when the timer starts, set a variable called starttime to system, then in your Y expression you might put: myChannel[startTime, startTime + 120] -Is there a way i can display the value of a channel at a certain time? IE Initial pressure, and final pressure (then finally calculate the pressure drop, and the test result?) The best way to do this is probably to capture the desired value at that time to a global variable. -I tried setting the value expression to: Mychannel[StartTime] That only works if MyChannel has a data point at exactly StartTime down to the microsecond. This usually only happens if you actually set startTime to a timestamp from the channel. It will (almost) never work if you do startTime = systime(). You can range the subset: myChannel[startTIme, startTime + 0.99], but its not as reliable as my first suggestion. I also thought to create a variable called initial_value = mychannel(startTime) however i cant seem to 'display' a variable. Must the value be associated with a channel? That is basically what I was suggesting, but you want: initial_value = myChannel[0], then put initial_value in your control. Link to comment Share on other sites More sharing options...
caljones Posted May 10, 2017 Author Share Posted May 10, 2017 Thanks for your help. There are a couple ways. 1) you can just stop taking data, 2) you can subset the Y Expression on time. So, when the timer starts, set a variable called starttime to system, then in your Y expression you might put: myChannel[startTime, startTime + 120] Are you able to explain how to start and stop taking data through an expression? I implemented the initial_value = mychannel[0] as a global variable, and it did record the pressure when the sequence begins as a static variable. While this is on the right track, it isn't exactly what i want. Basically, the program i have written pressurizes a physical volume through relays until a certain pressure is reached. It then needs to graph the pressure drop over a certain period of time. Thus, i dont know exactly when the "initial pressure" will be reached,(as this may change test to test) i only know where in the code it will happen. I guess this is related to what you wrote, in that i need to capture the desired value at that time to a global variable. Are you able to explain how to do this? Link to comment Share on other sites More sharing options...
caljones Posted May 10, 2017 Author Share Posted May 10, 2017 I also found this code and attempted to use it, however it is not returning any value. private theTime = myChannel.time[0] ? myChannel[theTime] Link to comment Share on other sites More sharing options...
AzeoTech Posted May 11, 2017 Share Posted May 11, 2017 You got it: if you know the point in your program where the desired pressure is reached, you can capture that value with initial_value = mychannel[0] Then you also know the start time, which is just: initial_value.time[0] or you can set an additional global variable with the time: global initial_value = mychannel[0] global starttime = mychannel.time[0] Then you can graph data from that point: myChannel[starttime, systime()] or, if you want it to end: myChannel[startTime, endtime] but in that case, you'll need to set endTime to something big initially: global initial_value = mychannel[0] global starttime = mychannel.time[0] global endtime = starttime * 2 and then in script, or in a quick sequence button fix endtime to something real when you want the graph to stop adding new points: endtime = systime() Finally, you could also use max() to figure out the maximum pressure and the time of that point: global initial_value = max(myChannel) global starttime = gettime(initial_value) Max() returns the maximum value, but it also returns the time of that maximum value tagged to that value. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.