06-16-2016 07:28 AM
Good Afternoon
I am currently writing the program to communicate with the controler which is connected to a mclennan stepper motor using RS232. I am absolutely new to labview but i was able to write a simple program that would send controller commands, implement them and get a response from the controller. I'm not sure if it's possible but i would like the program to be running continously with the user being able to constantly write commands one after another and get response for each individual command and keep them in the 'read buffer' ; at the moment due to my poor understanding of loops i can only send 1 command given number of times using 'for' loop or send 1 command infinate number of times using while loop. My vision of perfect program would be : 1. type a command, hit enter and get a response 2. for the next loop iteration with the program still running i want to enter a different command and get a response while keeping all previous responses in the read buffer.
Sorry for the long post i hope this makes sense and i apologise if i'm asking for impossible.
06-16-2016 07:34 AM
Take a look at the "Continuous Serial Write and Read" example
06-16-2016 07:36 AM
Thank you for your response, i was initially going to use it as a template but it was producing errors so i decided to write my own simplified version
06-16-2016 07:41 AM
What errors where you getting?
06-16-2016 07:47 AM
if i remember correctly nothing was happening and the error was something like 'timeout expired before operation can be completed'
06-16-2016 07:59 AM
Search for that error in the forums and you'll see everyone has had a problem with it. There are several things to look at:
1. Do you have the right communication cable?
2. Are the communication settings such as baud rate, data bits, parity, .... correct?
3. Do you need to send the commands in a format with a termination character such as a carriage return or linefeed?
4. Do you get responses back from the device with a termination character or linefeed?
5. Do you have any vendor supplied software you can try first to see if you can get that working?
06-16-2016 08:02 AM
That sounds like either an improperly configured serial port or you were not using a termination character and requested too many bytes to read
06-16-2016 08:07 AM
Thank you for your response, as specified in my first post i managed to write my own 'simple' vi which i also attached and it was working perfectly for 1 command at a time so all the settings and cables are valid and yes it needs carriage return which i also implemented in the 'continuous write and read vi' example but i'm looking into it now.
06-16-2016 08:30 AM
You can create an array of commands. Auto-index them through a For Loop. You should Write and Read in each iteration of the For Loop. I wouldn't bang out mutliple commands in a row and try to read multiple responses in a row. You don't know if your device can handle that. Often a device can be overwhelmed by incoming responses and will stop responding.