Munro Posted February 8, 2013 Share Posted February 8, 2013 Hi, I am reading date from a device its polling beautifully but far to often. I am trying use the read() staement and the delay (readinterval), so that it only reads as I get new data on the channel, at present its reading continusily. How can I correct this? Look forward to your reply while (1) read(CW1A_Weight) delay(1) endwhile Link to comment Share on other sites More sharing options...
AzeoTech Posted February 8, 2013 Share Posted February 8, 2013 I'm unclear what is happening. If your CW1A_Weight channel has a Timing of 0, and you run the script you provided, it will read that channel once a second. Is this not what you want? Link to comment Share on other sites More sharing options...
Munro Posted February 11, 2013 Author Share Posted February 11, 2013 Hi, No I want it read only when I get new data on the channel, I tried using the readinterval but am unsure how this works. I will not run and throws up errors and the manual with respect I feel does not explain well how to get this working. Look forward to your reply Thanks Link to comment Share on other sites More sharing options...
Munro Posted February 11, 2013 Author Share Posted February 11, 2013 I did use while(1) read(CW1A_Weight) deal(readinterval) endwhile This just throws up errors and I dont understand from the manual how to get the readinterval Thanks Justin Link to comment Share on other sites More sharing options...
AzeoTech Posted February 11, 2013 Share Posted February 11, 2013 So you want to read one channel only when you get new data on another channel? I'm unclear when you want to do the read. The script above will read that channel at a variable interval determined by the readinterval variable. To get it to work, you need to declare and define readinterval somewhere, for example: global readInterval = 1 Link to comment Share on other sites More sharing options...
Munro Posted February 12, 2013 Author Share Posted February 12, 2013 i want to read the channel CW1A_Weight and only display the data on my page as new data arrives which is variable. Hope that makes sense Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted February 12, 2013 Share Posted February 12, 2013 Sorry, I'm still unclear what you mean by "new data arrives". You are using Modbus which is a poll / response protocol. This means that DAQFactory has to poll the device to get a new value. The device can't push a new value to DAQFactory when the value changes. If you just want to see the most recent reading of CW1A_Weight, set the timing of that channel to, say, 0.25, then create a variable value component and put: CW1A_Weight[0] for the Expression. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.