取消
显示结果 
搜索替代 
您的意思是: 

Two Loops, One Output Window

Hi All,

 

    In the images attached to this post, I have two main loops that run one after the other. I'd like to have one output window with a graph and data that updates with each iteration for both loops. The UpperandLower.png shows the two main loops. At the bottom of the image shows my attempt at selecting which data is written to the output window. THD data.PNG gives a better look at my data selection logic and the output window. I'm sure there's a much more straight-forward (and functional) way to do this, so I appreciate any feedback. 

 

I was going to add the project to this post but at 24MB, it exceeds the 10MB limit. For whatever reason, 7-zip wasn't cooperating.

下载全部
0 项奖励
1 条消息(共 14 条)
2,636 次查看

Use a 3rd update loop which is a queue that waits for data (check out the Producer/Consumer example), then you can easily queue up data each loop and the 3rd loop will update accordingly.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
2 条消息(共 14 条)
2,626 次查看

Your code is a prime example to implement a state machine instead. Your two loops are never active at the same time and contain mostly identical code, so all you really need is one loop and switch state accordingly.

 

It is hard to fully gauge the code from a truncated picture (we can't even see the toplevel loop!), but I think there are serious architectural problem and the the entire thing could be done with much less than half the code.

 

There are also other fundamental flaws, such as poor choice of datatype ((using orange for obvious integers and even doing bitwise operations on them!!! 😮 )

 

 

altenbach_0-1651247816547.png

 

 

The circled code in the left is pure madness! It does not take two selects, two comparison, and two case structures to turn two booleans into a numeric!!!!!

I'd consider starting from scratch with a proper state machine and all your problems will disappear. good luck!

 

We can probably give more targeted advice if you would attach the entire code and explain what it it supposed to do.

0 项奖励
3 条消息(共 14 条)
2,595 次查看

@altenbach wrote:

The circled code in the left is pure madness! It does not take two selects, two comparison, and two case structures to turn two booleans into a numeric!!!!!

.


To turn two booleans into a 0..3 numeric, here's all you need.

 

altenbach_0-1651249337808.png

 

(see also)

 

4 条消息(共 14 条)
2,574 次查看

Hi altenbach,

 

    Thank you for the example of how I can simplify the logic. I had a feeling I was way off on the best way to do this. I'd definitely be interested in learning more about implementing a state machine in my code. 

 

A little overview on what I'm trying to do: I'm trying to create a THD test for a power amplifier where the user enters the frequency spec range, say 1kHz to 10kHz as well as a middle frequency starting point. The program takes the middle frequency starting point and measures THD up to where the THD limit is reached. (Say 3%) Once the upper limit is reached, it moves to the lower frequency limit loop and does the same thing. 

 

So I ideally need a single pop-up window that displays data as the upper frequency and lower frequency loops collect data one after the other. 

 

Sound like something a state machine would be good for?

0 项奖励
5 条消息(共 14 条)
2,556 次查看

@JayWW wrote:

A little overview on what I'm trying to do: I'm trying to create a THD test for a power amplifier where the user enters the frequency spec range, say 1kHz to 10kHz as well as a middle frequency starting point. The program takes the middle frequency starting point and measures THD up to where the THD limit is reached. (Say 3%) Once the upper limit is reached, it moves to the lower frequency limit loop and does the same thing. 


OK, that's not clear at all because you have two upper limits. (A) The one entered by the user (10kHz) and (B) the one where THD exceeds 3%. Is A always larger than B or can A be exceeded if the THD limit has not been reached?

 

Simple enough! that code should fit on a postcard! You have three main states:

 

  1. Idle, where the user enters the desired limits. Go to next state if "Go!" has been pressed.
  2. scanning up from the middle, Go to next state if THD limit has been reached
  3. Scanning down from the middle. Go to idle state and wait for user input.

 

 

0 项奖励
6 条消息(共 14 条)
2,544 次查看

Sorry for the confusion. The upper and lower frequency spec numbers are actually irrelevant when it comes to how the test logic works. The program itself will find the upper and lower limits.

 

To answer your question, typically the THD will pass beyond the given frequency range spec, unless there's something wrong with the unit.

0 项奖励
7 条消息(共 14 条)
2,531 次查看

Well, there still needs to be some upper limit. Seems unreasonable to ultimately go to THz just because the THD measurement is faulty. 😄

 

I guess a hard lower limit is 0Hz. 😄

 

If this is audio, maybe 44.1kHz is a good hard upper limit? Should the scanning be linear or logarithmic?

0 项奖励
8 条消息(共 14 条)
2,492 次查看

I would definitely have an "Abort" button or move to next step in the test button in case a loop gets stuck. But for the most part as soon as you move too far out from the frequency spec the output transformer begins to saturate and that causes a lot of noise. 

 

The sweep would be linear. I'm trying model it after this extremely old test bench that's on it's last legs using all discreet test equipment. In his test routine, if the jump from one frequency to the next causes too much THD, the frequency gets dialed back and retested. These adjustments occur about five times before it's determined to indeed be in a high THD zone. 

0 项奖励
9 条消息(共 14 条)
2,481 次查看

@JayWW wrote:

... the output transformer begins to saturate and that causes a lot of noise. . 


Unless the connector fell off. 😄

 

To give you some pointers, here's a quick demo for a state machine. Easily fits on a postcard. 😄

 

 

altenbach_0-1651264406318.png

 

altenbach_1-1651264457824.png

 

 

10 条消息(共 14 条)
2,446 次查看