Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

AquaPro Binary data


sinusoid Feb 14, 2013 06:49 PM

I am trying to control a Nortek AquaPro with a CR1000. I would like to record the binary output data on the CR1000 as well as on the Nortek. I can send the Nortek commands using SerialOut and commands listed here...
http://www.nortek-as.com/lib/manuals/system-integrator-manual-september-2011.

I am using the following CR1000 code...

SerialOpen(Com3,9600,0,0,10000)
SerialOut(Com3,"@@@","",0,100) 'command to wake up instrument and enter command mode
Delay(0,2,sec)
SerialFlush(Com3) 'flush acknowledgement of above command
SerialOut(Com3,"SR","",0,100) 'starts logging and reporting in Binary
Delay(0,2,sec)
SerialFlush(Com3) 'flush acknowledgement of above command
Do
SerialInRecord(Com3,Aquadopp,0,150,0,bytes,01)
Loop While bytes = 0
SerialOut(Com3,"@@@@@@","",0,100) 'starts the interrupt of the sampling routine
Delay(0,100,mSec)
SerialOut(Com3,"K1W%!Q","",0,100) 'finishes the interrupt of the sampling routine
SerialFlush(Com3) 'flush acknowledgement of above command
Delay(0,2,Sec)
SerialOut(Com3,"MC","",0,100) 'returns the instrument to command mode

but so far it seems to be working inconsistently and the when data does come in it doesn't look like the binary data that I get using a terminal emulator for the instrument. The Nortek is setup to sample for 5 seconds every 10 seconds for the sake of speed in my bench-top test. The data does not end with any consistent character, but it does start (from what I have seen) with a character that looks like a heart with lines drawn through it.

I have not worked with binary data much at all. Any help would be appreciated.


Sam Feb 18, 2013 06:16 AM

The manual link requires a user and pass.

If you haven't seen this, it is worth checking out.
https://s.campbellsci.com/documents/us/technical-papers/serial.pdf

I suggest that you use SerialInBlock(). Your data may contain null characters. During development and debugging, I recommend that you take advantage of the logger's port snooping capabilities. Open a terminal session with the logger (not the same one you are trying to snoop). Use CR1000>H to see the available menu items. Use W to enter the "watch" mode. Select the com port you wish to watch and answer N (no) to the prompt for ASCII mode. You will be able to view the "binary" traffic in hexidecimal.

Since the responses from the sensor contain non-printable characters, the table / numeric monitor won't do you much good when monitoring the contents of the string destination variable of the serial input instruction.


sinusoid Feb 19, 2013 04:19 PM

Thank you very much Sam. I am able to see the 'binary' coming in on the terminal window as two character pairs. The data is, however, being saved as a single '!' in the output table. I understand I cannot see the data in the Connect Screen, but is there any way to save the incoming data to the data table?


Sam Feb 20, 2013 02:20 AM

It would be a lot easier to help if you posted some data traffic and what you expect to get / how it should be decoded.
Once the data is in your destination string you will need to use the bytes in the string to construct your data points.


sinusoid Feb 20, 2013 03:47 PM

Here is what Hyper Terminal sees, and what I would like to record...

A5 21 F1 00 54 14 19 14 13 02 00 00 00 00 94 00 9A 3B D8 0C
03 00 3B 00
00 30 47 00 45 09 FF 01 BD 0D F4 06 06 02 21 02 EB 09 9A 05
68 07 41 07
DF 03 45 07 A2 07 39 06 B7 05 DF 08 7E 06 73 04 D9 02 96 08
2D FE 22 0B
5B 00 AE 02 CC 06 3B 03 F2 05 C5 07 93 FF D5 09 05 03 41 09
B0 06 7A 0A
6F FF 52 03 89 FE BC 0C 7C 04 13 0D 19 07 BD FF 94 09 61 05
41 06 D9 0A
F5 02 B0 00 03 0D 5E 05 10 03 47 00 9B FD 15 02 8D FF 78 FE
8E 04 1D FF
9D F8 64 F9 12 03 61 FF 66 00 FD 04 7C 08 DF FF 55 02 13 01
10 01 0E FA
36 FF B1 FE BD 07 E3 FF 0E FB D7 05 21 FC 6D FC AE F0 BF F6
34 03 25 03
E2 FA 5D FD 16 FC 4E 01 89 FD 83 FF BF FB 98 03 C4 FB 9F FE
EA F1 EE FB
8D FC 53 F9 57 02 73 FE 8A 02 B9 FC C4 FF 9C 00 ED FF 39 00
D1 FD 11 00
BC FF 8E FE 07 00 0D 02 AA FC 6E FE FE FE 16 FF 9C FD BE FB
13 FF 64 FE
48 FC C0 FD 7C 01 E7 FC 3B FF C1 FF E4 01 52 00 3C 02 92 FF
68 00 E6 FE
24 FE AB FF 56 FF 62 FE 28 FE 06 FE 59 FF 35 FE 28 00 DE 00
1D FE 41 00
29 00 FA 00 BC FF 5C FF 82 01 52 02 54 FD A0 01 5D 01 16 15
15 16 16 16
16 16 15 15 15 15 15 16 15 15 15 16 16 15 15 16 15 15 16 15
15 15 15 15
15 15 15 15 16 15 15 15 15 15 15 15 16 16 15 15 15 15 15 15
14 14 15 14
14 14 15 15 14 14 14 14 14 14 14 14 14 14 14 15 14 14 14 15
14 14 15 14
14 15 14 14 15 14 14 15 14 14 14 14 14 14 14 14 15 14 14 15
15 14 16 16
16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
16 16 16 16
EE 81


