LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 USB-rs232 converters asynchronous readout

Good day,

I'm a beginner in programming with labview but I've made one relative small data-acquisition program that is fully functioning and working properly.
I've found out how to program in labview myself with loads of searching the internet and viewing examples so how I've programmed some things won't be the proper way but it works.

But now my problem:

I've made another data-acquisition program that has to read from 2 serial (RS232) ports, in this case I've used one com port from the PC and used one USB-RS232 converter and with the 2 devices attached in that way so one on the converter and the other device directly connected on a serial port, with that configuration the program works perfectly but now comes the catch: we want to run the program on a small laptop without any serial ports except USB ports so we have to use 2 USB-RS232 converters and then the problem starts.

If we connect the devices to the laptop with the two converters than I don't get any real data any more and the timing of the program is totally destroyed because normally the program updates every second and with the two converters it takes 10 seconds before it updates the data (I guess the time-out time of the VISA serial block) and this program has to update every second.


I've tried some things I could come up with like build the both communication loops for the devices in separate VIs etc..
I have also thought about using a USB-RS232 converter with multiple RS232 ports but I don't have one lying around for testing, but if can be solved with adjusting my program than that has the preference.


The devices that has to be written to and has to be read are:
- Advantech ADAM-4017
- Bronkhorst EL-Flow

the EL-Flow needs a baud rate of 38400 and the ADAM-4017 uses the normal 9600 baud, and both of them has to be read and write at the same time.

I hope I have described the problem good enough so you could give me some ideas/examples etc. How I could solve the problem.

 

Greeting from the Netherlands,

 

Jorick

 

 

0 Kudos
Message 1 of 5
(2,584 Views)

Hopefully you put each device in its own loop then the timing should be independent from each other, this simplifys the program in the long run.  As for the USB-RS232, the first thing to keep in mind is that the comport numbers have a nasty habit of changing over time, you should plan for this by allowing selection of the active ports on the beginning of the program (or at least loaded from a file). 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 5
(2,569 Views)

I've attached the 2 versions of the program, I think they can be made much smaller and more orderly but i don't really know how to now but now you can see how it's made.

Download All
0 Kudos
Message 3 of 5
(2,559 Views)

Dear Jorick,

 

please have a look at the state machine design pattern this will make your code much readable. Avoid writing values to indicators through property node (write the property value); It is best to bundle some parameters in a cluster.

With the state machine design pattern you will notice also the  shift register; this will write date from one iteration to the next; in this case we write the next state to the right shift register, next iteration we will read the state in the left shiftregister. We can use this principle to write data from one state to another as well (to minimize the use of variables).

 

Best regards,

Martijn S
Applications Engineer
NI Netherlands
0 Kudos
Message 4 of 5
(2,489 Views)

If the code works on the PC but not on the laptop AND you have the drives installed (NI-VISA) then I suspect an issue with the wiring.

 

On a PC the ground can be found through the chassis. Laptops generaly flaot relative to ground so you need a ground line.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 5
(2,487 Views)