LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous RS232 serial write/read for stepper motor

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.

 

0 Kudos
Message 1 of 9
(3,266 Views)

Take a look at the "Continuous Serial Write and Read" example

0 Kudos
Message 2 of 9
(3,263 Views)

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

0 Kudos
Message 3 of 9
(3,260 Views)

What errors where you getting?

0 Kudos
Message 4 of 9
(3,256 Views)

if i remember correctly nothing was happening and the error was something like 'timeout expired before operation can be completed'

0 Kudos
Message 5 of 9
(3,252 Views)

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?

0 Kudos
Message 6 of 9
(3,240 Views)

That sounds like either an improperly configured serial port or you were not using a termination character and requested too many bytes to read

0 Kudos
Message 7 of 9
(3,239 Views)

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.

0 Kudos
Message 8 of 9
(3,236 Views)

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.

0 Kudos
Message 9 of 9
(3,228 Views)