Sam Feb 21, 2013 03:07 AM

What about it would you like to record?
You you like to break up the data stream up into a series of 4 byte floating point numbers?
You did not include information about "how it should be decoded". We need more information about how the data should be interpreted.


sinusoid Feb 22, 2013 04:07 PM

I would like to record the full incoming string of binary data.


Sam Feb 24, 2013 04:40 AM

then i suppose you should bring it in, covert it to ascii hex, and log it as a string.


Declare 2 string variables
One large enough to hold the data
A second large enough to hold the data as converted to an ascii representation of the hex values

Dim dataIn as string * 160
Dim dataASCII as string * 320
Dim I as long

SerialInBlock(ComPort,dataIn,NumBytes)

dataASCII = ""
for I = 1 to NumBytes
dataASCII = dataASCII & FormatLong(ASCII(dataIn(1,1,I),"%02x")
next I

then save dataascii to a table using the string data type.

there are a couple of other ways to log the data.

you could use an array of longs as the destination i think. not 100% sure.
Dim dataIn(40) as Long
and save the data in your datatable with the correct number of reps and a data type of Long

or you could do something like the first method and put each byte into a single element of an array of longs like
Dim dataIn as string * 160
Dim dataLng(160) as long
Dim I as long
Move(datalng,160,0,1)
for I = 1 to NumBytes
dataLng(I) = ASCII(dataIn(1,1,I)
next I


sinusoid Feb 25, 2013 04:37 PM

I tried your first method and was able to partially capture the incoming string. This is what terminal Emulator was showing....

R 08:26:15.89 A5 21 F1 00 26 01 25 08 13 02 00 00 00 00 94 00 88 3B DC 0C
R 08:26:15.89 02 00 3A 00
R 08:26:15.92 00 30 FA 00 FE 08 47 06 F6 05 11 05 E3 04 49 07 69 00 9B 04
R 08:26:15.92 02 04 65 07
R 08:26:15.94 B3 03 B9 06 45 08 AC 05 DE 06 52 04 1B 05 9F 01 6C 07 68 07
R 08:26:15.94 AC 07 02 04
R 08:26:15.97 26 07 BA 03 0B 04 31 02 60 05 5E 02 71 07 99 04 66 06 2C 04
R 08:26:15.97 FD 02 A0 02
R 08:26:15.99 2C 05 3E 05 DA 03 56 06 2D 04 FB 06 03 03 FE 04 0D 08 75 09
R 08:26:15.99 03 04 AF 08
R 08:26:16.02 13 03 CE 04 47 07 27 04 D0 02 14 00 9B F9 E8 FC 6A FD 66 FD
R 08:26:16.02 E6 FB C2 01
R 08:26:16.07 10 FC D3 FE 6E FE 1B FB 4D 00 80 FF 13 FA CC FD 47 02 49 02
R 08:26:16.07 E0 FA B2 FB
R 08:26:16.07 DD FD 55 FC 59 FE EE 00 44 FE 21 FC CB FE 80 FB 4A FE 61 02
R 08:26:16.07 04 FE 72 FD
R 08:26:16.12 E8 FE A5 FE 05 FE A5 FC 8A F9 05 01 82 FF CD FD 41 FE 7A FF
R 08:26:16.12 40 FF D7 FE
R 08:26:16.14 DD 00 0F FF 04 00 ED FE 4E FF 63 FF A0 FF 30 FF 5D FF 50 FF
R 08:26:16.14 F9 FF 66 FF
R 08:26:16.17 94 FF 7D FF 9C FF 49 FE DB FE 19 FE E7 FE 37 FE FB FF CB FF
R 08:26:16.17 E1 FF 53 FE
R 08:26:16.19 75 FF A7 FF A1 FE B3 FE 5C FE F9 FE BA FE 79 FF ED FE 80 FF
R 08:26:16.19 B2 FE 2D FF
R 08:26:16.22 57 FF 16 FF BE FE 3E FE 7B FF 58 FF 19 FF F5 FE B6 FF 15 15
R 08:26:16.22 15 15 15 15
R 08:26:16.24 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
R 08:26:16.24 15 15 15 15
R 08:26:16.27 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
R 08:26:16.27 14 14 14 14
R 08:26:16.29 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14
R 08:26:16.29 14 14 14 14
R 08:26:16.32 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14
R 08:26:16.32 14 14 16 16
R 08:26:16.32 16 16 16 16 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
R 08:26:16.32 16 16 16 16
R 08:26:16.37 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
R 08:26:16.37 16 16 16 16
R 08:26:16.40 90 13

And this is what was recorded...

210026012508130200000000003b0c02003a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

I know the time stamp is not something sent by the instrument, so it does not exist in the string(which is fine), but do you know why the alpha characters were not saved? I am guessing the extra 0's are just filling up space, but there is a large amount of data that is not recorded.


Sam Feb 26, 2013 05:56 AM

What alpha characters?
Your data stream is chock full of non printable and control characters.
http://www.asciitable.com/index/asciifull.gif


Sam Feb 26, 2013 06:36 AM

Since you hadn't posted the information about how to decode the datastream, I created an account on Nortek's website.
You're going to need to pull in the data into a string and begin parsing it character by character according to section 5.4


For example,
A5 = sync byte
21 = this is aquadopp profiler velocity data
F1 00 = looks like this needs to be interpreted as &h00F1 = 241 words of data output
26 = 26 minutes
01 = 1 second
25 = 25th day of month
08 = 8th hour
13 = 13th year of century
02 = 2nd month of year
00 00 = no errors
00 00 = analog input 1 = 0
94 00 = interpret as &h0094 = 14.8 volts
88 3B = &h3B88
...
so on and so forth.

this isn't going to be easy by any means for the novice programmer.

You are going to want to contact your local campbell scientific office to inquire about getting help.

alternatively, why not use the ASCII output mode using the "AS" command? (page 19 of the manual)


sinusoid Feb 27, 2013 06:17 PM

Within the string of incoming hex data there are numbers and letters (A5 21 F1), the numbers are being saved more than the letters(I may need to loop through looking for the incoming data as it comes in in waves as seen in the time stamp or try SerialInRecord?). I need to preserve every character that comes in. So ultimately I would like the above string to be saved to the CR1000 looking like this...

A521F10026, etc.

That way I can spoof the data for the AquaPro software by tossing a header on it and can then process it.


I didn't see the most recent response before posting...

thank you for that, I had looked through that document many times, but missed that table. The ASCII output does not output the full dataset. I gives only a 2D (XY-direction and velocity) vector as opposed to the 3D vector that is desired.

I have had a couple discussions with David Odd, and he said he would look into it. Otherwise it does not seem that this instrument is capable of real-time data without a computer running their software.

* Last updated by: sinusoid on 2/27/2013 @ 2:17 PM *


sinusoid Mar 26, 2013 05:05 PM

Sam, have you been able to put anymore thought into this issue? David has not gotten back to me, and I have been messing around with the tool, with no success.

I also noticed that according to the data collection results that I am getting 327 new values each sampling punch, but each row of data look like this...

2013-03-26 09:07:45 40 13.83 22.14 1013.115 ""

Where are the 327 values? Is it collecting the hex data and just unable to display it?

* Last updated by: sinusoid on 3/26/2013 @ 11:40 AM *


Sam Apr 20, 2013 07:32 PM

Const ComPort = ComRS232

Public AP As String * 700 'raw input from sensor
Public APBytes As Long 'number of bytes read in
Public APHex As String * 2000 'hex string
Public APHexLen As Long 'length of hex string
Dim tmpLng As Long
Dim I

DataTable (Test,1,1000)
Sample (1,APHexLen,Long)
Sample (1,APHex,String)
EndTable

BeginProg
SerialOpen (ComPort,9600,3,0,500)
Scan (5,Sec,0,0)

'init string that will contain hex pairs
APHex = ""

'while there are bytes in the comport buffer
Do While SerialInChk(ComPort)
'read in data from buffer
APBytes = SerialInBlock (ComPort,AP,700)
For I = 1 To APBytes 'for each byte read in
'pull it out
tmpLng = AP(1,1,I)
'convert it to a hex pair, e.g. 0a or a1
APHex = APHex & FormatLong (tmpLng,"%02x")
Next I
Loop
'get length of final hex string
APHexLen = Len(APHex)
'if have data, put it into the table
If APHexLen Then CallTable Test

NextScan
EndProg

* Last updated by: Sam on 4/20/2013 @ 1:59 PM *


heiko Apr 1, 2014 02:50 PM

Hi sinusoid, hi Sam

did you solved the problem already?

I suppose I will get the same Problem, with reading the Nortek Profiler data with the CR1000.
I was just starting with the Programming, but a suggestion would be good!
Currently I could not see the whole string as the incomming string!

cheers
Heiko

Log in or register to post/reply in the forum.