Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Help Needed!While Loop

I have been trying in vain to set the following vi up so that two of the final outputs pitch and roll are also inputs in other words there is control involved however any time I try this I get an error message 'this wire is part of a cycle' but if I try to create a while loop to get around this the system does not read the data in continuosly from the serial port. I apologise if the vi is a bit messy.All help appreciated have to present this Wednesday!
kilyg
0 Kudos
Message 1 of 10
(3,893 Views)
First, the VI isn't a bit messy, but very messy - both on the front panel and on the diagram. I'm surprised you can follow it yourself. I strongly advise you use a tab control (can be found in the containers palette) to group your controls and indicators to one spot and that you make subVIs of your redundant code. You have huge pieces of code which are duplicates and which could be minimized into a small icon inside a for loop. Also, document your code. If you have to present your code on wednesday, this is a must. I hope you have the time to do it.
I'm not sure what you are asking for so I don't know what your problem is. Please elaborate more on your objective and what's keeping you from getting to it. I see you already use shift registers. Does this not satisfy your needs?
You can't connect a wire to something that runs before it, because you're creating a paradox. Try using a while loop with a wait around the entire code instead of running it continuously. Move the config serial out of the loop and add close serial after the loop.

Message Edited by tst on 03-14-2005 11:51 AM


___________________
Try to take over the world!
0 Kudos
Message 2 of 10
(3,885 Views)
Okay I have cleaned up the presentation but this is not running for some reason. If I could explain myself better I am looking for the outputs pitch and roll to be inputs to the filter and so replace the controls phi and theta. There would therefore be a feedback loop replacing phi and theta with the outputs pitch and roll
0 Kudos
Message 3 of 10
(3,880 Views)
The sub-vi's are not included in this attachment. Could you either zip them into one file, or save the project as an llb?
0 Kudos
Message 4 of 10
(3,873 Views)
OK. This looks much better. Your subVIs still look like they have too many inputs but if this works then it's good enough for now. If you want to have pitch and roll instead of phi and theta, you have two simple options. The first: right click pitch and roll and select Create>>Local Variable. A local variable is the same as a variable in other languages, so you can change it to Read, and wire them instead of phi and theta. Since you'll need a while loop around your entire code anyway, the more elegant solution would be to add 2 shift registers to this while loop, wire the same wire going into pitch into the right side of the shift register and wire the left side of the shift register into the subVI. Since phi and theta are 1D arrays and pitch and roll are simple numerics, you'll have to compensate for this, according to your needs.

___________________
Try to take over the world!
0 Kudos
Message 5 of 10
(3,869 Views)
How do I set up the sub vi's to execute? They have definitely cleaned up the presentation but they are not processing the data. Can the sub vi's be set up to read data continuously?
0 Kudos
Message 6 of 10
(3,865 Views)
Not knowing exactly what you are trying to accomplish, I can only guess that you want to capture the serial port data and process it as fast as possible. Just put the code you have inside a while loop, and that should do it.
0 Kudos
Message 7 of 10
(3,861 Views)
SubVIs are like functions in other langauges - they have arguments (inputs) and return values (outputs). Once all the wires wired into a subVI have delivered their data, the VI will execute. To see what's happening in your code, you can use debugging devices like probes (the yellow circle with a P on the tools palette) and highlight execution (the light bulb button on the menu bar). Highlight execution should allow you to see exactly where your code is, but keep in mind that it runs in slow motion, so the serial comm may work differently. If all this didn't help, save your code as an LLB (File>>Save with options>>Development Distribution) and post it here.

___________________
Try to take over the world!
0 Kudos
Message 8 of 10
(3,859 Views)
I have tried to run this vi sub vi by sub vi to locate the problem. The first sub vi read in the data ok from the serial port but the second sub vi does not perform its function of removing 00AA hex bytes from the data that is to be sent to the third array.The red light of the 2nd sub vi flashes on and off. What mistake am I making in processing the data?
0 Kudos
Message 9 of 10
(3,853 Views)
I didn't understand what you're trying to do.
Do you want to remove all the characters after 00AA? If so, you don't need to do the conversion to the array and you don't need the while loop. Just use the string functions on the string. If not, explain exactly what you want to do.
What do you mean by "the red light flashes"? Are you talking about the X in the error cluster? If so, it means you have occasional errors in your serial read.

___________________
Try to take over the world!
0 Kudos
Message 10 of 10
(3,842 Views)