Sequence Not Starting


Recommended Posts

Posted

We are using the sequence below to log a TOC analyzer to DAQFactory. However, it is giving me an 'uncaught error' in line 4.

 

device.TOCOutput.purge()
while(1)
   try
      private string datain = device.TOCOutput.ReadUntil(13)
 
      // Modifying string for IC
      private string vIC = delete(datain,1,32)
      vIC = delete(vIC,5,17)
 
      //Modifying string for TC
      private string vTC = delete(datain,1,36)
      vTC = delete(vTC,5,13)
 
      //Modifying string for TOC
      private string vTOC = delete(datain,1,27)
      vTOC = delete(vTOC,5,22)
      delay(1)
endwhile
Posted

The sequence doesn't compile because you have a try but no catch.  The indenting should give that away.  At the end you skip back 6 spaces instead of 3 to the endwhile which tells you you missed something.

Posted

Oh thanks, it works now however I do not get the correct numbers because my guess I should manipulate this code for a serial connection since it was written for an ethernet connection?

Posted

What string?  If you want to output something, type it in the area at the top of the comm monitor and hit enter.  In order to use the comm monitor, you have to right click and select the desired port.

Posted

Here you are:

 

Rx (16:16:38.243): \084\117\114\098\111\044\049\048\032\074\085\078\032\050\048\049\052\044\049\054\058\049\053\058\052\049\044\049\053\049\044\050\051\052\044\051\056\053\044\050\046\048\044\050\046\048\044\078\047\065\013\010

Posted

Can you please repost with the "Display all ASCII chars as Codes" unchecked?  Its obvious from those numbers that you have an ASCII string, not a binary protocol, and having that checked gives us binary numbers.

Posted

OK, delete() is not the function you want.  You want parse.  I don't know which number is which, but, for example, to extract the -2.45 you'd do:

 

vIC = parse(datain, 3, ",")

 

for the 151 just change the 3 to a 4, etc.

Posted

So I am using the following right now but not yet creating a logging file on the computer.

 

device.TOC.purge()
while(1)
   try
      
      // Modifying string for IC
      vIC = parse(datain,4,",")
 
      //Modifying string for TC
      vTC = parse(datain,5,",")
 
      //Modifying string for TOC
      vTOC = parse(datain,3,",")
      
//Adds Channels for each output
      IC.AddValue(StrToDouble(vIC))
      TC.AddValue(StrToDouble(vTC))
      TOC.AddValue(StrToDouble(vTOC))
   catch()
      ? strLastError
      delay(0.01)
   endcatch
endwhile
 
while(1) 
   logging.TOC.strFileName = "c:\DAQFactoryData\TOCOutput.csv_" + formatdatetime("%m.%d.%y",systime()) + ".csv" 
   delay(1) 
endwhile
Posted

Try just deleting the logging set and creating a new one.  Its possible you changed one of the settings that is causing it to appear not working.  By creating a new logging set you'll get the defaults which work.  Alternatively you can post your .ctl file.

Archived

This topic is now archived and is closed to further replies.