04-24-2015 08:45 AM
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 .
04-24-2015 08:53 AM - edited 04-24-2015 08:54 AM
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…
04-24-2015 08:53 AM
04-24-2015 09:37 AM
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 .
04-24-2015 09:45 AM
04-27-2015 01:42 AM - edited 04-27-2015 01:44 AM
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 ?
04-27-2015 04:35 AM - edited 04-27-2015 04:39 AM
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 .