LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Take variable quantity data from serial port using 8051

The device sends data continuously without you needed to send a command to it?

 

How often is the data sent?  It sounds like it is more frequently than 12 seconds.  Put a zero msec wait is definitely wrong because the loop will run nearly infinitely fast.  Certainly much faster than the device is sending data.

 

Does your device send the same number of bytes in each packet of data?

Does your device send the data ending with a termination character?

 

If either of these two things are true, then you can either request the specific number of bytes, or request a sufficiently large number of bytes with the termination character enabled.

 

Even though the LabVIEW serial example likes to use the bytes at port property to read data, I don't think I've found a case yet where working with a real world device that it is the proper method to use.

Message 11 of 26
(2,070 Views)

you string format looks like this one

 

Capture.JPG 

 

with max value of the decimal be 255 ie three bytes. 

give the read function. count of the bytes & remove property node and delay. 

I dont know if this works or not lets give it a try.

 

Include delay Capture.JPG 

if micro controller send these strings with a definite delay. 

it will be better if microcontroller programmed so that there is some delay between each data sample string transmission. 

 

Regaurds

A.chaitanya 

Message 12 of 26
(2,066 Views)

If Ravens conditions are true for you then I have this VI for you that justifies both condions. I am reading 1 byte at a time and termination character is A. The case struture part is for writing on the port on different conditions to take action accordingly. I am still in the process of completing it. Hope it helps.

 

I also want all of you to tell me that how I can make my block diagram more professional. Any mistakes in it so far or any advice. Thanks.

Message Edited by Naqqash_IIEE on 10-25-2009 06:54 AM
Naqqash
Message 13 of 26
(2,047 Views)

Here are some basic tips for your VI.

 

  1. Replace the stacked sequence with a flat sequence.  You my even find that you can eliminate the sequence structure entirely with proper wiring of the VISA functions.  Don't split the purple wire.  Use the output wire on each function to be the input wire on the next.  And wire up the Error wires.
  2. With your subVI, put inputs to the subVI on the left hand side of the connector panel, outputs from the subVI on the right hand side of the connector panel.
  3. Avoid having wires run backwards.  Move your waveform chart terminal to the right of the subVI, then the wire won't have to run up, backwards left, up, then right.
  4. On your typecast functions, you don't need to put a Convert to U8 in line between the constant and the top of the typecast function.  The constant is already defined as a U8.
  5. On your temperature, water tank, and Setpoint water tank controls and indicators, set their representation to U8 to match the datatype going into them so you can eliminate those coercion dots.
  6. With all your case structures at the right hand side, you might have a race condition as to which executes first if more than one of those conditions turns out to be true.  Will this matter for your serial device?
  7. Put a label on the terminal that feeds into the loop's stop terminal so that we know which terminal it is.  If you don't want that button to have a label on the front panel, that's fine, you can hide the label on the front panel.  Put every terminal for every control and indicator should have its label shown on the block diagram.
  8. Wire up all your error wires.
Message 14 of 26
(2,035 Views)
Thank you very much Raven for your help. Is this proper that I include the respective right visa block also in the frame for respective channel.
Message Edited by Naqqash_IIEE on 10-26-2009 04:56 AM
Naqqash
Message 15 of 26
(2,026 Views)
You're welcome. I don't think there is any problem having the VISA Write in each case structure.  If it was me, I would probably just have one Write after them all, and just use the case structure to output the particular command and concatenate the results from all the case structures (that way you can control the order), then place the result of that concatenation into a single VISA write.  For any case that is false, it outputs an empty string, for true, it outputs the command letter.
Message 16 of 26
(2,015 Views)
sorry i am not exactly getting the point. Can you post a screen shot for that write part. I'll be thankful.
Naqqash
Message 17 of 26
(2,009 Views)
I decided to use the Select Statement instead of case structures.
Message 18 of 26
(2,007 Views)
Bill, I have tried to edit my VI according to your advice. Kindly check this and please help me with this creating file part in the VI whenever I run the VI no data stored in the file. What might be the problem. Hope not bothering. I'll also appreciate advice from others also. Thanks Bill for being such helpful Smiley Happy
Message Edited by Naqqash_IIEE on 10-26-2009 03:27 PM
Naqqash
Message 19 of 26
(1,996 Views)

Here is a little bit more of a clean so that the sequence structure can be removed.

 

Wire up the error wires for the file functions.  Put a probe or indicator on them to see if you are getting any errors.

 

I suspect that it may have something to do with opening the file with the "create" option.  Also you don't have a file path wired up to it.  So what will happen is that it will pop up a dialog box every iteration asking your for a file name.  And if that file exists (which it will every time after the first iteration), it will then ask if you want to replace it.  And if you say yes, it will then overwrite the data with the new data.

 

I would use a file path constant or control.  Use the Create or Open option.  And if you want to have a file where the data continually appends to the end, the use the Set File position and set it to the end after every open.

 

Now what you may want to do since this loop may run fairly quickly, all based on how fast the device sends data, you may want to open the file before the loop, and close it after the loop.

 

And to get the file part working to your satisfaction, particularly since there is a lot of string formatting going on, break out the file writing part to a separate VI without the serial stuff.  Put it in a loop with a wait statement, and turn the data coming from the serial part into controls you modify.  Now you can debug and get the file working right.  Once you have that, then add it back into the serial part.

Message 20 of 26
(1,990 Views)