LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Decimal Point position from right to left Serial Read Evaluate Number within Range over RS-232

 

Try hitting Ctrl-B which cleans up loose wires.  Sometimes when deleting or rewiring, you might leave a stray wire fragment.  That will give you an error until you clean it up.

0 Kudos
Message 11 of 23
(1,492 Views)

During testing I am finding out that the VISA Configure Serial Port is reading input data randomly. The termination character is not even being considered resulting in the -1073807252 error. How can I control the reading of data to just capture the 16 digit data stream at each read?

 

Thank you.

0 Kudos
Message 12 of 23
(1,469 Views)

Error -1073807252  is an overrun error.  I've never actually seen one of those in serial communication before.  How large is the buffer set for your serial port?  Most serial ports are large enough, and a PC fast enough, that it can keep up pulling data from the serial port before it gets overrun.

 

Your termination character is enabled and set to be the linefeed character (decimal 10, hex 0A).  Is that the last character your device sends in the package of data?  What character or byte is the D0 in your message?

 

If it is a line feed character, you would be running just fine.  Perhaps it is a carriage return?  Is it something else?  In which case you need to change the constant at the serial configure VI from x0A to something else.

 

Can you post your VI with some actual data you've collected saved as default in an indicator?

0 Kudos
Message 13 of 23
(1,464 Views)

@gprall001 wrote:

During testing I am finding out that the VISA Configure Serial Port is reading input data randomly. The termination character is not even being considered resulting in the -1073807252 error. How can I control the reading of data to just capture the 16 digit data stream at each read?

 

Thank you.


Please reread my post from earlier.  In there I told you that the File IO is slow and is causing the buffer overflow error.  You need to set up a Producer/Consumer.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 23
(1,457 Views)

The 16 digit data stream is as follows:


D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0


Each digit indicate the following status :
D0 End Word

D1 & D8 Display reading, D1 = LSD, D8 = MSD
For example :
If the display reading
is 1234, then D8 to D1 is :00001234


D9 Decimal Point(DP), position from right to the left
0 = No DP, 1= 1 DP, 2 = 2 DP, 3 = 3 DP

D10 Polarity
0 = Positive 1 = Negative

D11 & D12 Annunciator for Display
Kg cm = 81 LB inch = 82 N cm = 83

D13 1

D14 4

D15 Start Word

 

I have attached the vi, data log as well as the output to the file data.

 

I am also looking into the suggestion of Producer/Consumer and how to integrate into the vi.

 

Thank you.

Download All
0 Kudos
Message 15 of 23
(1,450 Views)

Nothing is saved as default in your read string.  You need to run your VI then stop it.  Then right click on that indicator and then Data Operations >> Make Current Value Default.  Then save the VI and attach it.

 

The other text files, I don't know what they are supposed to be showing.  The one doesn't look anything like the data you are talking about.    It has a weird combination of human readable strings, and also some binary-type ASCII characters.  There are also a whole lot of question marks, hex 3F throughout it.

 

All very strange.

0 Kudos
Message 16 of 23
(1,440 Views)

I am sorry I did not attach the file you needed. Hopefully this file is what you are looking for.

0 Kudos
Message 17 of 23
(1,435 Views)

That looks better.  But I want to see the actual VI with the data in it.  That way I can inspect all the bytes, including those that relate to non-printing characters.

0 Kudos
Message 18 of 23
(1,427 Views)

The data I sent earlier is the only data the vi displays some of the time. I get the -1073807252 error so no data is displayed. I did rewrite the vi using the producer consumer structure as was suggested twice in this discussion. I still get the same error with no data being written to the display. I have attached that vi. Thanks for any help.

0 Kudos
Message 19 of 23
(1,398 Views)

You have a carriage return in there which can be seen as \r when the indicator is in \codes display.  As a result, the termination character of x0A is not going to work because you aren't getting a line feed character.

 

In the Serial configure, change the x0A constant to x0D which is the code for a carriage return (ASCII decimal 13, hex 0D).

 

 

Beyond that, you have numerous problems with your code.  I'll list them in no particular order:

1.  Your event structure has a value wired to the timeout terminal, but no timeout event.  Thus you have a broken run arrow.

 

2.  You are only reading based on the "Read String" value change event.  Value change events occur whenever a user writes a value to a control, or a value is sent to the Value(Signalling) property node.  You don't have the latter, and you have an indicator which means the user can't interact with it to change a value.  That event case makes no sense why you wrote it that way.  That code should probably be in the timeout event case (which is missing) and Read String  Value change event removed since it can never run.

 

3. If you don't read your serial port often enough,  (and in your code I don't see any way for VISA read to ever run), then your buffer will overflow and you'll get the --1073807252 error.

 

4.  You have a shift register on your error wire.  Most functions will not execute at all when there is an error.  When you get an error in one loop iteration and you pass it to the next without handling it or clearing it, you'll start with an error in the next iteration, and code won't run.  One stray error will then cause the code to never run properly again until you stop and restart your VI.  NEVER PUT SHIFT REGISTERS ON ERROR WIRES.  I've seen tutorials to say to do it.   I've seen tutorials to say to do it.  Some people may say you should.  I have yet to see any actual piece of code by those people where You can use a shift register on an error wire as long as in the next iteration you do something to handle the error and clear it.    I have yet to see any actual piece of code by those people where they do that correctly.  To me, it's a bad idea to tell new users to put a shift register on an error wire because I guarantee they won't implement properly.

 

5.  Not that this event case ever runs (see #2 above) but your case structure in that is wrong.  You are picking out the first character in the string and see if it is a "\r" which it will never be because a single character of any type can never match a 2 character string.  That "lr" is a literal forward slash followed by "r".  Perhaps you think it is the \r character (backslash, not forward slash) which shows up in \codes display.  That is a symbol for the single character carriage return, which you are actually getting in your string as a termination character, not the first character in the string.

 

6.  Bytes at Port method is the wrong way to read from a serial port (despite the fact it is prominent in NI examples) pretty much 99% of the time.  Once you fix everything else including the termination character, you should wire a constant there that is equal to or larger than the longest message you expect to see.  In your case, you know you are looking for 16 bytes, so wire that.  You can even wire a larger number since the VISA Read will terminate automatically and return the data once it gets the termination characte of a carriage return.

 

7.  Your VISA read should be in its own loop continually reading packets of data.  Tying this to an event structure and user interation seems like a bad idea and would certainly lead to buffer overrun error if you didn't read the port frequently enough to keep up with the incoming data.

 

Now I wonder.  Did you write this code or someone else?  It visually looks pretty good.  It seems to even try to follow some typical VI architectures.  But beyond that, the architecture is completely distorted and basically non-functional.  Why did you not post this earlier?  This doesn't match the VI's you posted earlier.  Your earlier code showed the x0A termination character (which I can now tell you for sure is wrong), while this code uses the x0D, which is correct.  Your earlier code has no possibility that I can see of giving the buffer overflow error (even with the bad termination character).  Timeout error, possibly.  Overflow, no way.  This code, I can see how the overflow error could occur, except for the fact I don't see how the VISA read could ever possibly execute to throw the error.

 

Go back to your earlier simpler code.  Change the term char to x0D.  Run that.  If you need to add the event structure and producer/consumer loop like you did in the later code, wait until you understand how they work and how dataflow works in a VI before you start to piece that code in.

 

 

 

 

 

0 Kudos
Message 20 of 23
(1,389 Views)