LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Serial Misery....

Solved!
Go to solution

Hi Guys,

             i am working on a small project, some electronics controls temperature, some pumps and current consumption, i'm using rs232 and trying to control it from labview.

 

When i use teraterm to communicate everything is fine, i just cant seem to get labview to work properly with serial, it keeps freezing and now refuses to connect at all giving me error - 1073807360 (VISA unknown system error) nice usefull error explaination there.

 

I want to recieve dome data that is being sent every 100ms or so, and display it on the screen, and also transmit setpoints to the hardware when front pannel controls are changed.

 

I tried having the recieve run all the time which worked but my data kept getting out of sync so i couldnt index it to extract the usefull data, so i changed the code and hardware so that the device only sends data to me when it recieves "W" but now my labview wont connect.

 

 I have attached the code, i send "hxxxE" so set a temperature, i send "lxxxE" to set a curent, i send "A" to turn on pumps and peltier and "a" to turn off,

 

and at the moment i have to send "W" to request the data from the hardware (allthough i can get rid of this and have the hardwaresend all the time if its easier)

 

The data comes from the hardware like: "Val1:xxxVal2:xxxVal3:xxx"

 

I would apriciate any help.... .Thanks

0 Kudos
Message 1 of 36
(4,197 Views)

Most devices need a Termination Character - you're not using one. This is usually why some other terminal program works, but LabVIEW doesn't.

 

You are always reading exactly 27 bytes. If there isn't 27 bytes, it'll wait and appear to hang. Count the bytes in a loop, using the Bytes At Port property node, then feed the byte count input to the Read. (Bail out of the loop when bytes stops changing (all bytes received)).

 

Those are the obvious things I see for now.

Message Edited by Broken Arrow on 03-19-2010 08:31 AM
Richard






0 Kudos
Message 2 of 36
(4,177 Views)

First, this code is much better than your previous code. Secondly, please, please stop using all of the sequences structures. You have a ton of them in your code and there is only one that really needs to be there. Every other use of one has a data dependency and is not required. Taketime to learn data flow programming and embrace it. It can be quite useful.

 

As for the problem that you are having one thing I noticed is that you are not checking for errors in your writes. The FOR loops will stop on an error but you will continue with following steps if an error has occured. You should always pass the error data through if you don't process it immediately using some type of error handler. I would suggest that you use NI Spy to see what is happening on the serial port. This will help to isolate where the problem is.

 

Also, remember that when you do this using TeraTerm things are running MUCH slower than your program. You still may have a timing issue.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 36
(4,145 Views)

Thanks for the info,

                              i don't know which sequences i can get rid of and which i can't. In my mind i need to makesure it sends WE, then waits then recieves in that order so i used a sequence.  If i just stuck them in the diagram left to right would it still exicute in that order ?

 

 

I like the sound of clocking the data into a loop untill i get to the number of bytes at port, but i'm not sure how to implement that graphicaly.

 

I guess i need to increment the byte count on the recieve untill it = bytes at port, but the data from recieve would have to be recombined into a string ?

0 Kudos
Message 4 of 36
(4,111 Views)
You can eliminate every sequence structure except the one that has teh Wait VI in the middle frame. Every other sequence frame you have is unnecessary since you have data dependencies (wires) between the the VIs. If you wanted to read a single byte with a delay between each read you can put a read in a loop and read a character at a time until you reach your desired byte count. Use a string concatenate to create a single string. Although you don't need to do this since the PC will buffer the read data for and do basically what I described for you.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 36
(4,105 Views)

Zac_Acal wrote:

I like the sound of clocking the data into a loop untill i get to the number of bytes at port, but i'm not sure how to implement that graphicaly.


Here's a method

 

Richard






0 Kudos
Message 6 of 36
(4,098 Views)

Broken Arrow,

 

Will that work? If the first check of the number of bytes is 0, that will be passed through the shift register. If the instrument still has not responded with the second read, the loop will terminate.

 

What I often do is just loop until the byte count is greater than 0. Then have a second loop with the Bytes at Port and the VISA Read and loop until the byte count is equal to 0. In the first loop I will also have a timeout so that an error is generated if the byte count is never more than 0.

0 Kudos
Message 7 of 36
(4,084 Views)

Thanks for that,

                          i've just tried to implement it but running ni spy tells me that nothing is happening untill i change a button or setpoint then it sends the new data to the hardware and then sends "WE" and recieves 0 back.

 

I think the event structure seems to be holding up the program, it does nothing until an event hapens.  I might remove it and give it another go

0 Kudos
Message 8 of 36
(4,081 Views)
That is exactly what your code is doing. You have a data dependency (a wire) from your event structure to the code that follows. The following code cannot execute until all of its inputs are satisified. One of these inputs is the wire coming from the event structure. That wire will not get its value until an event has been processed. I have said it before and will say it again, take some time to learn what data flow programming is and how to use it.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 36
(4,079 Views)

I can't see an output wire from my event structure.

 

the visa name and error wires are T'd off into the event structure but still go to the read part of the code irespective of the event structure (don't they?)

 

Yes i do need to learn more about data flow, and i'de like to attend the labview courses etc.... but right at this moment, sat in the lab at a quarter to six on a friday night i just wan't to get this bl**dy thing working....

 

Thanks

0 Kudos
Message 10 of 36
(4,073 Views)