ni.com is currently undergoing scheduled maintenance.
Some services may be unavailable at this time. Please contact us for help or try again later.
09-05-2008 05:09 PM
Hello,
I'm working on a project where I have to create a labview program that allows me to serially communicate with the motors of a telescope. I'm trying to implement a function into a program where users can click on a single button that will allow me to calibrate the position of my telescope motors. However, to accomplish this, at least 5 different serial strings need to be sent individually, one after the other to the motors. Currently, I have created a program that does this, but users have to manually click 6 different buttons in order to accomplish one task.
I've just redid part of my program where I utilize a flat sequence, where each frame has one of the strings that will need to be written to the motors. I've added about 5000ms of delay between each frame in order to ensure that the strings are written. I ran my program, but despite what I have, the strings are created but they're not actually sent to the motors. When i hit the run/play button (at the top of the labview program panel), only the string that is in the first frame gets completely sent over to the motors. All other strings, are created, but are not implemented and sent. As a result, even though i have the flat sequence where all the 6 command strings are included, the result is the same as only having written 1 command string in my program.
Does anyone know how to fix this? (To have a button that will carry out a function where 6 different command strings are sent individually, one after another, to the motors)? Any help would be appreciated!
Chelle.
09-05-2008 05:27 PM - edited 09-05-2008 05:28 PM
I've tried to attach what my VI looks like for what I have attempted.
09-05-2008 06:48 PM
That VI makes no sense. There is no VISA Write in there and all that you are doing is writing to the same local variable over and over again. Since it looks like you are just starting LabVIEW, a word or two of advice is in order. Avoid sequence structures. They are usually not necessar and certainly not in your case. Avoid local variables. They are usually not necessary and certainly not in your case.
I think what you should do is is look at the event structure. Have an event for the front panel Boolean. Format the different strings with the Format Into String function only when you need to (most of your strings are constants) and create a string array from the different strings. Wire the string array into a for loop that has a VISA Write inside it. With each iteration of the loop, one of the strings will be written.
09-06-2008 07:09 AM - edited 09-06-2008 07:12 AM
Below a simple example that shows how to repeatedly write a string out to a visa resource.
All elements of the string array are sent out each 300 ms.
You could of course make the constant an input control.
And be aware of the shift register in the error line to remeber the first error that occurs.
Hi
09-08-2008 06:23 PM
Hello,
I tried doing what you suggested by implementing a string array where individual strings are fed into VISA Write each time it passes through the loop. However, for each write that is done, there needs to be a read function that accompanies it. Right now, I'm having trouble connecting the entire VISA Write/Read together because it's saying that the data type isn't the same. VISA write is from an array, but VISA read isn't. I don't know how i can fix that since the VISA read function is supposed to read command strings that the motor sends back, so unlike the write function, i don't know how i can make it into an array type when i'm not feeding it a string array through a loop. I need both the VISA write and read functions for this project. Write so i can send commands to the telescope motors. Read so that the motors can send a response back telling me what position my motors are at. In fact, I need the read function to return a string every time that I send a command over in order to ensure that my message is sent successfully over. I'm attaching the VI file, with the exact errors, so hopefully the VI can better explain my problem. Any help appreciated as always... (and yes.. i'm pretty new to labview).
09-08-2008 09:54 PM - edited 09-08-2008 09:56 PM
If you need to do a read after every write, then that is what you would need to have in the for loop. Even if you fix the problem of the wires leaving the loop, you still only have a single read. You can do like the image below. This would require you to post process the array of responses after all has been done. The most straightforward way is to use individual write followed by a time delay, followed by a read, followed by another Write, followed by a time delay, followed by a read, etc. DO NOT use a sequence structure.
p.s. The problem with your attachment is that just like an input array is autoindexed to a scalar inside a for loop, a scalar leaving the for loop is autoindexed into an array. You can disable this by right clicking on the exit tunnel and selecting 'Disable Indexing'.