Channel calculation with if loop
Hello!
I had a syntax problem concerning the calculation of channel (I must confess that I'm not an expert at all...).
Here's the problem: I got a measurement with two groups and multiple channels. I need to create a new channel that goes to 1 when the right conditions are given and will scratch if they are not met. My problem is that I do not know how to run a calculation and how to address the channels within an if loop.
Somehow, it should look like this:
Call BadExample
Function BadExample (NewCreatedChannel)
If
("Ch('[2]/Example') > = 1000") and ("Ch('[2]/Example2') < 1600)="" and ("ch('[2]/example3')=""> 10") and ("Ch('[2]/Example4')< 0.025*("ch('[2]/example5')+="" 10)="" and ("ch('[2]/example6')=""> > 210")
or
("Ch('[2]/Example') > = 1200") and ("Ch('[2]/Example2') < 1800)="" and ("ch('[2]/example3')=""> 10") and ("Ch('[2]/Example4')< 0.025*("ch('[2]/example5')+="" 10)="" and ("ch('[2]/example6')=""> > 240")
then
NewCreatedChannel = 1
On the other
NewCreatedChannel = 0
End if
End Function
I know that this won't work... but I hope you get the idea!
It would help even if someone could tell me how to implement a channel calculated in this loop.
Thank you!!!
Hey Melihson,
There are many possibilities to do so.
An example is to use the calculator IIF function that works with both channels.
Simply declare the condition and choose the values true and false, which can be 0 and 1.
Here's a simple example using the Example.TDM file:
Call Data.Root.Clear)
Call DataFileLoad "(par EXEMPLE.)" CT","CT","load")
Call Calculate ("Ch(""Results/Res1"") = IIF (Ch(""[2]/Schall_1"") > 0.1, 1, 0) '")
Call Calculate ("Ch(""Results/Res2"") = IIF (Ch(""[2]/Schall_2"") > 0.4, 1, 0) '")
Call Calculate ("Ch(""Results/ResAnd"") = AndB (Ch(""Results/Res1""), Ch(""Results/Res2""))")
If you use the English version just change channel names.
This code snipped evaluates two channels and combines logically with ETB function.
You can also use this approach for more than two channels.
Best regards
Christian
Tags: NI Software
Similar Questions
-
How to acquire of various AI channels simultaneously with a different range for each of them?
How to acquire of various AI channels simultaneously with a different range for each of them?
In LabView, I found some examples but in C it is not seem to be any.
Or you can add channels one by one with individual instructions: the follwing code compilation and runs without error on vitual DAQ hardware:
ERR = DAQmxCreateTask ("", &taskH); ")
ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai0', 'AI0', DAQmx_Val_Cfg_Default,-5,0, 5.0, DAQmx_Val_Volts, "");
ERR = DAQmxCreateAIVoltageChan (taskH, ' Dev1/ai1', 'AI1', DAQmx_Val_Cfg_Default,-10,0, 10.0, DAQmx_Val_Volts, "");
DAQmxStartTask (taskH);
ERR = DAQmxReadAnalogF64 (taskH, 5, 10.0, DAQmx_Val_GroupByChannel, val, 10, & read, 0);
DAQmxClearTask (taskH);
-
Machine condition with timed loop?
Hello world
Is it possible to have a state machine with timed loop? i.e. on the last State, wait us here until the end of the period to return to the initial state again.
Thank you
crazycompgeek wrote:
Hello world
Is it possible to have a state machine with timed loop? i.e. on the last State, wait us here until the end of the period to return to the initial state again.
Thank you
Yes. However, when the loop is running, there is no way to stop the program or do any other action. But if this is what you want, yes it is possible.
-
Application crashes with parallel loops
I developed an application that controls a digital fluorometer using a C++ DLL (provided by the seller) via a USB connection. I created specifically as QMH architecture because long scans on the fluorometer may take a few seconds and I want the user to be able to control the façade while the equipment is running in parallel. For some reason any, when the loop of material control is bound to its analysis, the façade hangs. If I click anywhere in the window, I get the «...» "" Message do not answer ' in the toolbar until the scan is finished. " While this happens, memory and processor remain substantially the same so I do not think he is tied up system resources. In addition, Windows normally responds.
I think the DLL is called to a level that affects all vi and when the call of the DLL will be made, each process LabVIEW gets put on hold. I'm leaving basic with this assumption? If this is not the case, how could one breach of this situation?
Yes - your problem is with the loop of wire/root LabVIEW UI. There is a very good article about it here.
Your call library function node is set to 'Run' in the UI thread which means that it will be executed in the same thread as stock user interface or anything else that requires that the user interface thread. In other words, no other action of the user interface can occur when your C++ DLL function runs - it blocks the thread to continue.
You need to know if the DLL is thread-safe, and if this is the case, change the method of appeal of the C++ DLL in the call library function node to 'run in any thread '.
You can make a difference in the color of the COLD LAKE:
-
Mathematical calculation with the numbering of the current page
Hello
I am currently in a situation where I need 2 types of page numbers for a single page.
To the right side, I use the current page number marker.
Is there a way to make a mathematical calculation with number of current page on the left side?
Something like 460 + current page number
I can't use the data merge feature because all the page are already installed on.
Kind regards.
Hello
You can run a script:
app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "~N"; var FindGrep=app.activeDocument.findGrep(), len = FindGrep.length, item, pageNo, calcNo, rightSide, mDiff = 460; // edit this value according to needs while (len-->0) { item = FindGrep[len]; pageNo = item.parentTextFrames[0].parentPage.name; calcNo = parseInt(pageNo) + mDiff; item.paragraphs[0].contents = calcNo + "\t" + pageNo; rightSide = item.parentTextFrames[0].textFramePreferences.textColumnFixedWidth; with (item.paragraphs[0]) { tabStops.add({alignment: TabStopAlignment.RIGHT_ALIGN, position: rightSide}); justification = Justification.LEFT_ALIGN; } }
that should work assuming management texts related with the pageNumbers are substituted (accessible)
Jarek
-
How to disable certain fields in the form of a calculation with a checkbox for the fields.
How to disable certain fields in the form of a calculation with a checkbox for the fields.
In Canada, we have taxes
I create a form that allows them to calculate a total
I need to be able to turn off all of those taxes to participate in the calculation and to their field visible should be 0
I was thinking about using a check box (when the checkbox is enabled (Yes) the tax is calculated, unchecked (Off) the tax is not calculated and visible field should show 0 or anything...)
I really need help on this one, I am a complete newbie...
Note that the second tax is calculated on the sum of what the first tax Add (tax first is pan-Canadian tax (all provinces).
The second tax is never only use (Quebec only (in addition to one Canadian)
Sometimes to sell outside Canada - no tax at all is calculated...
What should I do?
Yes, it's just the JS...
-
Dear Forum
Im working a calculator with a textfield. It can calculate if an input one number, but does not work when I try to enter two or three. I test several codes but they don't work at all. Could someone give me a helping hand. Please join you file.
var numeroEntrado = "";
var campoUno:int = 125;
var campoDos:int = 20;
var elResultado1 = 0;
var elResultado2 = 0;d. Text = '125 grs.';
cholesterol. Text = '20 mml.';
colesterol.backgroundColor = 0x9999FF;
textoColesterol.backgroundColor = 0x9999FF;numeroPorciones.maxChars = 3;
numeroPorciones.restrict = "0-9";btn.addEventListener (MouseEvent.MOUSE_UP, suma);
function sienteTecla(event:KeyboardEvent):void {}If (event.keyCode == 48) {numeroEntrado = 0 ;}
If (event.keyCode == 49) {numeroEntrado = 1 ;}
If (event.keyCode == 50) {numeroEntrado = 2 ;}
If (event.keyCode == 51) {numeroEntrado = 3 ;}
}
function suma(evt:MouseEvent):void {}
d. Text = "";
elResultado1 = (campoUno) Number * Number (numeroEntrado).
d. Text = elResultado1 + "grs".cholesterol. Text = "";
elResultado2 = Number (campoDos) * Number (numeroEntrado).
cholesterol. Text = elResultado2 + "mml";
numeroPorciones.text = «»
}Thank you
IN
It is hard to tell without understanding your intent.
I don't see where event listener for sienteTecla is assigned.
If numeroEntrado is supposed to be numeroPorciones value (a guess) so maybe you could just do something like this:
function suma(evt:MouseEvent):void {}
If ("numeroPorciones.text! =" ") {}
d. Text = "";
elResultado1 = (campoUno) Number * Number (numeroPorciones.text).
d. Text = elResultado1 + "grs".cholesterol. Text = "";
elResultado2 = Number (campoDos) * Number (numeroPorciones.text).
cholesterol. Text = elResultado2 + "mml";
numeroPorciones.text = «»}
} -
I have a form that contains text boxes where the name is created dynamically with a loop variable.
< cfset formcounter = 1 >
< cfoutput query = "ViewParts" >
< input type = "hidden" name = "" RecordID #formcounter # "value =" #RecordID #">"
< cfset formcounter = formcounter + 1 >
< / cfoutput >
< cfoutput > < cfset formcountermax = #formcounter # > < / cfoutput >
on the page, he submits to the that I have:
< cfloop from = "1" = "" #formcountermax # "index ="increment">"
< cfif form. NEQ Qtyshipped1 '0' AND form. Qtyshipped1 NEQ "" > "".
< CFQUERY NAME = "InsertQty" DATASOURCE = 'mydatasource' >
INSERT INTO InvoiceTable
(
Reffacture,
QtyShipped,
RecordID
)
VALUES
(
"#GetLastInvID.InvoiceID #"
#form. Qtyshipped1 #.
#form. RecordID1 #.
)
< / CFQUERY >
< / cfif >
Instead of '1' at the end of the inserted variables, I want my increment. I don't know how to name what is possible.MarkWright wrote:
> Any ideas?
Do not evaluate. 98.798% of the time that it is not necessary. Table
Notation, learn, love, it's very powerful. -
generic calculations with changing the number of channels
Hello
I want to do some math basic with a flexible number of channels. The point is that I get an error if I specify strings that do not exist in my calculations. For example:
CCh("[1]/CNV",2)-CCh("[2]/CNV",2) + CCh("[3]/CNV",2)-...
I think that it should be possible to do this using a script, but you have no idea how to do it only with the calculator?
Thanks in advance
Jeremy
You can do this easily using the recoding for VBScript method described in the following KB:
http://digital.NI.com/public.nsf/allkb/B769AE10EDB656D28625692D00583166?OpenDocument
-
Can someone tell me what's wrong with my loop of consumer queue or producer?
A Labview engineer helped me with the overall structure of my program, made necessary by the rapid sampling rate data and post-processing requirements. He recommended the producer/consumer, loop and using one of the example (Cont CQI graph - int clk voltage) files to actual data acquisition. So I put the loop on foot and spend my two channels of data acq past in the loop of the producer. However, nothing is get picked up in the loop of consumer and none of my data gets displayed there.
Someone wants to take a look and let me know what I am doing wrong?
It seems that the only time where you have to write the data in the queue (in the loop of the producer), when you stop the DAQ while loop or the acquisition of data generates an error.
You may need to place the element from the queue node in the data acquisition while loop.
-
How to read several channels simultaneously with a minimum
Hi all
Please see the attached file. In fact, this is a simplified example of my real application, I didn't understand the second half to reduce the complexity.
As demonstrated, I have two entries of analago I need to read (position and acceleration) with a SPECIFIC requirement which is:
At the same time, I make some decisions based on data more recently acquired in the "timed loop. The decision part is not included in this vi. for simplicity. But the fact is that I just need the most recent data (as well as online) make a kind of decisions.
Everything seems fine and it seems that I collect data in a way desired interval of 1msec. BUT I just discovered that the data I read (in the timed loop) are the most recent one compare is not to the real sensors. In other words, there is a delay in the acquisition process. The value in the timed loop is like 100 msec delayed the release of real sensor, which is generated by the sensor and acquired by DAQ card.
This problem makes my decision making part of constantly decide according to the before value of 100 msec. Unfortunately, it's terrible to my request, i.e. it is an intolerable delay to the process.
Are my settings of data acquisition as samples per channel, the number of samples per channel or right of sampling rate? I appreciate if someone can help me with this application. I just need to collect data at 1 kHz, as close as possible in real-time (online) or with a minimum delay, not 100 msec.
Thank you.
-
Can I sell music from Garageband with Apple Loops loops?
I was wondering if I could sell GarageBand music with the new update to GarageBand. Could I do a song and do a couple of apple loops loops in the song? I can also only use Apple Loops loops and sell?
Yes, you can use the loops in your projects and sell songs. The only restriction is that you must not sell the loops loops.
If you look to the top of GarageBand to the AppStore, you will see a link to the contract of license App: App license agreement
You can use the instruments and loops to produce your work of art, but not distribute them as autonomous loops or instruments.
-
Subvi with while loop + event structure works is not in multi tab VI
Hi all
I'm developing an interface for the control of a prober using Labview 2012, and I'm stuck with a question.
First I provide you with a simplified version of my VI control interface and the sub - VI used to generate and manage the mappings of wafer.
The VI is composed of several tabs: Prober initialization, manipulation of Wafer, Wafer map, status, error.
The sub - VI can:
1 / initialize the grid to display the map (Subvi Init grid not provided here)
2 / coordinates XY for import a txt file (Subvi Wafer map Import)
3 / view contact information and the index of the sector under the cursor
4 / and what position die is double clicked and the Boolean 'Edit Wafer map' is true, then the user can change the State (color) of the matrix between die on platelets and selected Die
My question:
If I use the sub - VI by itself, it works fine. However, when I use it as a Subvi in the 'Wafer map' tab, the plan does not rise and I can use any features incorporated into the Subvi.
I suspect that the while loop + structure of the event of sub - VI the bottleneck here.
However I do not know which way to go, that's why I'd be happy to have some advice and help here.
Thank you.
Florian
The question arises because your hand loop 'for' cycles of 33 times. In the loop of 32, appears your Subvi and execution is passed to your Subvi. During this time your main VI expected Subvi in the end, she never does. You could spend your Subvi out of the main loop of the program and run in a separate process, in order to pass data using queues, but you have to find a way to close the Subvi (i.e. a queue). By moving the Subvi on the main process, it is independent and you can do what you want to do with the events and others.
-
How to manage the structure of the event with two loops
I have a question about the structure of the user event with 2 buttons?
key 1: START LOGGING DATA
key 2: STOP LOGGING DATA
How do I control my
structure of the event so that it will work? because now that the loop is save data... I can't stop the loop, when I clicked on buttons.
super_saiyans wrote:
the problem with moving it is that I don't have control of the DATA RECORD STARTING?
Of course, you do. When you get your press conference button, you say your state machine to move to the State of logging. You must also make sure that you return to visit the State to wait for the event to check out the events of the stop button.
-
Manipulate the subdashboards with a loop for?
Hi all
Here is a picture of what I'm trying to do: basically, I want to choose the (3 x 3) A subarray, manipulate data, then
Select the subarray B (2 x 2), manipulate data, and finally select the (4 x 4) C subarray and manipulate its correspondent
data. In my real problem, I have more than A, B, C. I have a number any variables.
I have a 1 d table, below, that I use to make a kind of mapping to my 2D table so I can choose the appropriate sub-table.
Please see the VI attached and see if my approach is logical. To be concrete, the end result of my VI must be a 2D array containing
A, B, C and for each variable, I want the sum total of all the numbers corresponding to this sub-table.
For example, for A, I want 1 + 2 + 2 + 2 + 1 + 5. My real data manipulation would be more complicated, but if I can understand this simple case,.
the real case will follow.
I do not know where to store each subbarray in my loop and WHEN to do my manipulation of data, it must be inside of the inside of the loop, outdoors, where? See the attached VI.
Thanks in advance.
I think you need a boot and wiring through the case of fake.
Note that the output is a table to a dimension. Because pages can be of different sizes, the pages 'A' and 'B' contain empty elements. If no match is found fo a 1 d, a full page table element will be empty. To see this 'B' to replace in the table 1 d with "D".
To make your number a string number followed by conversion table amount works well.
Lynn
Maybe you are looking for
-
How to remove an e-mail account on the iphone?
How to remove an e-mail account on the iphone?
-
http://64.165.34.7:8134 / videoplayer3.html works well, but http://64.165.34.7:8134 / flash_ready.html does not load video in Firefox (black screen with the plug-in is needed, when you try to install "couldn't find any plugin"). Chrome works very wel
-
Pavilion 23-g013w All In One: RAM - what to buy?
I'm looking to upgrade my 4 GB to 8 GB RAM. But I do not know what look for when I buy. In addition, I did not jump the lid of the computer again. I really want to do it until I have the game to install. So, I don't know if there are two cards of
-
File Explorer Windows 7 shows a non-empty folder in a vacuum.
Here's a question that I have no idea how to fix on a Home Premium Windows 7 box. I copied 110 GB of data in a folder named "c:\old disks" earlier. All files where showing well after the copy was completed. Then a few months later, I noticed that I n
-
Magalie Today, I have a bad day. I lost all the money this month (I'm a student), and the worst is that I lost my blackberry z10 . When I knew I lost it, I was very angry.although it is an old phone, I purchase form someone else, but with me, it's a