Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Reading too fast?

Hi everyone!

 

I am using Arduino from 2 zigbee. Ive attached my program. 

When I highlight the execution I get a correct reading which is:

31.2

30.75

30.50

 

in both node A and B.

 

But when I turn off the highlight execution I get a reading like: 

3

30

31.

 

I dont know why it is like that. Im quite new to LabView and I based my program through research.

Oh and if you have any suggestion to improve my program please feel free to tell me. Especially on the part of if it is equal to A or B, I dont know other way for it.

 

 

If possible are there function like if else statement.

 

 

Thank You!!

0 Kudos
Message 1 of 11
(6,381 Views)

Hi,

 

There is no synchronisation between youre program and the device you read.

At moment x you look at the number of bytes received and read those bytes. How do you know your device is ready ? 

 

The easiest way is to use the termination character but it depends on what the other side sends. Or the answer must be of fixed length's than you can wait for a number of bytes to be ready.

 

btw. 'serial is never too fast' 

 

Kees

0 Kudos
Message 2 of 11
(6,357 Views)

Since you are using an Arduino, change that code to send an End Of Line character (0xA) at the end of each transmission.  Do NOT use the Bytes At Port.  The VISA Read will stop reading when it reads the given number of bytes, finds the termination character, or times out, whichever happens first.  So use the termination character.  Just tell the VISA Read to read a lot more bytes than you would expect (like 10).



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 3 of 11
(6,343 Views)

Hi. I tried to use the function End on Reads, nothing happens, I cant read any of my data.

The zigbee sends:

 

Serial.print(temp);

Serial.print('\n');

 

temp is the temperature data.

 

In synchronization for labviwe and the device. What are the methods to do this?

 

sorry new in labview 

0 Kudos
Message 4 of 11
(6,252 Views)

Hi,

 

To all, Best wishes for the new year.

 

 

You should enable the termination character. Now it is set to false. Set it to true. One of the input of the VI 'Configure serial port'

 

Kees

0 Kudos
Message 5 of 11
(6,232 Views)
Your arduino code should be using the println function which automatically appends a carriage return.
0 Kudos
Message 6 of 11
(6,230 Views)

Hi guys! thank you for your reply. 

I tried to use this:

http://digital.ni.com/public.nsf/allkb/6E2C88C43C76A77386256975006DB10A

 

the disable.vi for me to see what the read actually reads.

It reads:


øB33.

¦HøD

5
…D

 

 

I should expect to receive:

A33.25

B23.50

A33.50

 

stuff like that. I gives me othe characters.

 

 

BUT... When I ' highlight Execution' it gives me a value of:

A33.25

B23.50

A33.50

And sometimes a blank space. How is this?

0 Kudos
Message 7 of 11
(6,203 Views)

The linked VI still has a disabled termination character. You should enable the termination character by setting the constant to true.

0 Kudos
Message 8 of 11
(6,188 Views)

@shogunato3 wrote:

It reads:


øB33.

¦HøD

5
…D

 

 

I should expect to receive:

A33.25

B23.50

A33.50


1.  As has been repeatedly said, turn on the termination character.

2.  Are you constantly setting up the port?  That's what it looks like to me since you are getting "weird" characters (usually a symptom of having the wrong baud rate and/or the data frames being out of synch).  If you are using the Run Continuously button, stop that.  You should have a loop around your read section of code.  Also be sure to close the port after that loop.



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 9 of 11
(6,175 Views)

Maybe this will help. I changed your VI. Added a while loop. It far from good but I think this will give you a better result.

Try to learn from others.......

 

0 Kudos
Message 10 of 11
(6,171 Views)