09-13-2011 12:29 PM
I am relatively new to LabVIEW and I am trying to set up a program using two different RS-232 connections. I have one working correctly (peristaltic pump control), but one is not cooperating (balance measurements). When I run the program, I get a framing error, and when the serial connection is probed, it says it was not executed.
Are there any suggestions as to how to initialize communication?
09-13-2011 01:19 PM
Did you try a search on framing errors? This is a frequently asked question. Framing errors are generated by the serial port chip in your computer (or whatever external box you're using). These are cause by numerous sources:
You will need to rule these out one at a time.
09-14-2011 10:07 AM
Hello msteele,
Thanks for the question! Can you provide us with more information on the program you're using as well as the error you're seeing?
Additionally, try to use the Basic Serial Write and Read example VI with the "non-cooperating" machine. You can find this example through Help >> Find Examples. Then search for serial, and this should be one of the options that come up.
Cheers,
Lisa
09-14-2011 10:07 AM
Hello msteele,
Thanks for the question! Can you provide us with more information on the program you're using as well as the error you're seeing?
Additionally, try to use the Basic Serial Write and Read example VI with the "non-cooperating" machine. You can find this example through Help >> Find Examples. Then search for serial, and this should be one of the options that come up.
Cheers,
Lisa
09-19-2011 10:24 AM
Thanks for the responses.
@smercurio_fc: I had previously searched framing errors, and I don't believe the causes you've listed are the problem I am having. I am able to communicate fine with the instruments through VISA, and even when the program is running, but I am still getting a framing error. From my search, I thought the issue may be a result of not closing the serial ports. I have modified my program (and attached it for reference) to close the serial ports, but I don't think the way I have done it is correct. Should I put the Close command in a new sequence? Or should I change the while loops to have a control rather than a constant 'false'? Would a case loop be more appropriate?
@Lisa J: Again, I have attached my program for reference. There are some notes about the function of each command in various "Description and Tips" boxes. Also, I actually used the Basic Serial Write and Read example VI to setup the program and it was very helpful, but I still get framing errors.
It may also be helpful to know that I don't get the framing error every time I run the program. Generally the first time I run the program when I log on to the computer I don't get the error, which seems to verify that it may be an issue with properly closing the serial ports.
Thanks again,
M. Steele
09-20-2011 08:13 AM
Not closing a serial port does not generate framing errors. Framing errors are generated by the serial port hardware. They tell you that the byte stream received does not conform to an expected byte stream.
As for your code, you have several issue:
09-20-2011 09:51 AM
and within these infinite loops you use COM3 in two loops in parallel.
09-22-2011 01:23 PM
Thanks for your response.
I am working to correct my program but still having issues. I moved the serial configurations outside of the sequence structure, and tried to combine some of the parallel loops in frame two, but now I am not able to control my instruments as before. Should I have moved serial configuration outside the while loop, but inside the sequence structure?
I think a description of what I am trying to achieve may help you help me. I have three outside devices: (1) a pressure transducer connected through an NI USB-6009 using an analog connection (ai1), (2) a peristaltic pump connected to COM3, and (3) a balance connected through COM4.
I will devide the issues I'm having between instruments:
(1) The pressure transducer is working as I would hope. I would, however, like to write the pressure data to my array file. I am not sure how to convert it to the correct data type.
(2) There are three operations I need to communicate with the pump. In the first frame, I have written and write and read sequence to "identify" the pump (ie. I send it Z1, if it returns Z2, then it has been assigned pump identifier P1). This is executing as needed. In the second frame, I am trying to be able to both set the speed of the pump and be able to turn on and off the pump. That is why I had two parallel while loops using COM3 before. When I tried to combine them into one while loop as suggested, I cannot make both functions operable.
(3) With the balance I want to collect the mass accumulated per time step (3s). I am also hoping to be able to start running the program and control the pump, but tell the program when to start collecting balance data.
I am attaching my program with modifications made, but it does not run as well as the previous version. Any suggestions would be highly appreciated.
Thanks again,
-M. Steele
09-22-2011 04:20 PM
Have a look at the produce consumer template.
And do put the 3 instruments in parallel loops that produce and consume the data in another loop.
Do not use the same instrument (or port) in more than one loop because you don't know what you are sending from two sides.
Furthermore hide the nitty gritty details of communicating with an instrument in a subvi.