01-22-2014 07:33 PM - edited 01-22-2014 07:57 PM
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?
01-23-2014 02:09 AM
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
01-23-2014 06:49 AM - edited 01-23-2014 06:53 AM
01-23-2014 07:00 AM
Cool, i haven't looked at Python, but it's a great idea.
/Y
01-23-2014 09:33 AM
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);
01-23-2014 09:48 AM
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.
01-23-2014 10:02 AM
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
01-23-2014 10:11 AM
01-23-2014 10:20 AM
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?
01-23-2014 10:24 AM
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