LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scripting in LabVIEW

Hi, could you please let me know what is the easiest scripting method that can be used in LabVIEW, we have engineers that know nothing about LabVIEW, they want an scripting language to do simple things like assignments , for loop, while loop and basic math functions such Mean . Is math script ( Matlab) the best choice?

 

The problem I have with Math Script is , I think it is good for complicated mathematics but it can't be used as a command script for LabVIEW ?

 

For example if I have this line in that scripting window

 

vpp= 10

 

then I would like to pass that value to a VI, if I don't have this line then there is no need to have that VI

 

Is there any LabVIEW scripting language that can be good for this purpose?

0 Kudos
Message 1 of 24
(4,422 Views)

You'll have to create an interpreter, thus creating your own scripting language.

It's not too hard actually, read a file, extract an array of lines and loop through them.

For each line, split at '=' and see which command to run, and use/extract the parameters from the 2nd half.

There is e.g. formula nodes which can be fed directly with the parameter part.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 24
(4,374 Views)

LabPython?

 

 

I made an example here, a few years ago.  Wow!  Time flies when you're having fun...

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 24
(4,345 Views)

Cool, i haven't looked at Python, but it's a great idea.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 24
(4,337 Views)

Thanks jcarmody and Yamaeda for your suggestions

 

Before working on your idea about using Paython I would like to show you one example and if you think the toolbox can handle that I will continue

 

This is one of the m files ( matlab ) provided by them:

 

As you can see below they can call functions , use basic math functions and use basic commands such as if , for , while?

They would like to have an environment like this but when for example they call a function I don't want to run a Matlab or Paython code. I want to run a SubVI which is specified for that command and then we goto to the second line and continue. SO everything should be implemented in LabVIEW but I want to give them this capability to write scripts (since they don't know LabVIEW) but everything should be execute in LabVIEW. Can the Paython toolbox give me this capability?

 

If not do you have any suggestion

 

------------------------------------------------------------------------------------------------------------------------------

 

 

vTest = 0.8; %default voltage value for current measurements is 0.8V
end

atpMode = 2;
atpAddress = 3;
tpCfg = 'ATP';
tpAnaBuff = 'OFF';

configATP(dutNum,ATPmode,ATPaddress,tpCfg,tpAnaBuff);
%This function sets up the DUT test mode and test point

vdd = [];
vpp = [];

configTIBVolt(vdd,vpp,vTest);
% This funciton configures the analog voltages on the test interface board
% Variables that are empty would retain their previous values

bufferOn = 0;
configDUTRelay(bufferOn);
% This function configures the relay that selects the analog buffer on the
% DUT board. For current measurements, the buffer should be bypassed

k = 1;
trimCode = 0;

while(trimCode(k) < 8 && trimCode(k) > -9) %iBias Trim is 2's complement 4-bit

numBits = 4;
trimCode_twosComp = dec2twosComp(trimCode(k),numBits);
% this function converts the decimal trimCode into its 4-bit two's
% complement form since the iBias trim codes are in two's complement

regData = ['xxxx',trimCode_twosComp];
regAddr = 13;
regReadModifyWrite(dutNum,regAddr,regData)
% This function reads the register value, modifies only the selected bits,
% (i.e. those that aren't 'x'), then writes back to that register.
% This is to avoid overwriting unrelated bits in the same byte

dutOut = 'CURR_MEAS';
pxiAnaIn = 'CURR_MEAS';
dutVpp = [];
dutVdd = [];

configTIBMux(dutNum, dutVpp, dutVdd, dutOut, pxiAnaIn);
% This function configures the test interface board analog switches for
% VDD, VPP, DUTout, and PXIanaIn
% Variables that are empty would retain their previous values

pauseTime = 1e-3;
pause(pauseTime);
% Wait for everything to settle.


if( k>2 && direction(k)~=direction(k-1) )
% If the sign of the error changed, then the best trim code is
% either this one or the one just before it

[Y, minIndx] = min(abs(iBias-targetIBias));
% Finds the index with the min error

iBiasTrimCode = trimCode(minIndx);
iBiasMeas = iBias(minIndx);
% assigns values to output variables

trimCode_twosComp = dec2twosComp(iBiasTrimCode,numBits);
regData = ['xxxx',trimCode_twosComp];
regReadModifyWrite(dutNum,regAddr,regData)
% write the best trim code t0 the DUT

return
% Exit the function
end

trimCode(k+1) = trimCode(k) + direction;
k=k+1;

end

% If we've reached this portion of the code, then we failed to find an optimal
% trim code. We should just return the last values, since these are as close
% as we can get to the target (i.e. we're at the edge of the range)
iBiasTrimCode = trimCode(end-1);
iBiasMeas = iBias(end);

 

 

0 Kudos
Message 5 of 24
(4,305 Views)

I don't think that LabPython will do what you want.  I've done something similar using a string-based queued state machine with "macros" that direct the state sequence.  You'd have to define a state for every function you wanted to support and you'd need some mechanism for passing data around.  What you've described doesn't sound trivial.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 24
(4,298 Views)

Thanks Jcarmody for your quick reply. Could you please send me an example of what you have done before ( if it is avialable). I think it can give me a good idea of how to continue.

 

Thanks

0 Kudos
Message 7 of 24
(4,293 Views)
Why bother using LabVIEW? An awful lot of work to place a wrapper around each and every matlab function. That would only serve to make the script execute slower. I also fail to see how you would use loops and if statements on a line by line basis. LabVIEW scripting could be used but that is a pretty advanced topic.

What problem are you trying to solve? The engineers seem fluent in matlab.
0 Kudos
Message 8 of 24
(4,289 Views)

They can use it for characterisation but for test and production all the code is in LabVIEW , we want to give them this ability to write test scripts instead of using a test engineer to implement what they want

By the way what is LabVIEW scripting? 

 

 

0 Kudos
Message 9 of 24
(4,284 Views)

I also need to mention they don't need to script in Matlab. they just want a user friendly environment to write scripts but then LabVIEW should compile and execute that

0 Kudos
Message 10 of 24
(4,281 Views)