asaikk Posted February 19, 2012 Share Posted February 19, 2012 In the case where two data are read on two channels (ex. MyChannel_1, MyChannel_2) respectively, Where should I put the expression for calculation of two data such as below? MySum = MyChannel_1[0]+MyChannel_2[0] Can I put it on Either of the two channels, or should I make a sequence? And how should I declare "MySum", private, public or global? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 20, 2012 Share Posted February 20, 2012 Technically you can't use the event for the channels because you don't know which will be read first, so you probably have to put it in a sequence. The other question is why you even bother to create another variable, unless you want to log the sum (and then you'd need another channel, not a variable). You can access the sum at any time by doing: myChannel_1[0] + MyChannel_2[0] wherever you want the sum of the most recent readings. If you want to graph the sum, drop the [0]'s from above. As for your other question, there is no "public" variable type, just private and global, and you'd most likely want global. Private would only be accessible in your sequence. Link to comment Share on other sites More sharing options...
asaikk Posted February 21, 2012 Author Share Posted February 21, 2012 Many thanks for your reply and suggestion. Link to comment Share on other sites More sharing options...
cragjumper Posted August 10, 2012 Share Posted August 10, 2012 How does this change if your data is being streamed in the two channels? I'm streaming data from a duty cycle measurement using Timer0. Rather than logging the MSW and LSW on two channels and then processing the data later, I'd like to calculate the duty cycle as the data is being captured and then only log the calculated duty cycle value. Any suggestions? Link to comment Share on other sites More sharing options...
AzeoTech Posted August 11, 2012 Share Posted August 11, 2012 There isn't really a way to do this easily because streaming data comes in in blocks. You'd have to write script that figures out the size of the block then cycles through that block and processes each point. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 14, 2012 Share Posted August 14, 2012 See this topic for how to calc block streaming: http://www.azeotech.com/board/index.php?/topic/4895-how-to-both-stream-and-log-duty-cycle-calculations-as-well-as-raw-measurement/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.