LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Question,

Hi, i was wondering while in a while loop how do make a function perform once. I want the rest to keep sending the string, but for PWM6 I just want the string to be sent once then it stop sending the string, unless I move the knob to a different value.


Thanks,
0 Kudos
Message 1 of 6
(3,037 Views)
Hi,
 
If it is just a section of program inside a while loop that you want to execute for one iteration and not for subsequent iterations, there are a lot of ways to do it.
 
If you post your VI, we can sugest the most applicable option.
 
regards
Dev
 
 
0 Kudos
Message 2 of 6
(3,034 Views)
Opps, i thought i did upload my VI i guess it didn't do it.

Download All
0 Kudos
Message 3 of 6
(3,021 Views)
Your VI is very hard to read with initialization on the right, diagram much larger than screen, and objects hidden behind case structures, etc. Here is a cleaned up and simplified version which may do what you want.

Lynn
Download All
0 Kudos
Message 4 of 6
(3,009 Views)
I am just a student learning the basis of labVIEW. This is my first course. If you don't mind can you tell me what you did, and why you did it. Thanks for the help

Message Edited by wqvong on 12-06-2005 07:05 PM

0 Kudos
Message 5 of 6
(2,990 Views)
1. All data flows from left to right. So I moved the VISA Configure Serial port.vi to the left side of the diagram.
2. No diagram or panel should be larger than one screen. If you are so lucky as to have a very large screen, keep the diagrams to half of the screen. The changes I made allow this guideline to be followed. I did not change the front panel. I could not tell what you wanted the panel to do or look like.
3. Use subVIs to help accomplish item 2. The String Generator.vi contains code that your original had 6 copies scattered all over the diagram. The case structure to the left of the subVI selects the inputs to be used on a particular iteration of the while loop. Generally avoid repeating code; use loops instead.
4. The quotient and remainder function selects the PWM 1 through PWM 6 controls on successive iterations. The shift register connected to PWM 6 is used to detect value changes and only write when a change occurs. (Caution: Equality testing on real numbers is risky because of the way the numbers are stored in binary. It will probably work in this application, but I could not test it because I do not have a serial port.
5. Shift registers on the VISA resource name and error clusters will cause the writing to stop if a serial port error occurs. The presence of an error should probably be ORed into the loop terminator.
6. I failed to connect Output String 5 in the upper left case structure. Trying to do things too quickly and no chance to test.
7. Why do you have 2 Stop buttons? This will be confusing to the user, especially since one of them does not connect to anything.
8. Loops should usually have a Wait function to prevent them from consuming all available CPU time. This is especially important if multiple nodes are executing in parallel. I put a comment on the diagram but did not insert a wait.

If you have other questions, please post them.

Lynn
0 Kudos
Message 6 of 6
(2,969 Views)