From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication works in Debug / highlight Execution mode but not in standard execution

If it works with a break point then im going to agree with the rest of the group here and say it deffinatly sounds like a timing issue. If you put the break point before or after the write should tell you if you need to wait longer before or after the write but im going to say theres a timing issue before the write. Did you try doing a VISA clear before the VISA write? that usually solves problems for me.

0 Kudos
Message 11 of 24
(2,829 Views)

Hello There!

Alright, here´s my code, have a look, I´m looking forward to see what I´ve done wrong.

 

My Communication Partner is a Adept one SCARA Robot, when I communicate with him with Hyperterm from the same machine where LabView is located, everythings alright....

Regards

 

Sebastian

0 Kudos
Message 12 of 24
(2,827 Views)

In your serial read subvi, you don't need the flush buffer vi.  When you call serial write, the contents of the buffer get written, no need to flush.  You have a timer to wait for receive handshake.  Instead of this timer, use Bytes at Serial Port function in a loop.  Set the loop exit when the function returns the number of bytes you expect (like greater than or equal to 1).  Then call the read function.  Use the Bytes at Serial Port function everytime before a serial read.  This could be why it works in debug mode and not at regular speed.

Also, you could use a lesson in Labview style.  Use the Error In and Error out to dictate the execution flow.  Don't use several error outs, as you have, just wire error out of one function into error in of the next.  This ensure the proper execution order.  You can put a probe at certain spots when debugging.  You could also compact the block diagram for the benefit of those who are viewing on a single monitor.  I have a dual monitor system and it took the entire two screens to show some of your code.  Bring things closer together, straighten up the wiring for easier view.  Good habits like this will make it easier on you to maintain in the future.

- tbob

Inventor of the WORM Global
Message 13 of 24
(2,821 Views)

This is what a simple serial write-read should look like:

Message Edited by tbob on 04-26-2006 11:03 AM

- tbob

Inventor of the WORM Global
Message 14 of 24
(2,822 Views)

Thanks for reply!

 

My problem is that I got no problem with recieving the data, the data I send does not arrives at the other serial partner (with exeption in debug mode).

0 Kudos
Message 15 of 24
(2,806 Views)

Hi Seppfish,

Try to place a 'VISA set I/O buffer size" function before your write serial port function.

That's how I got my USB <-> serial ports working with the current VISA version.

 

 

0 Kudos
Message 16 of 24
(2,801 Views)

Hello!

I tried to set the buffer size for reading and writing, there´s no string send to the serial port....

That doesn´t solve the problem....

Could there be hardware problems ? I/O problems if the Visa driver is used? If I programm a loop where I write the Data to the port (in the loop there´s written permanently the string until there´s written something back) then it works also (without the highlight exec), but my buffer of the robot (the other serial partner) is overflowed...

More suggestions are welcome!

Regards

 

cand. Ing. Sebastian Neumeyer

0 Kudos
Message 17 of 24
(2,790 Views)
Hi Sepp, if you still didn't have a workaround on tbob's advice, I think you won't get it work. In the VI "recieve from Adept.vi" (which fits only on two monitors) there is to be seen, that you write something to your serial port ("menue\r\n", which is 7 chars and takes something like 7ms to transmit at 9600 bd).
Right after this you flush the transmit-buffer and this funktion is called earlier than 7ms. Besides the flushing you call the "wait"- function, but this appears parallel to the flushing. And again there is tbob very right, you don't need the "flush buffer", because after transmission the buffer is flushed! (see first attached picture)
And the second part of your sub-VI (on the right monitor Smiley Very Happy , this is the second attached picture) there is no flow- control at all. If you run this VI in debug- mode, labview tries to flow from left to right. But in your code, the data is actually coming out of the "VISA read" going to "send break" (the left and the one on the very right side ), "convert string to number" and "VISA flush buffer" at the same time!
And they all execute at the same time. So the "send break" sends a break for 250ms, in this time the received string is converted and put together again to another string (this takes micro-seconds) and then sent into a break- sending and flushing serial port. This only works, if you have loads of time between execution of every single function & sub-VI.
I made a little VI, which listens on a serial Port and sends back a String. If you connect two serial ports with a Nullmodem- cable (works on the same computer), you can see, that if you run your program at full speed, the transmitted strings are crippled, because of the "flush buffer" before complete sending.
To get an ordered flow into your program, you should read the post of tbob again and maybe have a look at the "sequence structure". A very good thing in waiting for something is the "time delay" Express-VI, because there are error-connectors for ordered execution.
I hope this helped,
Dave
Greets, Dave
Message 18 of 24
(2,778 Views)
What I forgot to post in the last message: how can I include pictures into the message without having a web-server to put my picture to?
Dave
Greets, Dave
0 Kudos
Message 19 of 24
(2,774 Views)
You need a web server, however you can use NI's server.  After you attach your picture file (PNG) and submit the post, and it shows up, click on the Options drop down menu and select edit message.  Then you can click on the attached picture, copy the URL of the picture, click the back button on your browser, place the cursor in the text body where you want to put the picture, click the Insert an Image icon (yellow box with mountains), and paste the copied URL there.  When you hit Enter, your picture will appear with your text message.  Whew... lots of steps.  You only have a few minutes to edit your message.
- tbob

Inventor of the WORM Global
0 Kudos
Message 20 of 24
(2,771 Views)