From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA + Stepper Motor

Hi .

 

I'm trying to control a stepper motor with VISA . I have made one diagram to control it " works.png" and it works perfectly but this diagram sends ONE command for ONE execution .

 

Commands I need to send are ( with Carriage Return each time ) :

 

1) -\r : sets the sense of rotation .

 

2) S2000\r ( for exemple) : sets the position needed .

 

3) R\r : Moves to the relative previous position "S" .

 

I want to do these 3 commands in this order automatically .

I have already tried to put only one " VISA configuration " and one " VISA close" for the 3 commands but it doesn't work .

 

So I have made the diagram " Doesn't work.png" but I don't understand why it doesn't work like the first one. Do you have some ideas ?

 

Thank you .

 

 

 

 

Download All
0 Kudos
Message 1 of 7
(3,898 Views)

Hi bejard,

 

two important notes:

DON'T open and close the VISA port for each single command. You only need to open it once on start of your program and close it once in the end.

DON'T close the port immediatly after writing a string to the VISA write buffer. Closing the port may also clear the buffer before your command is even sent…

 

More notes:

- Use error wires. Use them in all the places. You will not need the sequence structure anymore…

- Read about loops and state machines. They come in handy for such tools like yours…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,875 Views)
You can put the VISA Write inside of a for loop and pass in an array of commands. Do the configure serial port and close outside of the loop where the error and resource name are passed in with shift registers. Make sure that your string control is set for \ Codes Display.
0 Kudos
Message 3 of 7
(3,872 Views)

So I made this diagram "for loop.png"  but I can not test it today . What do you think ?

 

But what I don't understand is that in the first diagram which works, the commands are sent correctly ( the commands "R\r needs the commands "S2000\r" ) whereas the port is closed after each execution . So it means that the S command is saved somewhere .

0 Kudos
Message 4 of 7
(3,854 Views)
Don't wire anything to the n terminal when you pass in an array. Your array constant has the S command saved so I don't understand your question. And as I mentioned, make sure the string constant is set correctly for \ codes. You should set the display properties to show this for better readability.
0 Kudos
Message 5 of 7
(3,845 Views)

I have tested and it doesn't work..

 

My question was , in the case of the diagram " Works.png" , I do this: 

 

1st run : open port - send -\r close port 

2nd run : open port - send S2000\r close port 

3rd run : open port - send R\r close port 

 

And this program works even if the port is closed each time for each run , so I don't understand .

 

The tests don't work each time I send the command "S2000\r" so I guess the issue come from here in the for loop . Should I put delay maybe ? 

0 Kudos
Message 6 of 7
(3,796 Views)

And the fact is , each time i'm trying to send a string this way, the motor doesn't respond anymore. So there is a problem about sending strings (S2000\r or V2500\r )  with " Doesn't work.png" ( or with "for loop.png" ) but NO PROBLEMS with " Works.png" using the way I described just above .

0 Kudos
Message 7 of 7
(3,757 Views)