04-14-2012 12:48 PM
Hi,
I was checking whether you had a feedback on the proposed solution. Anyway I tested all three (Data Separator, Data Seprator 1 and String of 3's). Here is my small report:
Input: two values for the 24bits final conversion, repeated 100 times.
393A3B which correspnds to 3750459
3C3D3E which correspnds to 3947838
So, as an ouput, I would explect a numeric int32 signal oscillating between these two values.
Report on the previous methods:
method #1: StringStStream2binary1.vi
resembling the strategy of "Data Separator 1.vi", I work on triplets of Hexadecimals data, extracting the sign from the first triplet. In the output I observe two problems:
1. The first element of the array read in Matlab is the number of cicles N in labview routine, and I dont see how to get rid of this.
2. The signal oscillates between to values, 0 and 9, which are not the expected values.
method #2: StringStStream2binary2.vi
resembling the strategy of "Data Separator.vi", it works perfectly. I mention it because I dont get what are you doing with this 0 hex added before the conversion. Where to you find that string format?
I still have the same problem as in the previous case, the first element of the array read in Matlab is the number of cicles N in labview routine. Is it a Matlab or a Labview problem?
method #3:Strings-of-3 to Numbers.vi 24 KB
it works perfectly, same as #2.
I tried to include "StringStStream2binary2.vi" in my VISA based "Basic Serak Read2filrBmeth2.vi", but what I get it is only zeros, and a timeout error. Could you suggest me where to look for mistakes?
I attach the 3 viS, and also the matlab file, that I use to read the data.
For the hardware I dont anything to hide, but just to make things simpler for you, I acquire a serial stream through VISA, and need then to decode a stream of strings.
Thanks
Tommaso
04-14-2012 12:52 PM
Hi,
I was checking whether you had a feedback on the proposed solution. Anyway I tested all three (Data Separator, Data Seprator 1 and String of 3's). Here is my small report:
Input: two values for the 24bits final conversion, repeated 100 times.
393A3B which correspnds to 3750459
3C3D3E which correspnds to 3947838
So, as an ouput, I would explect a numeric int32 signal oscillating between these two values.
Report on the previous methods:
method #1: StringStStream2binary1.vi
resembling the strategy of "Data Separator 1.vi", I work on triplets of Hexadecimals data, extracting the sign from the first triplet. In the output I observe two problems:
1. The first element of the array read in Matlab is the number of cicles N in labview routine, and I dont see how to get rid of this.
2. The signal oscillates between to values, 0 and 9, which are not the expected values.
method #2: StringStStream2binary2.vi
resembling the strategy of "Data Separator.vi", it works perfectly. I mention it because I dont get what are you doing with this 0 hex added before the conversion. Where to you find that string format?
I still have the same problem as in the previous case, the first element of the array read in Matlab is the number of cicles N in labview routine. Is it a Matlab or a Labview problem?
method #3:Strings-of-3 to Numbers.vi 24 KB
it works perfectly, same as #2.
I tried to include "StringStStream2binary2.vi" in my VISA based "Basic Serak Read2filrBmeth2.vi", but what I get it is only zeros, and a timeout error. Could you suggest me where to look for mistakes?
I attach the method #2, and the method included in my VISA routine.
I read the ".dat" file in Matlab, with a simple command:
fid = fread(filename,'int32').
I don't think this can be source fo mistakes.
For the hardware I dont have anything to hide, but just to make things simpler for you, I acquire a serial stream through VISA, and need then to decode a stream of strings.
Thanks
Tommaso
04-14-2012 04:50 PM
It is a little bit hard to understand your message because you refer to VIs and methods that you have not attached to your post. However, I think I can easily resolve at least one of your problems. The reason that the first value you read is the number of loops in the LabVIEW program is because when you write to the binary file, you have set the "Prepend Array or String Size" input to TRUE. That input tells LabVIEW to write the array size to the file before the data. Set it to false, as you have done in the Basic Serial Read.
As for the "00" string, right-click on a string constant and choose "Hex Display" to see this format. It is necessary to add an extra byte to extend the 3-byte string to 4 bytes so that type cast can correctly convert it to a 4-byte (32-bit) integer. Let me suggest a much simpler and more efficient way to do the conversion, using a 3-byte cluster and "Scale by Power of 2":
Are you sure about the serial port settings? "3070000" is a strange value to use as the baud rate. It's also strange that you would write to one serial port and read from a different port, is this what you want to do? Do you need the write to occur before the read? If so, you should use the error wires to force the operations to happen in the correct order, because right now you may attempt to do the read before you do the write.
05-04-2012 07:20 AM
Hello everybody again,
I must say that I am quite happy with the solution you proposed. Many thanks, the conversion runs smoothly.
I have another problem now: When I set the number of bytes to a value higher than 270k I get a memory problem message.
How can I overcome it?
Please find attached the file I built.
N = number of bytes to read in "bytes to read" tab
N/3 = number of cicles for the conversion (it could be automatically set...) in "#of24bitsamples"
Many thanks,
Tom
05-04-2012 12:30 PM
Instead of doing everything at once, break it up into smaller chunks. That is, read a small number of bytes from the serial port, convert it, write to the file, then repeat until you have converted all the data. Keep the file open so that each new block that you write will be appended to the file.
05-09-2012 08:47 AM
Thanks for the suggestions. I tried to implement a FOR cicle, but I get dataskipping, even for one cicle.
I can generate a sawtooth signal from the µController of my device, and read it out with Labview 2010 (VISA interface).
I post here a simplified version of my script (without 24bit conversion, just looking at strings) for the two cases:
- "DoubleSerialPort_uint8_2Binary_in_blksLOOP.vi" without FOR cicle, which works well for a limited amount of bytes, up tp 270 kB on average,
- "DoubleSerialPort_uint8_2Binary_in_blks.vi" with FOR cicle, which presents data skipping even for N = 1.
Do you have comments/suggestions on that?
Thanks, Tom
05-09-2012 04:28 PM - edited 05-09-2012 04:30 PM
As far as I can tell, both of the VIs you posted are identical and neither contains a for loop.
EDIT: also, the sequence structures are unnecessary.