Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Control

Attached is a simple test VI to control a motor via serial port. The commands such as "p=1000\r\ss=10\r\sa=10\r\s^\r\r" are specific to the motor and they work.
 
In this test VI, I used Basic Serial Write and Read.vi to do the serial read/write.
 
The problem: When the test VI is run for the first time, the first command is executed and the motor moves. The second command is not executed.
 
When the test VI is run for the second time, the second command is executed and the motor moves again. The first command is ignored.
 
If we keep running the test VI, this sequence repeats.  I really like to have two commands executed within one run of the test VI.
 
Any help is deeply appreciated.  Thanks. JQS
0 Kudos
Message 1 of 5
(3,646 Views)
If you open up the basic serial read and write you see that they each initialise the port and then do some IO
The ebset you can do is to edit one of the basic serial write reads to internally have a for loop around the complete [write case,delay,read case] and add a n array of  strings to send and you will get an array to read.

I realised this is maybe more confusing so I added the example and use this as the vi you need.
greetings from the Netherlands
0 Kudos
Message 2 of 5
(3,624 Views)

Albert, I tried your VI. It does the same thing. I put two commands in the array. One only is executed at a time. Strange.

Thanks. JQS

0 Kudos
Message 3 of 5
(3,606 Views)
maybe a small delay is needed between two commands, or is the end character not recognized correctly?

greetings from the Netherlands
0 Kudos
Message 4 of 5
(3,601 Views)
Howdy JQS,

It sounds like your command string lacks proper termination. Try adding a \n character or \r\n at the end of each command you send to the instrument.
Warm regards,

pBerg
0 Kudos
Message 5 of 5
(3,587 Views)