LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DATA manipulation #2

Please help me with my concept and stuff. i do need to finish them for my senior project

zhi
0 Kudos
Message 11 of 23
(1,715 Views)

zhi,

All the information you need is in section 8 of the manual.  Section 8.3 describes in detail the structure of the command packets.  Section 8.4.7 specifically calls out what 3 32 bit words of data must be transmitted to the instrument to perform the START command.  Simply writing START to the COM port will not work.  This section also specifies how the instrument will acknowledge the start command before it begins transmitting the data.  You now have the code to parse out the measurements.  You must now write the code to send the start command to the instrument.

0 Kudos
Message 12 of 23
(1,712 Views)
Zhao: Relax. Some of the folks on this forum (like me) have full-time jobs, so we can't always respond right away.

centerbolt: The manual seems to imply that the device continuously spits out data on the serial port when it's powered on. At least, that's what it looks like the manual is implying. The manual looks like it was translated from another language, so it's not all that clear. It seems that the START command is only necessary if you've issued a STOP command. However, if the device spits out data as soon as it's powered on, creating those commands may not be necessary.

You're right about the multiple 32-bit words used for the commands, and Zhao, your VI doesn't do anything about creating these commands. If you're trying to send the "*IDN?" command that's useless, as that's not how you're supposed to send commands to this device. I would suggest that you contact the manufacturer to confirm the operation of this device.
0 Kudos
Message 13 of 23
(1,708 Views)

smercurio,

You obviously read more of the manual than I did.  If it is doing a continuous stream of data, then vi will need some functionality to differentiate between pairs of data?  Some sort of sync?

0 Kudos
Message 14 of 23
(1,706 Views)
Probably. It may be something as simple as seeing if the first byte starts with the first bit set to 1, since according to page 31, the high byte is transmitted first, and it always starts with the first bit set to 1. The lower byte always starts with the first bit set to 0.

Of course, this is all based on the assumption that the device continuously spits out data measurements, and it does so by transmitting 2 bytes for each value. Zhao really needs to confirm this with the manufacturer.
0 Kudos
Message 15 of 23
(1,702 Views)
Dear smercurio and centerbolt,
                   What you have said about the sensor are all correct. I have comfirmed the following with the manufacture:
 
1. The sensor start to send out the measured value once it is powered on. It does contiuesly split the data.
2. I do need to write a code to compose the command by myself (i guess I will try to do it later, I have to get the value first)
3. The sensor does sent out and Hi and low bites to represent a value. ( I m wandering if the bytes read by VISA read will effect this result).
 
With the above facts, can anyone of you tell me what i should do in order to properly get a correct reading due to my lack of knowledge. ( If anyone of you can recmmand any kind of resouce that will help me too?)
 
Thanks for all spending time on my post. If i have a chance, I will treat your guy a dinner once i finish my senior project.
 
sincerely
zhi




Message Edited by zhao.lin on 04-28-2008 02:57 PM
0 Kudos
Message 16 of 23
(1,662 Views)
Based on the fact that you were using a waveform chart and a loop in your original VI, I'm assuming you are trying to continously monitor the sensor output. Since it is continuously putting out data onto the serial port you have to realize that the number of bytes on the serial port may vary. Also, when you do a read the first byte may not be the "high" byte, as you may be catching the stream at a "low" byte. This means that you need to keep track of where you are. You can do this many ways, and thinking out before trying to code it up is the best way to handle this.

Since this is a senior design project, you wouldn't learn anything if we gave you all the code. However, here's a couple of methods (both of which would use a shift register to carry around leftover partial readings) that you can think through and implement:
  • Method 1: Use the Bytes at Port function to find out how many bytes are actually on the serial port, and pass that value to the VISA Read. You then have to look at the output of VISA Read and determine whether you're starting with a "high" byte or "low" byte. Previous code has shown you how to convert the string to an array of bytes. All you need to do is to see if the first byte is a value that has the highest bit set to 1 or 0. If it's 0 it means it's a low byte, and you've caught the middle of a reading, so you can throw out the first byte, and then convert every 2 bytes thereafter to values. If the number of bytes after removing the first one is odd, then you know you've caught the "high" byte of a reading at the very end, so pass this single character around into the next loop so you can prepend it to the next chunk of data.
  • Method 2: Always read 3 bytes. A similar approach to the previous method except this will always yield either one number or two number, if there was a character carried over from the previous loop.
Tip:
  • Learn how to run your code in highlight mode so you can see what's being read.
Good luck! Smiley Happy
0 Kudos
Message 17 of 23
(1,637 Views)

zhi,

Since the instrument is sending a continuous stream of data, you will need a way to synchronize with the data stream.  That means you will need to differentiate between the HI an LO bytes.  That should be easy because the HI byte will always be greater than or equal to a hex 80.  The LO byte should always be less than a hex 80.

0 Kudos
Message 18 of 23
(1,636 Views)
hi, Smercurio and Centerbolt,
        For the byte at the serial, since I am modifying the advance seral port write and read,  so I can define the read buffer. Since the sensor has a fixed sample rate of 5 KHz, doe this sampe rate matter ?   As I have monitor, i see that the bytes at serial port depends on the number that i have put down for the buffer size. Also, I have no idea how i should seperate the hi and low bytes. Does our old method work? using index array and put down the 1 or 0 to distinguish the hi/low?  i have idea that using logic fuction, i will work on it. I  know i might asking some very  basic question, however, since i am in mechenical major, we have never learned this kind of stuff.

Also, i am not familared with the hex format, can anyone give a direction to learn it ?

thanks
zhi


Message Edited by zhao.lin on 04-28-2008 04:13 PM
0 Kudos
Message 19 of 23
(1,629 Views)
hi Smercurio, Centerbolt and everyone,
                         with the help of one of our professor in school, we come up with the following VI to get the proper reading. however, we are not sure if we are right or not. Can anyone of you check the logic?  In addition, we want to use statisical method on the data. The first thing is to group the numbers, such as grouping the first 100 numbers and take the average, I am wandering how can i do it in the labview.

Thanks
0 Kudos
Message 20 of 23
(1,599 Views)