Robin_H Posted February 16, 2012 Share Posted February 16, 2012 Apologies if this question has come up before but I have been unable to find a specific thread to help me yet... honest! I am trying to connect an ultrasonic anemometer to our try-before-we-buy version of DAQFactory. The data comes out of the equipment in the following NMEA string which updates every second: $IIMWV,123,R,5.8,M,A*27 where 123 is the wind direction and 5.8 is wind speed. My question is, how do I get the wind direction and wind speed figures to display on the DAQFactory screen(s)? Many thanks in advance. Robin. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 16, 2012 Share Posted February 16, 2012 I'm assuming the NMEA string ends with a linefeed character (slash 010 in the monitor)? 1) create two channels, Device Type Test, I/O type A/D, CHannel # 0 and 1, Timing = 0. Call them windDir and windSpeed (you can call them what you want, but I'm going to use those names) 2) create a new serial device by going to Quick - Device configuration and selecting new Serial / Ethernet. Create your comm port, select the NULL protocol, give your device a name (for this example, I'll call it "anem"), and hit ok. 3) add a sequence: device.anem.purge() private string datain private data private thetime while (1) try datain = device.anem.readUntil(10) thetime = systime() if (left(datain,6) == "$IIMWV") // we have a wind line: data = strtodouble(parse(datain,1,",") data.time = systime() winddir.addValue(data) data = strtodouble(parse(datain,3,",") data.time = systime() windSpeed.addValue(data) endif catch() ? strLastError endcatch delay(0.5) endwhile Run the sequence to have it start collecting data and putting the results in your channels. You can then use the channels anywhere you would normally use a channel in DAQFactory. Link to comment Share on other sites More sharing options...
Robin_H Posted February 17, 2012 Author Share Posted February 17, 2012 Many thanks for your quick response. Unfortunately after following the above procedure I cannot get the channels to display the data coming from the anemometer. The full NMEA string being displayed in the monitor window is: Rx:_$IIMWV,312,R,1.0,M,A*211310. What am I doing wrong? Many thanks. Robin Link to comment Share on other sites More sharing options...
AzeoTech Posted February 17, 2012 Share Posted February 17, 2012 There's an underscore before the $? Then change the if() to: if (datain.left(7) == "_$IIMWV") Link to comment Share on other sites More sharing options...
Robin_H Posted February 20, 2012 Author Share Posted February 20, 2012 Sorry to be a pain but I am still having problems with the amended sequence. With Channel Tming set to 0 the displays do not update at all, however, entering a figure into the Timing column just causes spurious figures between -1 and +1 to be displayed. It is almost as if the sequence cannot see the data coming in on Comm 1 even though I can see the data in the Comm Monitor window. What should I try next? Many thanks. Robin Link to comment Share on other sites More sharing options...
AzeoTech Posted February 20, 2012 Share Posted February 20, 2012 Changing the Timing to 1 makes the channel work like a Test channel, which means it will generate a sin wave, so leave it at 0. If data isn't coming in, its probably the if(). To debug it, add: ? datain right after the device....readuntil(10) line. This will print what the sequence is reading to the command/alert window. Also, make sure you don't have an errors showing up in command alert. Link to comment Share on other sites More sharing options...
Robin_H Posted February 21, 2012 Author Share Posted February 21, 2012 Okay, I'm getting "C1000 Channel or function not found: anem Line 10" followed by the data line from the anemometer in the Command/Alert window, (screen grab attached). I will play around with the sequence for a while longer, as the data appears to be getting to the sequence, and let you know how I get on. Many thanks. Robin Comm_1_screen_grabs.rtf Link to comment Share on other sites More sharing options...
Robin_H Posted February 21, 2012 Author Share Posted February 21, 2012 SUCCESS!! Through a process of elimination. and with reference to the manual. my first hurdle of constructing our replacement DAQ has been removed. Many thanks for all your help. For reference, here's my amended script: device.Gill_Anem.purge() private string datain private data private thetime while (1) try datain = device.Gill_Anem.readUntil(10) //read serial sentence ? datain //display datain sentence in command/alert window thetime = systime() data = parse(datain,1,",") //pick out wind direction data.time = systime() Gill_Dir.addValue(data) //output direction figure for display data = parse(datain,3,",") //pick out wind speed data.time = systime() Gill_Spd.addValue(data) //output speed figure for display catch() ? strLastError endcatch delay(0.5) endwhile Many thanks. Robin Link to comment Share on other sites More sharing options...
AzeoTech Posted February 21, 2012 Share Posted February 21, 2012 Ah, silly me. I've been programming in too many languages lately. It should be left(datain,6), not datain.left(6). I've corrected my original post. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.