03-07-2011 07:08 AM
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
03-07-2011 08:47 AM
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).
03-07-2011 10:10 AM
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.
04-06-2011 08:52 AM
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,
04-06-2011 09:03 AM
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