LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I have this VI restart when it is done with the first run?

I have made a VI that works correctly.  The problem is I want it to repeat until the entire spreadsheet has been read and written.

 

A little background:  I will be having labview outputting a signal to 4 motors, which will perform the motion prescribed to each.  Only two are hooked up right now, so in the text document /1 refers to motor 1, and /3 refers to motor 3.  /_R tells the motors to execute both commands simultaneously.

 

When I tried to loop this, I was unable to have the VI wait until each motion was complete before sending the next command. Currently it works if I sit at the computer and press run once the motions are finished, but the goal is complete automation and this can't be that difficult.  I have attached the motor commands and the VI.

 

Please someone help me!

Download All
0 Kudos
Message 1 of 11
(3,841 Views)

Team23,

 

Can your motor controller send a confirmation message after a command is finished executing?  If so you could write the command and then wait for the reply before sending the next command.

0 Kudos
Message 2 of 11
(3,821 Views)

Some options that I can think of:

 

1. You will need to find out if the device outputs anything when the motion is completed so you can read that and only then start the next iteration of the loop or maybe there is some sort of register on the device that you can poll.

2. How long does each motion take? Maybe you can use some sort of timing to start the next motion.

 

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 3 of 11
(3,818 Views)

When you place something on the serial port for something else to read, it is difficult to determine if it had read anything at all unless there is a response.  The motor may be sending an "OK" or even better "ALL DONE" message back to you after each command.  I would try using a terminal program (like hyper-term or...better) and communicate with the motors and observe what their output is back to you.  Serial port stuff can be tricky and take a lot of tinkering.  Using a terminal program helps troubleshooting tremendously.

 

Other than that...you may need to figure out what a resonable amount of time is for each operation and then add a column in your spreadsheet for that.  So when that command is passed to the motor, your input for "wait ms" VI comes from your spreadsheet.

 

As for restarting after done with the first run, do you want to re-initialize your serial port or something like that?  There is the "First Call" function that is true on the first iteration of a loop since program execution and false thereafter.
0 Kudos
Message 4 of 11
(3,812 Views)

Thank you both for the replies.

 

Wayne - the motors can send a confirmation message (I believe).  the problem is that any messages I have received from the motors are a bunch of jibberish that make no sense, so programming the VI to respond to these is difficult.  Is there a way to have the VI run once it receives a message, regardless of what the message is?

 

Adnan - The motors will be set into a massage chair, so each motion will probably have different timing.  I have actually set up the VI to run through once, wait 30 seconds, then run again.  This setup works but is somewhat primitive for my goals.

0 Kudos
Message 5 of 11
(3,810 Views)

Team23,

 

Can you post link to communications manual for motor control?  All jiberish is after all just a bunch of 1's and 0's

 

One reason to read the reply from the controller is to make sure the controller is not trying to send you an error message.

Message Edited by Wayne.C on 04-01-2009 11:39 AM
0 Kudos
Message 6 of 11
(3,799 Views)

I doubt the instrument is sending you 'jibberish' Smiley Wink

Since you cant read it, I'm assuming it isnt ASCII.

It could be Binary or Hexadecimal. Try reading in the raw data and test converting it to different formats unitl you see one that makes sense.

They probably have the instrument send messages for a reason.

Cory K
Message 7 of 11
(3,770 Views)

The control board sends back a series of letters and numbers and symbols.  If I send a simple command like /1?T (asking the control board the current motor position), the output is this (copied and pasted directly from hyperterminal):

 

 

/1?T
 /0b0

 

that symbol at the end if it doesn't show up is a heart.

 

Also, the board sends back these messages when it receives a command, not when it completes one.

 

I am officially changing the goal of this topic.  I have decided that reacting to a response from the control board is a misguided goal, and I would like the VI to read a timing file and input that into a "wait (ms)".  When I try this I get problems with data type, inputing an array into the wait doesn't work.

 

I have tried using a read from spreadsheet file outside of the for loop and inputting the timing into the wait using auto-indexing but it does not work.

 

Ideas?

0 Kudos
Message 8 of 11
(3,747 Views)

Hey Team23,

 

To help focus this thread to your latest question. What output of the "Read From Spreadsheet File.vi" are you using to input your timing data into your "Wait (ms).vi" By default the 'Read From Spreadsheet File.vi' reads the data from your file in outputs a 2-D array. So if you wire the 2-D into a For Loop with indexing on, the 2-D array is broken into a series of 1-D arrays and is not a valid input for the Wait (ms).vi. There are a couple choices, you could wire the 1-D array into another For Loop to just have elements. Or, you could simply use the index array to get the actual value you want.

 

However, if your text file simple has a bunch of numbers in a single row, you could use the Read From Spreadsheet File.vi's "First Row" output and wire that into your For Loop with indexing on and then into your Wait (ms).vi.

 

Hope this helps

 

-Ben

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 9 of 11
(3,736 Views)

Team23,

 

Reacting to responses is not misguided.  Its a simple matter of telling the motor to move and then checking it current position until it has reached its destination.  Hard coding delays is just asking for trouble.

 

If you will give me some info about your controller I can help you write a vi to read the responses.

Message Edited by Wayne.C on 04-02-2009 03:07 PM
0 Kudos
Message 10 of 11
(3,725 Views)