jgad Posted May 19, 2022 Share Posted May 19, 2022 Hi, Excuse my ignorance, I'm a total beginner with Daqfactory. I have a device (an Omega HX200 Temperature/RH probe) which streams data over an RS232 connection, I can see the data coming in under monitor and get a sting of data such as this below... Quote Rx (09:46:46.923): \010 \013\03 7\082\072\061\032\053\057\046\050\052\044\032\068\080\067\061\032\049\049\046\053\048\044\032\065\084\067\061\032\049\057\046\053\049 I have set up a new protocol, but think that the script in the user guide (shown below) is telling the "if loop" to stop after the first (13), is this correct? Quote if (strIn == Chr(13)) private string datain = ReadUntil(13) Channel.AddValue(strDevice, 0, "Input", 0, StrToDouble(DataIn)) Endif I cannot for the life of me work out how to get this to display as values for individual measurements for RH and Temperature. Please help with an appropriate protocol. Endif Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted May 20, 2022 Share Posted May 20, 2022 Looking at the numbers in the comm monitor you have ASCII data, so if you uncheck the box that says "Display all chars as ASCII codes" you will better be able to see what the data looks like, and then how to parse it. I also don't recommend creating a user protocol. Just create the device with a NULL protocol and create a sequence to do the processing. If you can post the ASCII form of the data stream I can better tell you how to process it. Quote Link to comment Share on other sites More sharing options...
jgad Posted May 24, 2022 Author Share Posted May 24, 2022 With display all characters as ASCII unchecked I get something like the following... Quote Rx (09:25:11.004): \010 \013 %RH= 44.86, DPC= 9.11, ATC= 21.35 All the values listed as RH, DPC and ATC are variables and change with the climatic conditions. I'm not sure where to start with a sequence for this data! Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted May 25, 2022 Share Posted May 25, 2022 OK, so now you can see it is pretty easy to read, and not hard to parse. Assuming you created a serial device named "myDevice", the script would be something like: while(1) private string datain = device.myDevice.readUntil(13) private string pdata = parse(datain, -1, ",") private rh =strToDouble(parse(pdata[0],1,"=") private dpc = strToDouble(parse(pdata[1],1,"=") private atc = strtodouble(parse(pdata[2],1,"=") endwhile Then you just have to decide what you want to do with those three private variables with your values. Probably add them to a channel: myRH.addValue(rh) etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.